我对java的外观和感觉有问题。
在我的主要方法中,我使用以下代码将其设置为Nimbus皮肤:
public class Main
{
public static void main(String[] args)
{
try
{
boolean found = false;
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
{
if ("Nimbus".equals(info.getName()))
{
UIManager.setLookAndFeel(info.getClassName());
found = true;
break;
}
}
if (!found) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.allAuditoryCues"));
}
catch (Exception e) {}
Manager mngr = new Manager();
mngr.setSize(1000, 600);
Utils.centerWindow(mngr);
mngr.setVisible(true);
}
}它给了我这种窗户:

正如您所看到的,JInternalFrames是正确的皮肤,但主窗口不是!
如何将主题也应用于此窗口?
谢谢。
Manager是一个简单的JFrame,有以下代码:
public class Manager extends JFrame
{
public Manager()
{
initComponents();
}
private void initComponents()
{
setDefaultCloseOperation(3);
setTitle("My window");
setIconImage(ImageLoader.getIcon().getImage());
// My components go here
pack();
}
}发布于 2012-04-20 16:49:20
在框架/对话框创建之前,只需尝试打开这两个选项:
JDialog.setDefaultLookAndFeelDecorated ( true );
JFrame.setDefaultLookAndFeelDecorated ( true );这将允许JFrame/JDialog从LaF而不是系统中获得它们的装饰。
发布于 2012-04-20 13:44:01
main window ???的问题发布于 2012-04-20 16:27:28
如果没有一个好的SSCCE,我不知道该为您做什么,但是如果您想要一个总是对我有用的方法的例子,您可以看看github上的爪哇-助理员。具体来说,看看SwingHelper at 这条线。我在下面添加代码是为了遵守堆栈溢出的一些基本规则;)祝您好运。
/**
* Sets the look and feel to the given type (like "Nimbus") Learn more here:
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*
* @param lookAndFeel to set (like "Nimbus")
*/
public static void setLookAndFeel(String lookAndFeel) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ((info.getName()).equals(lookAndFeel)) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SwingHelper.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
}https://stackoverflow.com/questions/10247218
复制相似问题