0

I am creating a JFrame in the following way.

    JFrame f=new JFrame("Title");
    f.setUndecorated(true);
    f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

However, I am trying to display a custom tooltip text for the JFrame (by default it shows "Iconify"). Please help me out.

Thanks !

Pratanu Mandal
  • 597
  • 8
  • 23
  • 1
    If you set the `setUndecorated(true)` , how will you have the minimze button?? I guess it should be false – Stunner Mar 19 '14 at 08:53
  • The line f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); actually adds the minimize and close buttons ... however they are not the default L&F but taken from the root pane ... that is by design – Pratanu Mandal Mar 19 '14 at 10:41

2 Answers2

1

One way add some panel to frame with tooltip you needed:

JPanel panel = new JPanel();
panel.setToolTipText("Message");
frame.add(panel, BorderLayout.CENTER);

Another way if you have custom minimize button:

JButton button = new JButton() {
  public JToolTip createToolTip() {
    JToolTip tip = super.createToolTip();
    tip.setBackground(Color.YELLOW);
    tip.setForeground(Color.RED);
    return tip;
  }
Tamara Koliada
  • 1,200
  • 2
  • 14
  • 31
0

If you want to change text of minimize button in L&F, you can set InternalFrameTitlePane.minimizeButtonText value if UIDefaults.

UIManager.getDefaults().put("InternalFrameTitlePane.minimizeButtonText", "my text");

It can be used as a solution if you definitely know which L&F your application will use.

4ndrew
  • 15,354
  • 2
  • 27
  • 29