Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.78 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to install/configure custom Java Look-And-Feel?
  2. try {
  3.     UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
  4. } catch (Exception e) {
  5.     e.printStackTrace();
  6. }
  7.        
  8. -Dswing.defaultlaf=com.seaglasslookandfeel.SeaGlassLookAndFeel
  9.        
  10. import java.awt.*;
  11. import javax.swing.*;
  12. //import javax.swing.plaf.InsetsUIResource;
  13.  
  14. public class NimbusJPanelBackGround {
  15.  
  16.     public NimbusJPanelBackGround() {
  17.         JFrame f = new JFrame();
  18.         JButton btn = new JButton("  Whatever  ");
  19.         JButton btn1 = new JButton("  Whatever  ");
  20.         JPanel p = new JPanel();
  21.         p.add(btn);
  22.         //UIManager.getLookAndFeelDefaults().put("Button.contentMargins", new InsetsUIResource(0, 0, 0, 0));
  23.         //SwingUtilities.updateComponentTreeUI(f);
  24.         p.add(btn1);
  25.         f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  26.         f.add(p, BorderLayout.CENTER);
  27.         f.setSize(200, 100);
  28.         f.setLocation(150, 150);
  29.         f.setVisible(true);
  30.     }
  31.  
  32.     public static void main(String[] args) {
  33.  
  34.         /*try {
  35.         for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
  36.         if ("Nimbus".equals(laf.getName())) {
  37.         UIManager.setLookAndFeel(laf.getClassName());
  38.         UIManager.getLookAndFeelDefaults().put("Panel.background", Color.white);
  39.         }
  40.         }
  41.         } catch (Exception e) {
  42.         e.printStackTrace();
  43.         }*/
  44.  
  45.         try {
  46.             UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
  47.         } catch (Exception e) {
  48.             e.printStackTrace();
  49.         }
  50.  
  51.  
  52.         EventQueue.invokeLater(new Runnable() {
  53.  
  54.             @Override
  55.             public void run() {
  56.                 NimbusJPanelBackGround nimbusJPanelBackGround = new NimbusJPanelBackGround();
  57.             }
  58.         });
  59.     }
  60. }