1 import java.applet.Applet; 2 import java.awt.*; 3 import java.io.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 import javax.swing.event.*; 7 8 public class nwchem_MD_dynamics extends JPanel implements ActionListener { 9 10 //////////////////////////////////////////////////////////////////////// 11 // Dynamics panel variables 12 //////////////////////////////////////////////////////////////////////// 13 14 JLabel temperlabel; 15 JLabel integrationlabel; 16 JLabel equillabel; 17 JLabel datalabel; 18 JLabel timelabel; 19 JLabel tsteplabel; 20 JLabel ensemblelabel; 21 JLabel vellabel; 22 JLabel recordlabel; 23 JLabel coordlabel; 24 JLabel proplabel; 25 JLabel rstlabel; 26 JLabel synclabel; 27 JLabel veloclabel; 28 JLabel solvlabel; 29 JLabel solxlabel; 30 JLabel presslabel; 31 JLabel relaxlabel; 32 JLabel compresslabel; 33 JLabel templabel; 34 JLabel fillerlabel; 35 JLabel updateslabel; 36 JLabel pairslabel; 37 JLabel centerlabel; 38 JLabel motionlabel; 39 JLabel rdflabel; 40 41 IntegerField equilfield; 42 IntegerField datafield; 43 DoubleField timefield; 44 DoubleField tstepfield; 45 IntegerField velfield; 46 DoubleField temperfield; 47 DoubleField pressfield; 48 DoubleField relaxfield; 49 DoubleField compressfield; 50 DoubleField tempfield; 51 DoubleField solventfield; 52 DoubleField solutefield; 53 IntegerField coordfield; 54 IntegerField solxfield; 55 IntegerField solvfield; 56 IntegerField propfield; 57 IntegerField rstfield; 58 IntegerField syncfield; 59 IntegerField velocfield; 60 IntegerField centerfield; 61 IntegerField motionfield; 62 IntegerField rdffield; 63 IntegerField pairsfield; 64 65 JComboBox ensemblebox; 66 JComboBox integrationbox; 67 JComboBox eccebox; 68 JComboBox relaxbox; 69 70 String[] intstrings = {"leapfrog", "velocity Verlet"}; 71 String[] integrationstrings = {"leapfrog", "vverlet"}; 72 73 GridBagLayout dynamicslayout; 74 GridBagConstraints dynamicsconstraints; 75 Font defaultfont; 76 77 private nwchem_Task task = null; 78 79 nwchem_MD_dynamics(nwchem_Task t)80 public nwchem_MD_dynamics(nwchem_Task t) { 81 82 defaultfont = new Font("Dialog", Font.BOLD,12); 83 dynamicslayout = new GridBagLayout(); 84 setLayout(dynamicslayout); 85 dynamicsconstraints = new GridBagConstraints(); 86 87 task = t; 88 89 //////////////////////////////////////////////////////////////////////////// 90 // Setting up dynamics panel 91 /////////////////////////////////////////////////////////////////////////// 92 //JLabel integrationlabel 93 94 setForeground(Color.black); 95 setFont(defaultfont); 96 97 integrationlabel = new JLabel("Integration: "); 98 integrationlabel.setFont(defaultfont); 99 integrationlabel.setForeground(Color.black); 100 addComponent(this,integrationlabel,0,0,2,1,15,1, 101 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 102 103 104 integrationbox = new JComboBox(intstrings); 105 integrationbox.setSelectedIndex(0); 106 if(task.integration.equals("vverlet")) integrationbox.setSelectedIndex(1); 107 addComponent(this,integrationbox,2,0,2,1,15,1, 108 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 109 integrationbox.addActionListener(new ActionListener(){ 110 public void actionPerformed(ActionEvent e){ 111 task.integration=integrationstrings[integrationbox.getSelectedIndex()]; 112 }}); 113 114 equillabel = new JLabel("equilibration:"); 115 equillabel.setFont(defaultfont); 116 equillabel.setForeground(Color.black); 117 addComponent(this,equillabel,4,0,2,1,15,1, 118 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 119 120 equilfield = new IntegerField(task.equi,0,5); 121 addComponent(this,equilfield,5,0,1,1,7,1, 122 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 123 equilfield.addFocusListener(new FocusListener(){ 124 public void focusLost(FocusEvent e){ task.equi=equilfield.getValue();}; 125 public void focusGained(FocusEvent e){} 126 }); 127 128 datalabel = new JLabel("data:"); 129 datalabel.setFont(defaultfont); 130 datalabel.setForeground(Color.black); 131 addComponent(this,datalabel,4,1,1,1,7,1, 132 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 133 134 datafield = new IntegerField(task.data,1000, 5); 135 addComponent(this,datafield,5,1,1,1,7,1, 136 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 137 datafield.addFocusListener(new FocusListener(){ 138 public void focusLost(FocusEvent e){ task.data=datafield.getValue();}; 139 public void focusGained(FocusEvent e){} 140 }); 141 142 timelabel = new JLabel("time:"); 143 timelabel.setFont(defaultfont); 144 timelabel.setForeground(Color.black); 145 addComponent(this,timelabel,6,0,1,1,2,1, 146 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 147 148 timefield = new DoubleField(task.time,0.0,5); 149 addComponent(this,timefield,7,0,1,1,12,1, 150 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 151 timefield.addFocusListener(new FocusListener(){ 152 public void focusLost(FocusEvent e){ task.time=timefield.getValue();}; 153 public void focusGained(FocusEvent e){} 154 }); 155 156 tsteplabel = new JLabel("time step:"); 157 tsteplabel.setFont(defaultfont); 158 tsteplabel.setForeground(Color.black); 159 addComponent(this,tsteplabel,6,1,1,1,14,1, 160 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 161 162 tstepfield = new DoubleField(task.timestep,0.001,7); 163 addComponent(this,tstepfield,7,1,1,1,7,1, 164 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 165 tstepfield.addFocusListener(new FocusListener(){ 166 public void focusLost(FocusEvent e){ task.timestep=tstepfield.getValue();}; 167 public void focusGained(FocusEvent e){} 168 }); 169 170 ensemblelabel = new JLabel("Ensemble:"); 171 ensemblelabel.setFont(defaultfont); 172 ensemblelabel.setForeground(Color.black); 173 addComponent(this,ensemblelabel,0,2,2,1,15,1, 174 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 175 176 String[] ensemstring = {"microcanonical", "canonical", 177 "isobaric", "isothermal-isobaric"}; 178 ensemblebox = new JComboBox(ensemstring); 179 if(task.isotherm){ 180 if(task.isobar){ ensemblebox.setSelectedIndex(4); } 181 else { ensemblebox.setSelectedIndex(2); }; 182 } else { 183 if(task.isobar){ ensemblebox.setSelectedIndex(3); } 184 else { ensemblebox.setSelectedIndex(0); }; 185 }; 186 addComponent(this,ensemblebox,2,2,2,1,15,1, 187 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 188 ensemblebox.addActionListener(new ActionListener(){ 189 public void actionPerformed(ActionEvent e){ 190 int i = ensemblebox.getSelectedIndex(); 191 task.isotherm=(i==1||i==3); 192 task.isobar=(i==2||i==3); 193 enableSelections(); 194 }}); 195 196 vellabel = new JLabel("Velocity reassignment frequency:"); 197 vellabel.setFont(defaultfont); 198 vellabel.setForeground(Color.black); 199 addComponent(this,vellabel,2,6,2,1,28,1, 200 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 201 202 velfield = new IntegerField(task.freq_reas,0,8); 203 addComponent(this,velfield,4,6,1,1,7,1, 204 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 205 velfield.addFocusListener(new FocusListener(){ 206 public void focusLost(FocusEvent e){ task.freq_reas=velfield.getValue();}; 207 public void focusGained(FocusEvent e){} 208 }); 209 210 temperlabel = new JLabel("temp:"); 211 temperlabel.setFont(defaultfont); 212 temperlabel.setForeground(Color.black); 213 addComponent(this,temperlabel,5,6,2,1,14,1, 214 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 215 216 temperfield = new DoubleField(task.temp_reas,298.15,7); 217 addComponent(this,temperfield,6,6,1,1,7,1, 218 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 219 temperfield.addFocusListener(new FocusListener(){ 220 public void focusLost(FocusEvent e){ task.temp_reas=temperfield.getValue();}; 221 public void focusGained(FocusEvent e){} 222 }); 223 224 presslabel = new JLabel("Pressure:"); 225 presslabel.setFont(defaultfont); 226 presslabel.setForeground(Color.gray); 227 addComponent(this,presslabel,3,5,1,1,7,1, 228 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 229 230 pressfield = new DoubleField(task.press,102500.0,9); 231 addComponent(this,pressfield,4,5,1,1,14,1, 232 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 233 pressfield.addFocusListener(new FocusListener(){ 234 public void focusLost(FocusEvent e){ task.press=pressfield.getValue();}; 235 public void focusGained(FocusEvent e){} 236 }); 237 // pressfield.setEnabled(false); 238 239 relaxlabel = new JLabel("rlx time"); 240 relaxlabel.setFont(defaultfont); 241 relaxlabel.setForeground(Color.gray); 242 addComponent(this,relaxlabel,5,5,2,1,14,1, 243 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 244 245 relaxfield = new DoubleField(task.prsrlx,0.4,5); 246 addComponent(this,relaxfield,6,5,1,1,7,1, 247 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 248 relaxfield.addFocusListener(new FocusListener(){ 249 public void focusLost(FocusEvent e){ task.prsrlx=relaxfield.getValue();}; 250 public void focusGained(FocusEvent e){} 251 }); 252 // relaxfield.setEnabled(false); 253 254 compresslabel = new JLabel("compr:"); 255 compresslabel.setFont(defaultfont); 256 compresslabel.setForeground(Color.gray); 257 addComponent(this,compresslabel,7,5,1,1,14,1, 258 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 259 260 compressfield = new DoubleField(task.compr,4.53E-10,6); 261 addComponent(this,compressfield,9,5,1,1,1,1, 262 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 263 compressfield.addFocusListener(new FocusListener(){ 264 public void focusLost(FocusEvent e){ task.compr=compressfield.getValue();}; 265 public void focusGained(FocusEvent e){} 266 }); 267 268 dynamicslayout.setConstraints(compressfield,dynamicsconstraints); 269 270 templabel = new JLabel("Temperature"); 271 templabel.setFont(defaultfont); 272 templabel.setForeground(Color.gray); 273 addComponent(this,templabel,3,4,2,1,14,1, 274 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 275 276 tempfield = new DoubleField(task.temp,298.15,7); 277 addComponent(this,tempfield,4,4,1,1,7,1, 278 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 279 tempfield.addFocusListener(new FocusListener(){ 280 public void focusLost(FocusEvent e){ task.temp=tempfield.getValue();}; 281 public void focusGained(FocusEvent e){} 282 }); 283 284 String[] relaxstring = {"System rlx time", 285 "Solvent/solute rlx times"}; 286 relaxbox = new JComboBox(relaxstring); 287 if(task.isotherm_both){ 288 relaxbox.setSelectedIndex(1); 289 } else { 290 relaxbox.setSelectedIndex(0); 291 }; 292 addComponent(this,relaxbox,5,4,2,1,21,1, 293 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 294 relaxbox.addActionListener(this); 295 relaxbox.addActionListener(new ActionListener(){ 296 public void actionPerformed(ActionEvent e){ 297 task.isotherm_both=(relaxbox.getSelectedIndex()==1); 298 enableSelections(); 299 }}); 300 301 solventfield = new DoubleField(task.tmprlxw,0.1,5); 302 addComponent(this,solventfield,7,4,1,1,7,1, 303 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 304 solventfield.addFocusListener(new FocusListener(){ 305 public void focusLost(FocusEvent e){ task.tmprlxw=solventfield.getValue();}; 306 public void focusGained(FocusEvent e){} 307 }); 308 309 solutefield = new DoubleField(task.tmprlxs,0.1,5); 310 addComponent(this,solutefield,8,4,1,1,7,1, 311 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 312 solutefield.addFocusListener(new FocusListener(){ 313 public void focusLost(FocusEvent e){ task.tmprlxs=solutefield.getValue();}; 314 public void focusGained(FocusEvent e){} 315 }); 316 317 updateslabel = new JLabel("Updates:"); 318 updateslabel.setFont(defaultfont); 319 updateslabel.setForeground(Color.black); 320 addComponent(this,updateslabel,0,7,2,1,15,1, 321 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 322 323 pairslabel = new JLabel("pairs:"); 324 pairslabel.setFont(defaultfont); 325 pairslabel.setForeground(Color.black); 326 addComponent(this,pairslabel,2,7,1,1,7,1, 327 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 328 329 pairsfield = new IntegerField(task.freq_pair,1, 5); 330 addComponent(this,pairsfield,3,7,1,1,7,1, 331 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 332 pairsfield.addFocusListener(new FocusListener(){ 333 public void focusLost(FocusEvent e){ task.freq_pair=pairsfield.getValue();}; 334 public void focusGained(FocusEvent e){} 335 }); 336 337 centerlabel = new JLabel("center:"); 338 centerlabel.setFont(defaultfont); 339 centerlabel.setForeground(Color.black); 340 addComponent(this,centerlabel,4,7,1,1,7,1, 341 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 342 343 centerfield = new IntegerField(task.freq_center,0, 5); 344 addComponent(this,centerfield,5,7,1,1,7,1, 345 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 346 centerfield.addFocusListener(new FocusListener(){ 347 public void focusLost(FocusEvent e){ task.freq_center=centerfield.getValue();}; 348 public void focusGained(FocusEvent e){} 349 }); 350 351 motionlabel = new JLabel("motion:"); 352 motionlabel.setFont(defaultfont); 353 motionlabel.setForeground(Color.black); 354 addComponent(this,motionlabel,6,7,1,1,7,1, 355 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 356 357 motionfield = new IntegerField(task.freq_motion,0,5); 358 addComponent(this,motionfield,7,7,1,1,7,1, 359 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 360 motionfield.addFocusListener(new FocusListener(){ 361 public void focusLost(FocusEvent e){ task.freq_motion=motionfield.getValue();}; 362 public void focusGained(FocusEvent e){} 363 }); 364 365 rdflabel = new JLabel("rdf:"); 366 rdflabel.setFont(defaultfont); 367 rdflabel.setForeground(Color.black); 368 addComponent(this,rdflabel,8,7,1,1,7,1, 369 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 370 371 rdffield = new IntegerField(task.freq_rdf,0,5); 372 addComponent(this,rdffield,9,7,1,1,7,1, 373 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 374 rdffield.addFocusListener(new FocusListener(){ 375 public void focusLost(FocusEvent e){ task.freq_rdf=rdffield.getValue();}; 376 public void focusGained(FocusEvent e){} 377 }); 378 379 recordlabel = new JLabel("Recording:"); 380 recordlabel.setFont(defaultfont); 381 recordlabel.setForeground(Color.black); 382 addComponent(this,recordlabel,0,8,2,1,15,1, 383 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 384 385 coordlabel = new JLabel("coord:"); 386 coordlabel.setFont(defaultfont); 387 coordlabel.setForeground(Color.black); 388 addComponent(this,coordlabel,2,8,1,1,7,1, 389 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 390 391 coordfield = new IntegerField(task.freq_coo,0,5); 392 addComponent(this,coordfield,3,8,1,1,7,1, 393 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 394 coordfield.addFocusListener(new FocusListener(){ 395 public void focusLost(FocusEvent e){ task.freq_coo=coordfield.getValue();}; 396 public void focusGained(FocusEvent e){} 397 }); 398 399 solxlabel = new JLabel("solute x"); 400 solxlabel.setFont(defaultfont); 401 solxlabel.setForeground(Color.black); 402 addComponent(this,solxlabel,4,8,1,1,7,1, 403 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 404 405 solxfield = new IntegerField(task.freq_sco,0,5); 406 addComponent(this,solxfield,5,8,1,1,7,1, 407 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 408 solxfield.addFocusListener(new FocusListener(){ 409 public void focusLost(FocusEvent e){ task.freq_sco=solxfield.getValue();}; 410 public void focusGained(FocusEvent e){} 411 }); 412 413 rstlabel = new JLabel("restart"); 414 rstlabel.setFont(defaultfont); 415 rstlabel.setForeground(Color.black); 416 addComponent(this,rstlabel,6,8,1,1,7,1, 417 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 418 419 rstfield = new IntegerField(task.freq_rst,0,5); 420 addComponent(this,rstfield,7,8,1,1,7,1, 421 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 422 rstfield.addFocusListener(new FocusListener(){ 423 public void focusLost(FocusEvent e){ task.freq_rst=rstfield.getValue();}; 424 public void focusGained(FocusEvent e){} 425 }); 426 427 synclabel = new JLabel("sync:"); 428 synclabel.setFont(defaultfont); 429 synclabel.setForeground(Color.black); 430 addComponent(this,synclabel,8,8,1,1,7,1, 431 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 432 433 syncfield = new IntegerField(task.freq_syn,0,5); 434 addComponent(this,syncfield,9,8,1,1,7,1, 435 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 436 syncfield.addFocusListener(new FocusListener(){ 437 public void focusLost(FocusEvent e){ task.freq_syn=syncfield.getValue();}; 438 public void focusGained(FocusEvent e){} 439 }); 440 441 veloclabel = new JLabel("veloc:"); 442 veloclabel.setFont(defaultfont); 443 veloclabel.setForeground(Color.black); 444 addComponent(this,veloclabel,2,9,1,1,7,1, 445 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 446 447 velocfield = new IntegerField(task.freq_vel,0,5); 448 addComponent(this,velocfield,3,9,1,1,7,1, 449 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 450 velocfield.addFocusListener(new FocusListener(){ 451 public void focusLost(FocusEvent e){ task.freq_vel=velocfield.getValue();}; 452 public void focusGained(FocusEvent e){} 453 }); 454 455 solvlabel = new JLabel("solute v"); 456 solvlabel.setFont(defaultfont); 457 solvlabel.setForeground(Color.black); 458 addComponent(this,solvlabel,4,9,1,1,7,1, 459 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 460 461 solvfield = new IntegerField(task.freq_svl,0,5); 462 addComponent(this,solvfield,5,9,1,1,7,1, 463 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 464 solvfield.addFocusListener(new FocusListener(){ 465 public void focusLost(FocusEvent e){ task.freq_svl=solvfield.getValue();}; 466 public void focusGained(FocusEvent e){} 467 }); 468 469 proplabel = new JLabel("property"); 470 proplabel.setFont(defaultfont); 471 proplabel.setForeground(Color.black); 472 addComponent(this,proplabel,6,9,1,1,7,1, 473 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 474 475 propfield = new IntegerField(task.freq_prp,0,5); 476 addComponent(this,propfield,7,9,1,1,7,1, 477 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 478 propfield.addFocusListener(new FocusListener(){ 479 public void focusLost(FocusEvent e){ task.freq_prp=propfield.getValue();}; 480 public void focusGained(FocusEvent e){} 481 }); 482 483 String[] eccestring = {"ecce"}; 484 eccebox = new JComboBox(eccestring); 485 addComponent(this,eccebox,9,9,1,1,7,1, 486 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 487 488 fillerlabel = new JLabel(" "); 489 addComponent(this,fillerlabel,10,10,1,1,35,35, 490 GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER); 491 492 enableSelections(); 493 494 } 495 enableSelections()496 void enableSelections(){ 497 if (ensemblebox.getSelectedIndex() == 0) { 498 templabel.setForeground(Color.gray); 499 tempfield.setEnabled(false); 500 relaxbox.setSelectedIndex(0); 501 relaxbox.setEnabled(false); 502 solventfield.setEnabled(false); 503 solutefield.setEnabled(false); 504 presslabel.setForeground(Color.gray); 505 pressfield.setEnabled(false); 506 relaxlabel.setForeground(Color.gray); 507 relaxfield.setEnabled(false); 508 compressfield.setEnabled(false); 509 compresslabel.setForeground(Color.gray); 510 }; 511 if (ensemblebox.getSelectedIndex() == 1) { 512 templabel.setForeground(Color.black); 513 tempfield.setEnabled(true); 514 relaxbox.setEnabled(true); 515 solventfield.setEnabled(true); 516 presslabel.setForeground(Color.gray); 517 pressfield.setEnabled(false); 518 relaxlabel.setForeground(Color.gray); 519 relaxfield.setEnabled(false); 520 compressfield.setEnabled(false); 521 compresslabel.setForeground(Color.gray); 522 }; 523 if (ensemblebox.getSelectedIndex() == 2) { 524 templabel.setForeground(Color.gray); 525 tempfield.setEnabled(false); 526 relaxbox.setSelectedIndex(0); 527 relaxbox.setEnabled(false); 528 solventfield.setEnabled(false); 529 solutefield.setEnabled(false); 530 presslabel.setForeground(Color.black); 531 pressfield.setEnabled(true); 532 relaxlabel.setForeground(Color.black); 533 relaxfield.setEnabled(true); 534 compressfield.setEnabled(true); 535 compresslabel.setForeground(Color.black); 536 }; 537 if (ensemblebox.getSelectedIndex() == 3) { 538 templabel.setForeground(Color.black); 539 tempfield.setEnabled(true); 540 relaxbox.setEnabled(true); 541 solventfield.setEnabled(true); 542 presslabel.setForeground(Color.black); 543 pressfield.setEnabled(true); 544 relaxlabel.setForeground(Color.black); 545 relaxfield.setEnabled(true); 546 compressfield.setEnabled(true); 547 compresslabel.setForeground(Color.black); 548 }; 549 if(relaxbox.getSelectedIndex() == 0) { 550 solutefield.setEnabled(false); 551 }; 552 if(relaxbox.getSelectedIndex() == 1) { 553 solutefield.setEnabled(true); 554 }; 555 }; 556 addComponent(Container container, Component component, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int fill, int anchor)557 static void addComponent(Container container, Component component, 558 int gridx, int gridy, int gridwidth, 559 int gridheight, double weightx, 560 double weighty, int fill, int anchor) { 561 LayoutManager lm = container.getLayout(); 562 if(!(lm instanceof GridBagLayout)){ 563 System.out.println("Illegal layout"); System.exit(1); 564 } else { 565 GridBagConstraints gbc = new GridBagConstraints(); 566 gbc.gridx=gridx; 567 gbc.gridy=gridy; 568 gbc.gridwidth=gridwidth; 569 gbc.gridheight=gridheight; 570 gbc.weightx=weightx; 571 gbc.weighty=weighty; 572 gbc.fill=fill; 573 gbc.anchor=anchor; 574 container.add(component,gbc); 575 } 576 } 577 actionPerformed(ActionEvent e)578 public void actionPerformed(ActionEvent e){} 579 580 } 581