Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JScrollPane;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import javax.swing.JWindow;
- import java.awt.FlowLayout;
- import java.awt.Insets;
- import java.awt.Dimension;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class Code2 implements ActionListener {
- JLabel jLabInstruction, jLaberror, copyright;
- JLabel curStatus = new JLabel("");
- JFrame frame = new JFrame();
- JTextField uI;
- Object fileExists;
- boolean file;
- JTextArea textArea;
- JButton jbtnSubmit;
- Object results;
- String[] diagResults;
- boolean check;
- JScrollPane areaScrollPane;
- String btnResponseText;
- // Set up the GUI end for the user
- public void startGUI() {
- // These are all essential GUI pieces
- copyright = new JLabel("");
- uI = new JTextField("");
- uI = new JTextField(25);
- new JTextArea("");
- final JFrame jfrm = new JFrame(
- "program");
- jfrm.setLayout(new FlowLayout());
- jfrm.setSize(300, 300);
- jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- textArea = new JTextArea(5, 20);
- textArea.setEditable(false);
- textArea.setLineWrap(true);
- textArea.setWrapStyleWord(true);
- textArea.setCaretPosition(textArea.getDocument().getLength());
- jLabInstruction = new JLabel("SYSTEM: Please type in a command: ");
- jbtnSubmit = new JButton("Submit");
- jLaberror = new JLabel("");
- textArea.setMargin(new Insets(10, 10, 10, 10));
- areaScrollPane = new JScrollPane(textArea);
- areaScrollPane
- .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- areaScrollPane.setPreferredSize(new Dimension(250, 150));
- jfrm.add(jLaberror);
- jfrm.add(curStatus);
- jfrm.add(areaScrollPane);
- jfrm.add(jLabInstruction);
- jfrm.add(uI);
- jfrm.add(jbtnSubmit);
- jfrm.add(copyright);
- jfrm.setVisible(true);
- }
- public void actionPerformed(ActionEvent e) {
- btnResponseText = "hi there!";
- Toolkit.getDefaultToolkit().beep();
- // Get the text
- btnResponseText = getuIText();
- }
- // Writes to the text area
- public void writeToTextArea(char annotation, String userInputText) {
- if (annotation == 's') {
- textArea.append("\nSYSTEM: " + userInputText);
- } else if (annotation == 'n') {
- textArea.append(userInputText.toUpperCase());
- } else {
- {
- textArea.append("\nUSER: " + userInputText.toUpperCase());
- }
- }
- }
- public String btnClick() {
- //where initialization occurs:
- jbtnSubmit.addActionListener(this);
- return btnResponseText;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement