How to change the JFrame's titlebar's icon's context menu's font?

Hi everyone.
I want to know how to change the font of the text that appears in the context menu originated from right clicking at the icon that's all the way to the left in the titlebar of JFrames that use the default look and feel for decoration (JFrame.setDefaultLookAndFeelDecorated(true); // which uses the Metal L&F, Ocean theme).
I searched around and found nothing. I thought that I could use what I learned at https://forums.oracle.com/message/9221826, but I couldn't come up with something that worked.
Thanks in advance.t

After some more messing around, I finally made it! I like Java so much that it makes me a bit sad how hard it is to do stuff like this. Anyway, I found a method here to recursively change the font of all components from a JFileChooser, but it doesn't work on the JPopupMenu (now I know the name) that pops up from the titlebar's icon. So I messed around with that method, used some casting, and was able to change the JMenuItems' font:
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 to use .toString().contains() by this thread.
I also did this 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);
Every System.out.println() gives a hint to what should go on the following if condition, so they should be used one at a time. This doesn't work for the JFileChooser's title font though. When I have time I'll either look further into it or ask another question.
So, if someone else needs it like I did, here it is. As a tip, System.out.println() and .toString() are your friends! That's how I learned what was contained in each object, and what path I needed to take to get to the objects of interest.
Thanks anyway!

Similar Messages

  • How to change the browser used for Google search from context menu of selected text?

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

  • How to change the JFrame's title?

    Is it possible to change the title of a JFrame at runtime?
    If so, how?
    sincerely
    nir

    See JFrame.setTitle(String).
    Shaun

  • How to change the size of an individual icon?

    I know that I can do "Show View Options" and drag the slider to change the size of all the icons on my desktop, but how do I change them individually?  I want to make one icon larger and keep the others the same size.
    Thanks!

    hello danacorrick, please see [[Font size and zoom - increase the size of web pages]]. the firefox zoom settings are always only applied for the current domain (for example support.mozilla.org if you scroll here) and will, per default, be remembered the next time you visit a page.

  • How to change the Finder and Time machine Icons

    Hi, wondered how you change these icons as the usual method of just copying and pasting the image in does not work.  Would also like to not have to download an app to be able to do this if possible.
    Thanks.

    I do not think the FINDER icon can be changed.  I have seen software that allows you to change the appearance of external HHDs, but I do not know if that is possible with Time Machine.  If I were a betting man I would say no.
    Ciao.

  • First off this is not a problem it inquery into how to change the color of your basic icons so they are easier to recognize among the rest of my icons.

    I have used different version of FF before and was not able to change the appearance(to be able tweak it with color or style to fit my personality or mood) of the toolbar icons so I hoped that FF 4 would have added that option although I have not found that to be true as yet or am I not looking in the correct place to find that feature.

    Try a different Firefox theme (Tools > Add-ons > Appearance/Themes):
    *Firefox 3 theme for Firefox 4: https://addons.mozilla.org/firefox/addon/firefox-3-theme-for-firefox/
    *Strata XP: https://addons.mozilla.org/firefox/addon/strata-xp/
    *Native XP: https://addons.mozilla.org/firefox/addon/native-xp/

  • How to change the image in title bar for JFrames

    plz give me a small code to change the image of the JFrame in the Title bar.
    i know how to change the name of the title bar .
    import javax.swing.*;
    class Rathna1 extends JFrame
    Rathna1()
    super("rathna project ");
    public class Rathna
    public static void main(String ax[])throws Exception
    Rathna1 r=new Rathna1();
    r.setVisible(true);
    r.setSize(400,400);
    Like this how to change the image of the title bar
    Message was edited by:
    therathna

    hi,
    JFrame frame;
    frame.setVisible(true);
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    frame.setSize(800,600);
    i think the thing u r searching is :
    frame.setIconImage(new ImageIcon("icons/img007.gif").getImage());
    ~~~radha

  • How to change the icon of the Frame(JFrame)

    my doubt is,
    how to change the by default icon(sun coffee cup) icon of a frame to a small user defined icon.
    thank you,
    Ranjith.M

    Take a look at this method:
    http://java.sun.com/j2se/1.4/docs/api/java/awt/Frame.html#setIconImage(java.awt.Image)

  • How to change the components in a visible JPanel?

    How to change the components in a visible JPanel?
    Is there any way to change the components in a JPanel while it is already visible in a JFrame? I tried the na�ve approach of removing the components and adding new ones, but the effect is not the expected.
    For now I'm opening new frames with newly created panels.

    After adding/removing components to/from a panel try:
    panel.revalidate();
    panel.repaint() // sometimes this is also needed, I'm
    not sure whyI'm not certain, but I think that panel.revalidate() implicitly calls repaint() only if something actually changed in the layout. If nothing changed, it sees no reason to repaint; hence, if something changed in appearance but not in layout, you have to repaint it yourself.
    Or something like that. I'm no expert. ;)

  • How to change the icon for print dialog?

    Hello,
    I have a JTable, and with the print() method, I'm able to bring up the Print dialog and successfully print the contents of the table. Example:
    myTable.print( JTable.PrintMode.FIT_WIDTH, myHeaderFormat, myFooterFormat );This works great, but one small detail I'd like to change is the icon in the top-left corner of the dialog. The icon is currently the default Java coffee cup icon, while the rest of my application uses my custom icon. I couldn't find any documentation in the API or tutorials that Java has listed which shows how to change the icon, so I'm not even sure if it's possible (but why shouldn't it be?).
    My question is this: Is it possible to change the default icon in the print dialog? Or do I have to either make my own print dialog somehow, or use a third-party print dialog?
    Thanks

    tjacobs01: Appreciate the assistance (despite your sass). I've already searched the API, tutorials, and this forum. I'm already well aware of the setIconImage() method for JFrame -- after all, that's how I set the icon for my other frames as I previously mentioned. However, I want to set the icon for the print dialog called from the print() method of JTable.
    How would I use setIconImage() for the print() method of JTable? The print() method returns a boolean value, not a JFrame, so I'm just not sure how to implement what you're saying.
    Thanks

  • How to change the Icon for a JFileChooser ?

    Has anyone figured out how to change the icon for an instance of JFileChooser from the coffee cup to something else?
    I'm on 1.4
    Thanks,
    Ken

    Never mind. I figured it out.
    You have to use an instance of JFrame in the call to showXxxxDialog(Component c). Set the icon of the JFrame to what you want the JFileChooser's icon to be.

  • Know how to change the outline shape of a tooltip?

    Hi All,
    I was wondering if anybody knows how to change the shape of a tooltip popup box?
    I've implemented my own UI delegate for ToolTipUI and overridden the paint( Graphics g, JComponent c ) method which I thought would have allowed me to completely control the rendering of the tooltip, box and all. But what I discovered was that even when I did nothing inside this method, the rectangular popup window was still appearing (I stepped through the code, and the correct instance of UI was being used, not the one that may have been defined by UIManager.set( "ToolTipUI", "foo.Bar" )) After a little more investigation, I ended up in ToolTipManager.showTipWindow() which eventually calls
    PopupFactory popupFactory = PopupFactory.getSharedInstance();
    tipWindow = popupFactory.getPopup(insideComponent, tip, location.x, location.y);
    tipWindow.show();To try to overcome this, as a test I extended JButton with the following constructor:
    public TestButton() {
        super();
        setUI( new MyCustomUI() );
        ToolTipManager.sharedInstance().unregisterComponent( this );
    }but this didn't solve the problem either. Has anybody got any ideas on this?
    Cheers,
    Paul.

    Try this.
    regards,
    Stas
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    public class Test {
        JScrollPane scroll;
        JPanel p=new JPanel(new BorderLayout());
        Robot robot=new Robot();
        public Test()  throws Exception {
            final JFrame frame=new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(p);
            JButton b=new JButton("Test balloon!");
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    TransparentFrame frame1=new TransparentFrame();
                    int x=frame.getX()-100;
                    if (x<0) x=0;
                    int y=frame.getY()-100;
                    if (y<0) y=0;
                    frame1.setBounds(x,y,100,100);
                    frame1.createBalloon();
                    frame1.setVisible(true);
            frame.getContentPane().add(b);
            frame.setBounds(200,200,120,50);
            frame.show();
        public static void main(String[] args) throws Exception {
            new Test();
    class TransparentFrame extends JWindow {
        Robot robot;
        BufferedImage screenImg;
        Rectangle screenRect;
        MyPanel contentPanel=new MyPanel();
        boolean userActivate=false;
        Area Balloon;
        public TransparentFrame() {
            super();
            createScreenImage();
            contentPanel.Balloon=Balloon;
            this.setContentPane(contentPanel);
            this.addComponentListener(new ComponentAdapter() {
                public void componentHidden(ComponentEvent e) {}
                public void componentMoved(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentResized(ComponentEvent e) {
                    resetUnderImg();
                    repaint();
                public void componentShown(ComponentEvent e) {}
            this.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                public void windowClosed(WindowEvent e) {
                public void windowOpened(WindowEvent e) {
                public void windowIconified(WindowEvent e) {
                public void windowDeiconified(WindowEvent e) {
                public void windowActivated(WindowEvent e) {
                public void windowDeactivated(WindowEvent e) {
                    Balloon=null;
        protected void createScreenImage() {
            try {
                if (robot==null)
                    robot=new Robot();
            catch (AWTException ex) {
                ex.printStackTrace();
            Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
            screenRect=new Rectangle(0,0,screenSize.width,screenSize.height);
            screenImg=robot.createScreenCapture(screenRect);
        public void createBalloon() {
            Rectangle bounds=new Rectangle(0,0,getWidth(),getHeight());
            Balloon=new Area(new Rectangle(bounds));
            System.err.println(Balloon.getBounds());
            RoundRectangle2D content=new RoundRectangle2D.Double(0,0,getWidth(),getHeight()/3,20,20);
            Polygon polygon=new Polygon(new int[] {20,getWidth()/2,getWidth()},new int[] {getHeight()/3,getHeight()/3,getHeight()},3);
            Area a=new Area(new Rectangle(bounds));
            a.subtract(new Area(content));
            a.subtract(new Area(polygon));
            Balloon.subtract(a);
            contentPanel.Balloon=Balloon;
        public void resetUnderImg() {
            if (robot!=null && screenImg!=null) {
                Rectangle frameRect=getBounds();
                int x=frameRect.x;
                contentPanel.paintX=0;
                contentPanel.paintY=0;
                if (x<0) {
                    contentPanel.paintX=-x;
                    x=0;
                int y=frameRect.y;
                if (y<0) {
                    contentPanel.paintY=-y;
                    y=0;
                int w=frameRect.width;
                if (x+w>screenImg.getWidth())
                    w=screenImg.getWidth()-x;
                int h=frameRect.height;
                if (y+h>screenImg.getHeight())
                    h=screenImg.getHeight()-y;
                contentPanel.underFrameImg=screenImg.getSubimage(x,y,w,h);
    class MyPanel extends JPanel {
        BufferedImage underFrameImg;
        Area Balloon;
        int paintX=0;
        int paintY=0;
        public MyPanel() {
            super();
            setOpaque(true);
        public void paint(Graphics g) {
            super.paint(g);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(underFrameImg,paintX,paintY,null);
            if (Balloon!=null) {
                g.setColor(Color.yellow);
                ((Graphics2D)g).fill(Balloon);
            g.setColor(Color.red);
            g.drawString("Balloon test!",10,20);
    }

  • How to save the JFrame

    how we save the JFrame dynamically???????/

    hiiii
    i'm a student doing my project in real time video processing, wherein we plan to accept real time images 4rm the web camera. We wish to divide the main frame of our front-end into 3 parts. One will display the video coming in 4rm the webcamera & the other side of the screen(front-end) the processed video.
    The third part will consist of radio buttons, textboxes,etc, which we will use to adjust contrast,sharpening,etc. the changes must happen on the video as it comes in. The original video should continue to show as normal, and the processed video should reflect the changes. This should allow us to thus compare the two.
    Please suggest us some way of implementing the above using JMF. We have been able to get the video as it is captured from the webcam. However we are not able to figure out how to implement the second video screen after applying the various techniques, so that it appears as a real time video.
    Any help or suggestions in this regard will be appreciated.
    thanx,
    Leon.

  • How to change the OraSSO login link in webcache/load balance

    Hi
    we have 10gAsR1 installed as a Portal instance. We have 6-server
    load balancer => webcache as loadbalancer (listening port 80)
    Wb ch1 and wb ch2 => webcache (listening port 7777)
    portal1 and portal2 => Portal listening 7778
    infra =>Infrastruture with repository Portal/Oracle SSO (listening 7777)
    This set up is working fine for our intranet setup, now we need to open this for couple of external clients. Well initially we need to open on the load balancer server on port 80 for external team to access, it works fine when we make it publc access.
    Now when we need to make it SSO (siteminder) enables, when users click on login link it first goes oracle sso then it internally redirects the page to site minder sso.
    Well, I have noted that the sso server details are mentioned in global setting sso/oid details. Since we need to open this for external client we have to add a DNS entry for this so that we can allow its access over firewall..
    Now I have made DNS name change at my infrserver level, now I need to update the change at the load balancer server (where wheb chache is running).
    Any one know how to chang the URL at load balancer.
    I am struck at this point please suggest how should i proceed..
    Thanks,

    Extract from Personalization Guide - Page Footer - Personalization Considerations
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a standard Copyright and Privacy (that is, its Auto Footer property is set to true), set the Scope to OA Footer, in the Choose Personalization Context page of the Personalization UI.
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a custom Copyright and Privacy (that is, its Auto Footer property is set to false), set the Scope to Page in the Choose Personalization Context page of the Personalization UI. In the following Page Hierarchy Personalization page , identify and personalize the Privacy page element.

  • How to change the privacy statement link url

    I looked into the previous threads , could not find the answer to "Changing the privacy statement url to clients privacy statement url".
    I am talking about the privacy statement URL in the page that user see it as soon as user logs into the e-business suite.
    I have read the previous theads and developers guide regading how to show or hide this autofooter thing. but could not find any thing about how to change the one in the login page.I even looked ino personalization but could not find a place to change this url. please HELP.
    Another question is " is it ok to show privacy statement in just the first page and hide it in rest of the application pages?"
    Thanks
    karan

    Extract from Personalization Guide - Page Footer - Personalization Considerations
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a standard Copyright and Privacy (that is, its Auto Footer property is set to true), set the Scope to OA Footer, in the Choose Personalization Context page of the Personalization UI.
    * If you wish to personalize the URL that points to the Privacy Statement for a page that displays a custom Copyright and Privacy (that is, its Auto Footer property is set to false), set the Scope to Page in the Choose Personalization Context page of the Personalization UI. In the following Page Hierarchy Personalization page , identify and personalize the Privacy page element.

Maybe you are looking for