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 status; private int CurrentVariable; private JTextArea resultText, sc; private JProgressBar progress; private JScrollPane sp; private desktop a; private String Server=" "; String nextLine; String resultFile = "result.txt"; private boolean debug = true; private static boolean ExecutionCompleted; private Thread exeA; public AdcircFrame1(desktop a) { super("Adcirc", true, true, true, true); this.a = a; ExecutionCompleted=false; /* 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 JPanel south=new JPanel(); //progress bar; getContentPane().add(left,BorderLayout.WEST); getContentPane().add(right,BorderLayout.CENTER); getContentPane().add(south,BorderLayout.SOUTH); 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(up,BorderLayout.NORTH); left.add(centerPanel,BorderLayout.CENTER); left.add(bottom,BorderLayout.SOUTH); centerPanel.setLayout(new BorderLayout()); //centerPanel.add(middle,BorderLayout.CENTER); centerPanel.add(scenarios,BorderLayout.SOUTH); if(debug) System.out.println("MSU logo"); up.setLayout(new BorderLayout()); JLabel LogoLabel = new JLabel("ADCIRC",JLabel.CENTER); LogoLabel.setFont(new Font("arun",Font.BOLD,30)); up.add(LogoLabel,BorderLayout.CENTER); status=new JTextField("welcome!",20); up.add(status,BorderLayout.SOUTH); if(debug) System.out.println("input params"); bottom.setLayout(new GridLayout(3,2,5,0)); 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); 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); /* progress = new JProgressBar(0,100); progress.setPreferredSize(new Dimension(400,20)); south.add(progress); */ } public void printHelpFile(String helpfile) { status.setText("sorry, not available"); } public void runIt(String command) { ExeAdcirc ea = new ExeAdcirc(status,resultText,sp,command,debug); exeA = new Thread(ea); exeA.start(); } public void ShowData(String page) { status.setText("sorry, not available"); /* 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);} } public static void setExecutionCompleted() { ExecutionCompleted=true; } public static boolean getExecutionCompleted() { return ExecutionCompleted; } }