[英]Java custom tooltip for minimize button
I am creating a JFrame in the following way. 我通过以下方式创建JFrame。
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"). 但是,我试图显示JFrame的自定义工具提示文本(默认情况下显示为“ Iconify”)。 Please help me out.
请帮帮我。
Thanks ! 谢谢 !
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;
}
If you want to change text of minimize button in L&F, you can set InternalFrameTitlePane.minimizeButtonText
value if UIDefaults
. 如果要在L&F中更改最小化按钮的文本,则可以将
UIDefaults
设置为InternalFrameTitlePane.minimizeButtonText
值。
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. 如果您确实知道您的应用程序将使用哪个L&F,则可以将其用作解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.