Hey everybody,
I don't really have a whats wrong with my code as much as a how would i do such a thing.
So i have a JTextArea that asks whats your name, and then a bunch of other questions. Then i have a textfield and button for input to the JTextArea since i was very unsure of how to do something like System.in/out in eclipse.
But i can't just put like an integer to keep track of what question its on.
Im trying to figure out a way to make my JTextArea wait for me to hit the enter button and then accept the input into a string.
Heres the code, their was more but i found this pretty tight snag so i decided to start over. Basically this will just let you see my GUI
import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; public class General extends JFrame{ JPanel Outside; JPanel info1, info2; JButton[][] Buttons = new JButton[30][30]; JTextField Input; JButton Enter; static JTextArea Output; General() throws FileNotFoundException{ setLayout(null); setBounds(0, 0, 1498, 800); Outside = new JPanel(new GridLayout(30, 30)); Outside.setBounds(10,10,700,700); for(int a = 0; a < 30; a++){ for(int b = 0; b < 30; b++){ Buttons[a][b] = new JButton(); Buttons[a][b].setBorder(BorderFactory.createLineBorder(Color.BLACK)); Buttons[a][b].setBackground(Color.WHITE); Outside.add(Buttons[a][b]); } } Input = new JTextField(); Input.setBounds(10, 720, 602, 25); Enter = new JButton("ENTER"); Enter.setBounds(612, 720, 90, 25); Enter.addActionListener(new InputListener()); Output = new JTextArea(); Output.setBounds(730,10,300,735); Output.setBorder(BorderFactory.createLineBorder(Color.BLACK,3)); info1 = new JPanel(); info1.setLayout(null); info1.setBounds(1050, 10, 200, 735); info1.setBorder(BorderFactory.createLineBorder(Color.BLACK)); info2 = new JPanel(); info2.setLayout(null); info2.setBounds(1270, 10, 200, 735); info2.setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(info1); add(info2); add(Output); add(Enter); add(Input); add(Outside); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws FileNotFoundException { new General(); } public class InputListener implements ActionListener{ public void actionPerformed(ActionEvent e) { } } }