import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; //import java.applet.*; import java.net.*; import java.text.*; public class AdcircFrame1 extends JInternalFrame { // GUI variables private JButton Button1,Button2,Button3,Button4,Button5,Button6; private JTextField[] ParamField; private int CurrentVariable; private JTextArea resultText, sc; private JScrollPane sp; private desktop a; private String Server=" "; //private String Server="http://osprey4.npac.syr.edu:8001/MSU/calculator/"; //private String Server="http://maine.npac.syr.edu:8001/GEM/"; //private AppletContext ac; String nextLine; String resultFile = "result.txt"; private boolean debug = true; public AdcircFrame1(desktop a) { super("Adcirc", true, true, true, true); this.a = a; // ac = a.getAppletContext(); /* menu bar ActionListener mListener = new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }; if(debug) System.out.println("menu bar"); MenuBar menubar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem exitItem = new MenuItem("close this window"); exitItem.addActionListener(mListener); menuFile.add(exitItem); menubar.add(menuFile); setMenuBar(menubar); */ if(debug) System.out.println("build GUI"); getContentPane().setLayout(new BorderLayout()); JPanel left=new JPanel(); //input parameters JPanel right=new JPanel(); //results getContentPane().add(left,BorderLayout.WEST); getContentPane().add(right,BorderLayout.CENTER); if(debug) System.out.println("input parameters (left panel)"); JPanel up=new JPanel(); // label (logo) JPanel centerPanel = new JPanel(); // input params and scenarios // Panel middle=new Panel(); // input params JPanel scenarios = new JPanel(); // scenarios JPanel bottom=new JPanel(); // action buttons left.setLayout(new BorderLayout()); left.add(bottom,BorderLayout.SOUTH); left.add(centerPanel,BorderLayout.CENTER); left.add(up,BorderLayout.NORTH); centerPanel.setLayout(new BorderLayout()); //centerPanel.add(middle,BorderLayout.CENTER); centerPanel.add(scenarios,BorderLayout.SOUTH); if(debug) System.out.println("MSU logo"); JLabel LogoLabel = new JLabel("ADCIRC",JLabel.CENTER); LogoLabel.setFont(new Font("arun",Font.BOLD,30)); up.add(LogoLabel); if(debug) System.out.println("input params"); if(debug) System.out.println("action buttons"); Button1 = new JButton ("HELP"); bottom.add(Button1); Button2 = new JButton ("RESET"); bottom.add(Button2); Button3 = new JButton ("run ls"); bottom.add(Button3); Button4 = new JButton ("Run Adcirc"); bottom.add(Button4); bottom.setLayout(new GridLayout(3,2,10,0)); if(debug) System.out.println("button action Events"); Button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String helpfile="help.txt"; printHelpFile(helpfile); } }); Button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // reset } }); Button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // run ls runIt("/usr/bin/ls"); } }); Button4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // run Adcirc runIt("/home/haupt/runIt.pl"); } }); if(debug) System.out.println("do scroll pane"); /* results (right panel) */ // text area with Scrollbar /* replaced by swing Panel upright=new Panel(new FlowLayout()); right.setLayout(new BorderLayout()); right.add(upright,BorderLayout.CENTER); resultText = new TextArea(); resultText.setFont(new Font("Courier", Font.PLAIN, 12)); right.add(resultText); } */ right.setLayout(new BorderLayout()); resultText = new JTextArea(); resultText.setFont(new Font("Courier", Font.PLAIN, 12)); sp = new JScrollPane(resultText); right.add(sp,BorderLayout.CENTER); } public void printHelpFile(String helpfile) { } public void runIt(String command) { runJob rj = new runJob(command, resultText, sp, debug); Thread rjThread = new Thread(rj); rjThread.start(); } public void ShowData(String page) { /* try { URL pageurl = new URL(Server+page); ac.showDocument(pageurl,"results"); } catch (Exception e) {if(debug) System.out.println(e);} */ } public synchronized void waitFor(long howLong){ try { wait(howLong); } catch (Exception e) { System.out.println(e);} } }