混合外观和感觉
到目前为止,
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
UIManager.getBorder("design");//change look and feel here?
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Nimbus isn't available");
}
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
design GUI = new design();
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.setVisible(true);
}
});
}
我正在尝试使主要外观和感觉灵气十足,但将标题边框更改为窗口。
我的边界是这样的:
contentPanel.setBorder(new TitledBorder("Downloader"));
可以吗?如果是的话有人可以指点我去哪里看吗?我现在很困惑。 :\
谢谢。
So far I have this
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
UIManager.getBorder("design");//change look and feel here?
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Nimbus isn't available");
}
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
design GUI = new design();
GUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GUI.setVisible(true);
}
});
}
I'm trying to make the main look and feel nimbus, but change the titled border to windows.
My border is this:
contentPanel.setBorder(new TitledBorder("Downloader"));
Is it possible to do? If it is can someone point me where to look? I'm so confused right now. :\
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经做到了。您必须创建 UI 的一部分,然后调用 UIManager.setLookAndFeel() 来更改外观和外观。感受一下,然后创建其他部分。这更像是一次黑客攻击。
I've done it. You have to create parts of the UI, and then call UIManager.setLookAndFeel() to change the look & feel, and then create the other parts. It's more like a hack.
当
组件
创建后,当前的LookAndFeel
将用于显示该组件
。When a
Component
is created, the currentLookAndFeel
will be used to display thatComponent
.我知道我迟到了,但我认为有人可能会使用它,这是我用来为应用程序添加多种外观和感觉的一种黑客:在启动项目之前(在写入=新之前)将其放置在外观和感觉选择器中)
,然后将 UIManager 外观返回到执行此操作之前的外观和感觉,如下例所示:
像这样,只有按钮测试将具有窗口的外观和感觉,其余部分将具有金属的外观和感觉。
希望这个黑客可以帮助别人。
I know I am late but I think someone might be use this it is kind of hack that I use to put multi look and feel to the app: put this the look and feel chooser before initiating the item (before writing = new ...)
and then return the UIManager look and feel to the look and feel that it was on before you do this after it as in the example below:
Like this only the button test will have the look and feel of the windows and the rest will have look and feel of Metal.
Hope this hack help someone.