刚入门并出现问题无论我做什么,我都无法修复,所以任何 帮助将不胜感激。在Nimbus设置后返回GUI返回
我在Java中有一个小应用程序,并集成了弹出日历(WWW) 可用,它使用Nimbus的外观和感觉。我的问题是,在弹出日历第一次被调用 后,我无法 获得与我的GUI相同的外观和感觉。我有两个选择。要么找到一种方法来重置设置,以便我的GUI与以前一样调用 ,并调用弹出窗口,或者输入一些代码而不是 ,确保在哪里(主类),以便所有GUI都使用灵气外观。
下面是弹出日历代码
import java.awt.*;
import javax.swing.*;
import javax.swing.UIManager.*;
public class Celendar extends JFrame {
//private JPanel p;
Celendar(){
//super("ColorEditor");
//UIManager.put("nimbusBase", new Color(233,22,22));
//UIManager.put("nimbusBlueGrey", new Color(22,200,150));
//UIManager.put("control", new Color(100,150,200));
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}else{
UIManager.setLookAndFeel"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and
// feel
}
setLayout(new GridLayout(1,1));
setSize(322,250);
setLocation(500,400);
setResizable(false);
Days d= new Days();
/*----- Here -----*/
//setVisible(true);
//setDefaultCloseOperation(EXIT_ON_CLOSE);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
I THINK HERE IS WHERE I NEED TO INSERT SOME CODE TO GET MY GUI DISPLAYING
BEFORE THECALL TO THE POP UP IS MADE.
/*----------------*/
add(d);
// try{
// //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
// //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
// //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
// //UIManager.setLookAndFeel("com.sun.javax.swing.plaf.metal.MetalLookAndFeel");
// SwingUtilities.updateComponentTreeUI(this);
// }catch(Exception e){System.out.println("error "+e);}
}
}
或者我在哪里插入代码,使我的GUI有灵气的外观和感觉
Java新手,呵?我祝你非常幸运。至少尝试玩得开心。 :)哦,请用四个空格缩进你的代码,参见格式规则。欢迎! :D – 2011-01-05 21:30:36