How to change the font of the title bar of the JFrame icon context menu?

Hello world.

I want to know how to change the font of the text that appears in the context menu is native to click with the right button on the icon that is completely left in the title bar of JFrames which use the default appearance for decoration (JFrame.setDefaultLookAndFeelDecorated (true); / / uses the metal L & F, theme "Océans").

I searched and found nothing. I thought I could use what I learned to https://forums.oracle.com/message/9221826, but I couldn't find something that worked.

Thanks to advance.t

After a few more messing around, I finally did! I love so much it makes me a little sad Java how it is difficult to do things like that. In any case, I found a method here to recursively change the fonts of all components in a JFileChooser, but it does not work on the JPopupMenu (now I know the name) who jumps to the top of the icon in the title bar. So I messed around with this method a few casting and was able to change the fonts of the JMenuItems:

public static void setSubComponentFont (Component comp[], Font font) {
    for (int x = 0; x < comp.length; x++) {
        if (comp[x] instanceof Container) {
            setSubComponentFont(((Container)comp[x]).getComponents(), font);
        }
        try {
            //comp[x].setFont(font);
            if (comp[x].toString().contains("JMenu")) {
                for (Component y : ((JMenu)comp[x]).getPopupMenu().getComponents()) {
                    if (y.toString().contains("JMenu")) {
                        y.setFont(font);
                    }
                }
            }
        } catch (Exception ex) {}
    }
}

I was inspired by this thread of utiliser.toString () .contains ().

I also did with nested loops, so the path to the menu items can be seen:

for (Component a : frame.getLayeredPane().getComponents()) {
    System.out.println(a.toString());
    if (a.toString().contains("MetalTitlePane")) {
        for (Component b : ((Container)a).getComponents()) {
            System.out.println(b.toString());
            if (b.toString().contains("SystemMenuBar")) {
                for (Component c : ((Container)b).getComponents()) {
                    System.out.println(c.toString());
                    for (Component d : ((JMenu)c).getPopupMenu().getComponents()) {
                        System.out.println(d.toString());
                        if (d.toString().contains("JMenu")) {
                            d.setFont(font);
                        }
                    }
                }
            }
        }
    }
}

Each System.out.println () gives an indication of what should go on what follows if State, so they should be used one at a time. This does not work for the title of the JFileChooser however font. When I have time I'll either look no further away inside or ask another question.

So, if someone else needs like I did, it's here. As a tip, System.out.println () and. toString() are your friends! That's how I learned what was contained in each object, and which path I needed to take to get to objects of interest.

Thanks anyway!

Tags: Java

