1 36 37 40 41 42 package java2d; 43 44 import java.awt.GridBagLayout ; 45 import java.awt.BorderLayout ; 46 import javax.swing.JPanel ; 47 import javax.swing.JTabbedPane ; 48 import javax.swing.border.*; 49 import javax.swing.event.ChangeEvent ; 50 import javax.swing.event.ChangeListener ; 51 52 53 58 public class GlobalPanel extends JPanel implements ChangeListener { 59 60 61 private JPanel p; 62 private int index; 63 64 65 public GlobalPanel() { 66 setLayout(new BorderLayout ()); 67 p = new JPanel (new GridBagLayout ()); 68 EmptyBorder eb = new EmptyBorder(5,0,5,5); 69 BevelBorder bb = new BevelBorder(BevelBorder.LOWERED); 70 p.setBorder(new CompoundBorder(eb,bb)); 71 Java2Demo.addToGridBag(p,Java2Demo.controls,0,0,1,1,0,0); 72 Java2Demo.addToGridBag(p,Java2Demo.memorymonitor,0,1,1,1,0,0); 73 Java2Demo.addToGridBag(p,Java2Demo.performancemonitor,0,2,1,1,0,0); 74 add(Java2Demo.intro); 75 } 76 77 78 public void stateChanged(ChangeEvent e) { 79 80 Java2Demo.group[index].shutDown(Java2Demo.group[index].getPanel()); 81 if (Java2Demo.tabbedPane.getSelectedIndex() == 0) { 82 Java2Demo.memorymonitor.surf.stop(); 83 Java2Demo.performancemonitor.surf.stop(); 84 removeAll(); 85 add(Java2Demo.intro); 86 Java2Demo.intro.start(); 87 } else { 88 if (getComponentCount() == 1) { 89 Java2Demo.intro.stop(); 90 remove(Java2Demo.intro); 91 add(p, BorderLayout.EAST); 92 if (Java2Demo.memoryCB.getState()) { 93 Java2Demo.memorymonitor.surf.start(); 94 } 95 if (Java2Demo.perfCB.getState()) { 96 Java2Demo.performancemonitor.surf.start(); 97 } 98 } else { 99 remove(Java2Demo.group[index]); 100 } 101 index = Java2Demo.tabbedPane.getSelectedIndex()-1; 102 add(Java2Demo.group[index]); 103 Java2Demo.group[index].setup(false); 104 } 105 revalidate(); 106 } 107 } 108
| Popular Tags
|