Java Tips


SwingのLookAndFeelを切り替える


SwingのLookAndFeelを切り替えるには、setLookAndFeel()を使用します。
設定できる値は、
- com.sun.java.swing.plaf.metal.MetalLookAndFeel
- com.sun.java.swing.plaf.windows.WindowsLookAndFeel
- com.sun.java.swing.plaf.motif.MotifLookAndFeel
などです。

JFrame application = new JFrame();

try
{
  // Set LookAndFeel
  UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

  // Activate LookAndFeel toJFrame
  SwingUtilities.updateComponentTreeUI(application);
  application.pack();
} catch (Exception e) {
  e.printStackTrace();
}


目次に戻る
Copyright(c) 2008 WoodenSoldier Software