Advertisement
droidus

Untitled

Jan 31st, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.61 KB | None | 0 0
  1. import javax.swing.JButton;
  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;
  4. import javax.swing.JOptionPane;
  5. import javax.swing.JScrollPane;
  6. import javax.swing.JTextArea;
  7. import javax.swing.JTextField;
  8. import javax.swing.JWindow;
  9. import java.awt.FlowLayout;
  10. import java.awt.Insets;
  11. import java.awt.Dimension;
  12. import java.awt.event.ActionListener;
  13. import java.awt.event.ActionEvent;
  14.  
  15. public class Code2 implements ActionListener {
  16.  
  17. JLabel jLabInstruction, jLaberror, copyright;
  18.     JLabel curStatus = new JLabel("");
  19.     JFrame frame = new JFrame();
  20.     JTextField uI;
  21.     Object fileExists;
  22.     boolean file;
  23.     JTextArea textArea;
  24.     JButton jbtnSubmit;
  25.     Object results;
  26.     String[] diagResults;
  27.     boolean check;
  28.     JScrollPane areaScrollPane;
  29.     String btnResponseText;
  30.    
  31.  
  32. // Set up the GUI end for the user
  33.     public void startGUI() {
  34.         // These are all essential GUI pieces
  35.         copyright = new JLabel("");
  36.         uI = new JTextField("");
  37.         uI = new JTextField(25);
  38.         new JTextArea("");
  39.  
  40.         final JFrame jfrm = new JFrame(
  41.                 "program");
  42.         jfrm.setLayout(new FlowLayout());
  43.         jfrm.setSize(300, 300);
  44.         jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  45.         textArea = new JTextArea(5, 20);
  46.         textArea.setEditable(false);
  47.         textArea.setLineWrap(true);
  48.         textArea.setWrapStyleWord(true);
  49.         textArea.setCaretPosition(textArea.getDocument().getLength());
  50.         jLabInstruction = new JLabel("SYSTEM: Please type in a command: ");
  51.         jbtnSubmit = new JButton("Submit");
  52.         jLaberror = new JLabel("");
  53.         textArea.setMargin(new Insets(10, 10, 10, 10));
  54.  
  55.         areaScrollPane = new JScrollPane(textArea);
  56.         areaScrollPane
  57.                 .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  58.         areaScrollPane.setPreferredSize(new Dimension(250, 150));
  59.  
  60.         jfrm.add(jLaberror);
  61.         jfrm.add(curStatus);
  62.         jfrm.add(areaScrollPane);
  63.         jfrm.add(jLabInstruction);
  64.         jfrm.add(uI);
  65.         jfrm.add(jbtnSubmit);
  66.         jfrm.add(copyright);
  67.         jfrm.setVisible(true);
  68.     }
  69.  
  70. public void actionPerformed(ActionEvent e) {
  71.         btnResponseText = "hi there!";
  72.         Toolkit.getDefaultToolkit().beep();
  73.         // Get the text
  74.         btnResponseText = getuIText();
  75.     }
  76.    
  77.     // Writes to the text area
  78.     public void writeToTextArea(char annotation, String userInputText) {
  79.         if (annotation == 's') {
  80.             textArea.append("\nSYSTEM: " + userInputText);
  81.         } else if (annotation == 'n') {
  82.             textArea.append(userInputText.toUpperCase());
  83.         } else {
  84.             {
  85.                 textArea.append("\nUSER: " + userInputText.toUpperCase());
  86.             }
  87.         }
  88.     }
  89.    
  90.     public String btnClick() {
  91.         //where initialization occurs:
  92.         jbtnSubmit.addActionListener(this);
  93.         return btnResponseText;
  94.     }
  95.    
  96.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement