1 import java.awt.*; 2 import java.io.*; 3 import java.awt.event.*; 4 import javax.swing.*; 5 6 class nwchem_Main extends JFrame implements ActionListener, WindowListener { 7 8 // Menubar 9 10 JMenuBar menubar = new JMenuBar(); 11 12 JMenuItem quit; 13 JMenuItem nwchem, rasmol, gopmol; 14 JMenuItem proper, anal, rms, free, synch, times, timing, rama; 15 JMenuItem frgmnt, segmnt, param, seqnce, topol; 16 17 // Status TextArea 18 19 JTextArea statusarea; 20 JScrollPane statuspane; 21 nwchem_Main()22 nwchem_Main(){ 23 24 super("NWChem Computational Chemistry Software"); 25 super.setSize(400,200); 26 super.setLocation(100,100); 27 super.setBackground(Color.lightGray); 28 super.setForeground(Color.blue); 29 super.addWindowListener(this); 30 super.setFont(new Font("Serif",Font.BOLD,10)); 31 32 GridBagLayout nwchemlayout = new GridBagLayout(); 33 super.getContentPane().setLayout(nwchemlayout); 34 GridBagConstraints nwchemconstraints = new GridBagConstraints(); 35 36 // Setup MenuBar 37 38 this.setJMenuBar(menubar); 39 40 // Setup File Menu 41 42 JMenu select = new JMenu("File"); 43 menubar.add(select); 44 45 select.add(quit = new JMenuItem("Quit")); 46 quit.addActionListener(new ActionListener(){ 47 public void actionPerformed(ActionEvent e){ 48 setVisible(false); System.exit(0); }}); 49 50 // Setup Run Menu 51 52 JMenu run = new JMenu("Run"); 53 menubar.add(run); 54 55 run.add(nwchem = new JMenuItem("NWChem")); 56 nwchem.addActionListener(new ActionListener(){ 57 public void actionPerformed(ActionEvent e){ 58 System.out.println("New NWChem Job"); 59 nwchem_Job job = new nwchem_Job(); 60 job.setVisible(true); 61 }}); 62 63 JMenu view = new JMenu("View"); 64 menubar.add(view); 65 view.add(rasmol = new JMenuItem("Rasmol")); 66 rasmol.addActionListener(new ActionListener(){ 67 public void actionPerformed(ActionEvent e){ 68 System.out.println("RASMOL Coordinate Viewer"); 69 nwchem_Rasmol rasmol_View = new nwchem_Rasmol(); 70 rasmol_View.setVisible(true); 71 }}); 72 view.add(gopmol = new JMenuItem("gOpenMol")); 73 view.add(proper = new JMenuItem("property")); 74 proper.addActionListener(new ActionListener(){ 75 public void actionPerformed(ActionEvent e){ 76 System.out.println("Property Viewer"); 77 nwchem_Property proper_View = new nwchem_Property(); 78 proper_View.setVisible(true); 79 }}); 80 view.add(anal = new JMenuItem("analysis")); 81 anal.addActionListener(new ActionListener(){ 82 public void actionPerformed(ActionEvent e){ 83 System.out.println("Analysis Viewer"); 84 nwchem_Analysis anal_View = new nwchem_Analysis(); 85 anal_View.setVisible(true); 86 }}); 87 view.add(rms = new JMenuItem("rms")); 88 rms.addActionListener(new ActionListener(){ 89 public void actionPerformed(ActionEvent e){ 90 System.out.println("RMS Viewer"); 91 nwchem_RMS rms_View = new nwchem_RMS(); 92 rms_View.setVisible(true); 93 }}); 94 view.add(rama = new JMenuItem("ramachandran")); 95 rama.addActionListener(new ActionListener(){ 96 public void actionPerformed(ActionEvent e){ 97 System.out.println("Ramachandran Viewer"); 98 nwchem_Rama rama_View = new nwchem_Rama(); 99 rama_View.setVisible(true); 100 }}); 101 view.add(free = new JMenuItem("free energy")); 102 free.addActionListener(new ActionListener(){ 103 public void actionPerformed(ActionEvent e){ 104 System.out.println("Free Energy Viewer"); 105 nwchem_Free free_View = new nwchem_Free(); 106 free_View.setVisible(true); 107 }}); 108 view.add(synch = new JMenuItem("synchronization")); 109 synch.addActionListener(new ActionListener(){ 110 public void actionPerformed(ActionEvent e){ 111 System.out.println("Synchronization Viewer"); 112 nwchem_Synch synch_View = new nwchem_Synch(); 113 synch_View.setVisible(true); 114 }}); 115 view.add(times = new JMenuItem("times")); 116 times.addActionListener(new ActionListener(){ 117 public void actionPerformed(ActionEvent e){ 118 System.out.println("Timing Analysis Viewer"); 119 nwchem_Times times_View = new nwchem_Times(); 120 times_View.setVisible(true); 121 }}); 122 view.add(timing = new JMenuItem("timings")); 123 timing.addActionListener(new ActionListener(){ 124 public void actionPerformed(ActionEvent e){ 125 System.out.println("Timing Analysis Viewer"); 126 nwchem_Timing timing_View = new nwchem_Timing(); 127 timing_View.setVisible(true); 128 }}); 129 130 JMenu edit = new JMenu("Edit"); 131 menubar.add(edit); 132 edit.add(frgmnt = new JMenuItem("fragment")); 133 frgmnt.addActionListener(new ActionListener(){ 134 public void actionPerformed(ActionEvent e){ 135 System.out.println("Fragment Editor"); 136 nwchem_Fragment frgmnt_View = new nwchem_Fragment(); 137 frgmnt_View.setVisible(true); 138 }}); 139 edit.add(segmnt = new JMenuItem("segment")); 140 segmnt.addActionListener(new ActionListener(){ 141 public void actionPerformed(ActionEvent e){ 142 System.out.println("Segment Editor"); 143 nwchem_Segment segmnt_View = new nwchem_Segment(); 144 segmnt_View.setVisible(true); 145 }}); 146 edit.add(param = new JMenuItem("parameter")); 147 param.addActionListener(new ActionListener(){ 148 public void actionPerformed(ActionEvent e){ 149 System.out.println("Parameter Database Editor"); 150 nwchem_Param param_View = new nwchem_Param(); 151 param_View.setVisible(true); 152 }}); 153 edit.add(seqnce = new JMenuItem("sequence")); 154 edit.add(topol = new JMenuItem("topology")); 155 156 buildConstraints(nwchemconstraints,0,0,1,1,1,1); 157 nwchemconstraints.fill = GridBagConstraints.BOTH; 158 nwchemconstraints.anchor = GridBagConstraints.CENTER; 159 statusarea = new JTextArea("Status Window"); 160 statusarea.setEditable(false); 161 statusarea.setBackground(Color.white); 162 statuspane = new JScrollPane(statusarea); 163 nwchemlayout.setConstraints(statuspane,nwchemconstraints); 164 super.getContentPane().add(statuspane); 165 166 setVisible(true); 167 168 } 169 buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw,int gh, int wx, int wy)170 void buildConstraints(GridBagConstraints gbc, int gx, int gy, 171 int gw,int gh, int wx, int wy){ 172 gbc.gridx = gx; 173 gbc.gridy = gy; 174 gbc.gridwidth = gw; 175 gbc.gridheight = gh; 176 gbc.weightx = wx; 177 gbc.weighty = wy;} 178 actionPerformed(ActionEvent e)179 public void actionPerformed(ActionEvent e){} 180 windowClosing(WindowEvent event)181 public void windowClosing(WindowEvent event){ setVisible(false); System.exit(0);} 182 windowClosed(WindowEvent event)183 public void windowClosed(WindowEvent event) { System.exit(0); } 184 windowDeiconified(WindowEvent event)185 public void windowDeiconified(WindowEvent event) {} 186 windowIconified(WindowEvent event)187 public void windowIconified(WindowEvent event) {} 188 windowActivated(WindowEvent event)189 public void windowActivated(WindowEvent event) {} 190 windowDeactivated(WindowEvent event)191 public void windowDeactivated(WindowEvent event) {} 192 windowOpened(WindowEvent event)193 public void windowOpened(WindowEvent event) {} 194 195 } 196