/Users/lyon/j4p/src/javagroup/tools/processmanager/ProcessManagerFrame.java

1    package javagroup.tools.processmanager; 
2     
3    import javax.swing.*; 
4    import javax.swing.border.TitledBorder; 
5    import java.awt.*; 
6    import java.awt.event.WindowEvent; 
7     
8    public class ProcessManagerFrame extends JFrame 
9            implements java.awt.event.WindowListener { 
10    
11       JTabbedPane _container = new JTabbedPane(); 
12    
13       public ProcessManagerFrame() { 
14           super("Process Manager"); 
15           this.getContentPane().setLayout(new BorderLayout()); 
16    
17           ProcessWatcherPanel watcher = new ProcessWatcherPanel(); 
18           LaunchProcessPanel launcher = new LaunchProcessPanel(); 
19    
20           JPanel pane = new JPanel(); 
21    
22           pane.setBorder(new TitledBorder(BorderFactory.createEmptyBorder(), 
23                   "Process Watcher")); 
24    
25           //pane.setBorder(new JGroovedBorder()); 
26           pane.setLayout(new BorderLayout()); 
27           pane.add("Center", watcher); 
28    
29           //watcher_pane.setBorder(new JGroovedBorder); 
30           //watcher_pane.add("Center", new ProcessWatcherPanel()); 
31           this.getContentPane().add("Center", pane); 
32    
33           pane = new JPanel(); 
34    
35           pane.setBorder(new TitledBorder(BorderFactory.createEmptyBorder(), 
36                   "Process Launcher")); 
37    
38           //JBorderedPane launcher_pane = new JBorderedPane(); 
39           //launcher_pane.setBorder(new JGroovedBorder); 
40           //launcher_pane.add(new LaunchProcessPanel()); 
41    
42           pane.setLayout(new BorderLayout()); 
43           pane.add("Center", launcher); 
44    
45           this.getContentPane().add("South", pane); 
46           addWindowListener(this); 
47    
48           setSize(300, 250); 
49           validate(); 
50           show(); 
51       } 
52    
53    
54       public void windowOpened(WindowEvent e) { 
55       } 
56    
57       public void windowClosed(WindowEvent e) { 
58       } 
59    
60       public void windowClosing(WindowEvent e) { 
61           setVisible(true); 
62           dispose(); 
63    
64           try { 
65               System.exit(0); 
66           } catch (SecurityException ignored) { 
67               // can't 
68           } 
69           // Luke: Disabled below - I personally don't want the processes to die when the 
70           // manager does.  I think of the process manager GUI as a client, rather than the 
71           // server, so the server lives on when it dies.  Uncomment the below if you'd 
72           // rather it the other way 
73           /* 
74             System.out.print("Shutting down. Please wait till all processes are killed .."); 
75             // All processes are killed before exiting. If it is not done, 
76             // JVM stays in memory (at least on Win95) 
77    
78             ProcessManager pm=ProcessManagerHolder.getProcessManager(); 
79             Enumeration processes = pm.getProcesses(); 
80    
81             // cycle and kill all 
82             while (processes.hasMoreElements()) 
83             ((JProcess)processes.nextElement()).kill(); 
84    
85             // upon kill, all thread groups will be stopped. 
86             while (pm.getProcesses().hasMoreElements()) 
87             { 
88    
89             System.out.print("."); 
90             try 
91             { 
92             Thread.sleep(ProcessGarbageCollector.DEFAULT_INTERVAL); 
93             } 
94             catch(java.lang.InterruptedException ex) 
95             {} 
96             } 
97             System.out.println(""); 
98             System.exit(0); 
99           */ 
100      } 
101   
102      public void windowIconified(WindowEvent e) { 
103      } 
104   
105      public void windowDeiconified(WindowEvent e) { 
106      } 
107   
108      public void windowActivated(WindowEvent e) { 
109      } 
110   
111      public void windowDeactivated(WindowEvent e) { 
112      } 
113   
114  } 
115   
116