home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / SwingSet$ToggleUIListener.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  3.4 KB  |  71 lines

  1. import com.sun.java.swing.AbstractButton;
  2. import com.sun.java.swing.JMenuItem;
  3. import com.sun.java.swing.JRadioButtonMenuItem;
  4. import com.sun.java.swing.SwingUtilities;
  5. import com.sun.java.swing.UIManager;
  6. import com.sun.java.swing.UnsupportedLookAndFeelException;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Cursor;
  10. import java.awt.event.ItemEvent;
  11. import java.awt.event.ItemListener;
  12. import java.util.EventObject;
  13.  
  14. class SwingSet$ToggleUIListener implements ItemListener {
  15.    // $FF: synthetic field
  16.    private final SwingSet this$0;
  17.  
  18.    public void itemStateChanged(ItemEvent var1) {
  19.       Container var2 = SwingSet.sharedInstance().getRootComponent();
  20.       ((Component)var2).setCursor(Cursor.getPredefinedCursor(3));
  21.       JRadioButtonMenuItem var3 = (JRadioButtonMenuItem)((EventObject)var1).getSource();
  22.  
  23.       try {
  24.          if (((AbstractButton)var3).isSelected() && ((AbstractButton)var3).getText().equals("Windows Style Look and Feel")) {
  25.             this.this$0.currentUI = "Windows";
  26.             UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  27.             this.this$0.tabPlacement.setEnabled(true);
  28.             SwingUtilities.updateComponentTreeUI(this.this$0.getRootComponent());
  29.          } else if (((AbstractButton)var3).isSelected() && ((AbstractButton)var3).getText().equals("Macintosh Look and Feel")) {
  30.             this.this$0.currentUI = "Macintosh";
  31.             UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel");
  32.             this.this$0.tabPlacement.setEnabled(false);
  33.             SwingUtilities.updateComponentTreeUI(this.this$0.getRootComponent());
  34.          } else if (((AbstractButton)var3).isSelected() && ((AbstractButton)var3).getText().equals("Motif Look and Feel")) {
  35.             this.this$0.currentUI = "Motif";
  36.             UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
  37.             this.this$0.tabPlacement.setEnabled(true);
  38.             SwingUtilities.updateComponentTreeUI(this.this$0.getRootComponent());
  39.          } else if (((AbstractButton)var3).isSelected() && ((AbstractButton)var3).getText().equals("Metal Look and Feel")) {
  40.             this.this$0.currentUI = "Metal";
  41.             UIManager.setLookAndFeel("com.sun.java.swing.plaf.metal.MetalLookAndFeel");
  42.             this.this$0.tabPlacement.setEnabled(true);
  43.             SwingUtilities.updateComponentTreeUI(this.this$0.getRootComponent());
  44.          }
  45.       } catch (UnsupportedLookAndFeelException var6) {
  46.          ((JMenuItem)var3).setEnabled(false);
  47.          System.err.println("Unsupported LookAndFeel: " + ((AbstractButton)var3).getText());
  48.  
  49.          try {
  50.             this.this$0.currentUI = "Metal";
  51.             this.this$0.metalMenuItem.setSelected(true);
  52.             UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
  53.             this.this$0.tabPlacement.setEnabled(true);
  54.             SwingUtilities.updateComponentTreeUI(this.this$0.getRootComponent());
  55.          } catch (Exception var5) {
  56.             System.err.println("Could not load LookAndFeel: " + var5);
  57.          }
  58.       } catch (Exception var7) {
  59.          ((JMenuItem)var3).setEnabled(false);
  60.          System.err.println("Could not load LookAndFeel: " + ((AbstractButton)var3).getText());
  61.       }
  62.  
  63.       ((Component)var2).setCursor(Cursor.getPredefinedCursor(0));
  64.    }
  65.  
  66.    SwingSet$ToggleUIListener(SwingSet var1) {
  67.       this.this$0 = var1;
  68.       this.this$0 = var1;
  69.    }
  70. }
  71.