miAsWindows,miAsMotif,miAsMetal为menuItemmiAsWindows.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
miAsWindows.setState(true);
miAsMotif.setState(false);
miAsMetal.setState(false);
}
});
miAsMotif.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String plaf="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
miAsWindows.setState(false);
miAsMotif.setState(true);
miAsMetal.setState(false);
}
});
miAsMetal.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String plaf="javax.swing.plaf.metal.MetalLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
miAsWindows.setState(false);
miAsMotif.setState(false);
miAsMetal.setState(true);
}
});
} private void setWindowStyle(String plaf){
try{
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
}catch(Exception e){
}
}
public void actionPerformed(ActionEvent ae){
String plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
miAsWindows.setState(true);
miAsMotif.setState(false);
miAsMetal.setState(false);
}
});
miAsMotif.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String plaf="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
miAsWindows.setState(false);
miAsMotif.setState(true);
miAsMetal.setState(false);
}
});
miAsMetal.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String plaf="javax.swing.plaf.metal.MetalLookAndFeel";
setWindowStyle(plaf);
canvas.fanning();
miAsWindows.setState(false);
miAsMotif.setState(false);
miAsMetal.setState(true);
}
});
} private void setWindowStyle(String plaf){
try{
UIManager.setLookAndFeel(plaf);
SwingUtilities.updateComponentTreeUI(this);
}catch(Exception e){
}
}
就是 ddbean(丁大伯) 说得很好
这里不用,你可以删掉,其他的没有问题的
我问的不是怎么实现这个!我问的是为什么边框没换!
JDialog.setDefaultLookAndFeelDecorated (true);
//JFrame.setDefaultLookAndFeelDecorated(true);do not use JFrame.setDefaultLookAndFeelDecorated(true);Because com.sun.java.swing.plaf.windows.WindowsLookAndFeel and com.sun.java.swing.plaf.motif.MotifLookAndFeel don't support Window Decoration. So window title and border will not show.However javax.swing.plaf.metal.MetalLookAndFeel supports Window Decoration.you can use UIManager.getLookAndFeel().getSupportsWindowDecorations() to check if current LookAndFeel supports Window Decoration.
com.sun.java.swing.plaf.windows.WindowsLookAndFeel or com.sun.java.swing.plaf.motif.MotifLookAndFeelThey don't support Window Decoration. So window title and border will not show.Clear?
明白了!我试了下!只能显示默认的边框!
谢谢了,100分,马上给你