如何让这个 JButton 看起来像 awt.Button?
JButton button = new JButton("bob");
button.setUI(???????);
如何让这个 JButton 看起来像 awt.Button?
JButton button = new JButton("bob");
button.setUI(???????);
这是三个单独的 ui Lookandfeel 选项
UIManager.setLookAndFeel (“java.awt.swing.plaf.metal.MetalLookAndFeel” ) ;
SwingUtilities.updateComponentTreeUI ( this ) ;
UIManager.setLookAndFeel (“java.awt.swing.plaf.windows.WindowsLookAndFeel” ) ;
SwingUtilities.updateComponentTreeUI ( this ) ;
UIManager.setLookAndFeel (“java.awt.swing.plaf.motif.MotifLookAndFeel” ) ;
SwingUtilities.updateComponentTreeUI ( this ) ;
如果您想在您的机器上查找已安装的外观和感觉:
//Get Installed look and Feels
import javax.swing.UIManager;
public class InstalledLookandFeels {
public static void main(String args[]) {
UIManager.LookAndFeelInfo laf[] = UIManager.getInstalledLookAndFeels();
for (int i = 0, n = laf.length; i < n; i++) {
System.out.print("LAF Name: " + laf[i].getName() + "\t");
System.out.println(" LAF Class name: " + laf[i].getClassName());
}
System.exit(0);
}
}