Similar Questions

  • How to change the error icon in the validation error message in inputText

    Hello

    I want to change the error icon in the error message when a validation Rodez inputText.

    I know we need a new skin. Should what changes I make?

    inside in your skin such as changing file

    af|message::error-icon{ 

       content:url(/adf/images/abc.png); 

    }

  • Custom device: how to change the channel icon in NI Veristand?

    Hello Board,

    I build peripheral customized for third-party product for my RT controller. They work well and properly. One thing that bothers me is: icon of the chain as shown in the figure below, with the red zone.

    How can I change the icon of the appropriate icon? Any help would be appreciated...

    Thank you!

    Rajamodol

    In the tags for an item, you can use the tag to configure a custom glyph to display for the item. You can use any PNG file as a glyph. As already mentioned a collection of glyphs that install with NI VeriStand is available at \System Explorer\Glyphs.

  • [bump] How to change the drop-down size menu

    Hello

    I have a menu dropdown and I want to change the size = 4. Where to put it?

    Thanks for your help.
    Jen

    Published by: Jen Hu on April 8, 2013 12:38

    Jen Hu wrote:
    Eric,

    Do you mean: put onload = this.width (300); under attributes of HTML form elements?

    What you're trying to define? size or width?

    Size and width are two different attributes.

    For size add this to your page load

    var resultSelect = document.getElementById ("PX_ITEM_NAME");
    resultSelect.size = 6;

  • How to change the background color of menu bookmarks / sidebar

    The bottom of the bookmarks menu sidebar is grey blue currently. Clicking on brings one of the bright blue link background then it turns grey which is difficult to see. How can I get the selected link to stay bright blue or some other easy to see color?

    See http://kb.mozillazine.org/Editing_configuration#How_to_edit_configuration_files

    Add code to userChrome.css below @namespace.

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    
    #bookmarks-view treechildren {background-color:#FFFF99!important}
  • How to change the video icon

    I downloaded short videos from same camera, I converted from MOV to WMV.   In my folder of the windows media video files auto show two different icons. -some videos show as a film strim with a photo in the slide with the arrow, other icons with a generic image and a large WMV on it.  I still want them looking like a strip of film with a part of the projection of the video image.   I think the generic photo icon causes a problem with windows move maker because they don't matter.  Message says "is not indexed and cannot be imported with windows movie maker.

    Maybe the problem files should be converted again.

    There are to many converters available on the net...
    the following links are some examples.

    Proceed at your own risk *.

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    (1) format Factory (freeware)
    http://www.videohelp.com/tools/Format_Factory
    (the 'direct link' is faster)
    (the file you want to download is: > FFSetup260.zip<>
    (FWIW... installation..., you can uncheck
    ('all' boxes on the last screen)
    (Windows XP / Vista / 7)

    First, you will need to decompress the file or just open the
    Drag FFSetup260.exe out of the folder
    and drop it on your desktop. To install left click.

    (2) Freemake Free Video Converter (freeware)
    http://www.Freemake.com/free_video_converter/
    (Windows XP / Vista / 7)

    (3) Xilisoft Video Converter
    http://www.Xilisoft.com/video-converter.html
    (not freeware but receives good reviews)
    (Windows XP (SP2 or later) / Vista / 7)

  • How to change the icons size in the bar of tasks other than small or big

    How to change the size icons in the bar of tasks other than small or big. I'd like an average size.

    There is no intermediate option to choose. You can choose small or large icons on the taskbar. -Ramesh Kumar http://www.WindowsValley.com

  • How to change the icon of the application where the application focus?

    Hello guys

    I want to know how to change the application icon focus when the application.

    I know how to create the icon of the Application, such as insert icon-> properties-> use as the application icon.

    Do you know how to insert the second icon to the project?

    Please help me guys

    TNX'

    Hello

    Ago may messages on roll on icon.

    This is the KB article for the overview icon.

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

    KB article for icon creation.

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

    TNX.

  • How I change the fonts and colors of default return?

    I changed the font and the color of the text through the Tools button and the button options and the tab content. I can't find anything tell me how to change the fonts and colors to the colors and fonts by default. Can you advise me? I use Windows 7 Home Premium OS. Thank you.

    Hi Brenda19605,

    You can use this article to set the fonts and colors: https://support.mozilla.org/en-US/kb/change-fonts-and-colors-websites-use?esab=a & s = do & r = 0 & s = as

    The default settings for the police are in this article:
    https://support.Mozilla.org/en-us/KB/some%20text%20shows%20up%20bold%20after%20upgrade

    Unfortunately for the default color has no good reference. For the text, but it is black (most lower-left), the background is white (color above left). Unvisited links is blue (column 8, line 5) and the visited link is purple (column 9, line 5).

    Let me know if you need help more!

    Lordfreak

  • How to change the font colors in the communities of support?

    How to change the font colors in the communities of support?

    Thank you

    Press or click on use the Advanced Editor in the upper right of this text block which will take you to it.

  • Yoga Tablet 2-1050 - how to change the fonts

    Hello

    Just bought my compressed Yoga 2-1050 and really like it. Updated to Android 5.0, and everything works great.

    A question, however: does anyone know how to change the font (not font size) on my device not rooted?

    Thank you!

    You can't change the fonts by default on an android device, except if the option has been enabled by the devs - in which case, it will be somewhere in the menu "settings".

    However, there are two workarounds:

    1. install another Launcher to game Google store. Different allow different settings such as the layouts of different menu, different fonts, Widgets, etc.

    2. the only other option is to root your device that belongs entirely to the user & one I wouldn't recommend it unless you know what you are doing and accept the fact that it is very easy to brick your device.
    You'll also voiding the warranty (dependent on country) Although some manufacturers are pretty lax on this and can do a RMA number.

    This is pretty much your only options in its current version.

  • How to change the default font size in Word pad

    How to change the font and size of the default settings in wordpad?

    Thank you

    You can change the font and size and then save it as a template - ex: default.wri

    Navigate to this file and make it read-only. Create a shortcut to it and use it as WordPad in the future.

    It will always come back with the font settings that you put, but you will need to save it under a new name every time (you usually do in any case).

    There is no other way to keep the settings of fonts in WordPad.

  • How to change the font size in windows diff that is email; Word; etc.

    How to change the font size in windows diff i.e. E-mail; Word; etc.

    Try the following: (Note: you must be an administrator to do so)

    1. go into the control panel.

    2. double-click on 'ease of access '.

    3. click on "make the computer easier to see.

    4. click on "change the size of text and icons.

    5. click on "Continue" to the pop-up message.

    6. Select "larger scale (120 DPI)(-rendre le texte plus lisible) and click on 'OK'."

    You need to restart for the change to take effect.

  • How to change the default font in the system in all parts completely

    Separated from this thread.

    First BIG THX for this post - helped me change the fonts almost all except those used by the modern UI in point 8.1 of Windows. Looks like the modern user interface to use 'Segoe UI Light' as default font, but it changes the way it changes only in the destop and not in the modern user interface.

    So someone knows how to change the font used in the modern user interface?

    Managed to achieve this:

    Screenshot

    In my view, there is a last default font used by the system, and everything I have to do is find his name and then just follow your steps again.

    Update:

    The font is arial. But when I change in the registry, the system takes a different default font - arial italic.

    How to prevent the system from changing the font to the next in the queue?

    Hi Dan,.

    You cannot change the font size in Windows modern user interface, it's by design. However, you can install a third-party application using your favorite search engine to change the fonts.

    Note: using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    It will be useful.

  • How to change the color of the title bar?

    Hi @all!

    How to change the color of the title bar? I want to use color.black, not blue? who can tell me, thanks!

    If you change your theme of "Bright" (default on the Z10) 'Dark' (which will default on the Q10) all the bars title will change to black. However, be aware that all components of Cascades will change the bright theme with the dark theme, such as the buttons change to light gray to black.

    See example on this page: http://bbcascades.com/index.php/ui-features/design/42-theme (note this is an old screenshot, I should update to have the bright theme with the new blue header bar)

Maybe you are looking for

  • iOS 10 - No Music Videos

    After the upgrade to iOS 10 on two more 6 iPhone and iPad 9.7 purchased Pro, my music videos will not play on any of these devices. Videos always show in my playlist but will not play. On my Macbook Pro and iMac (27 "), they play very well.

  • How to preserve the multi-level iPhoto in Photos folder directory

    If you upgrade OS to Yosemite or El Capitan, how to preserve my folder customized Photos iPhoto multi-level directory? My iPhoto library is 105 GB and contains 41 000 photos, all carefully arranged in a directory of custom and subsidiary subjects. iP

  • Satellite A - need software for keys FN on Windows 7

    Hello Where can I find software for the FN keys? I mean the toolbar on the top view in Windows. I have it on Vista, but now I have seven and can't find it. Sorry for the bad language. THX

  • What should I use: Stand by or hibernation mode?

    What is the general Council concerning power options - should I use (default) stand-by, hibernation or shutdown. This could be for 1 hour or overnight. I just used stand-by but sometimes all night I hear the hard disk activity. I was wondering the ge

  • How to browse the internet? Has been seen Android tablet Bauhn and can't get online

    Hi, I know this will seem like a stupid question, but I, m a senior I am connected to internet through Optus. My daughter gave me his (Bauhn) Android tablet to use to get around.  I am not able to access internet through this tablet...  I activate Bl