Я не понимаю, почему я получаю ошибку времени выполнения, когда пытаюсь выполнить .setText() объекту JTextArea в моей программе. В моем главном классе GUI я настроил событие, которое создает всплывающий объект JFrame, у этого JFrame есть кнопка, в которую также установлен JTextArea.setText(); к JTextArea в моем основном GUI-классе под названием MainOut.Ошибка Java setText()
public class GUI extends JFrame implements ActionListener {
JTextArea MainOut = new JTextArea(20,50);
public void actionPerformed(ActionEvent e) {
if (e.getSource() == ExitVar){
System.exit(0);
}
else if (e.getSource() == ServerLoginVar) { //This is my event that creates a
//new JFrame popup
new ServerLoginGUI(this);
}
//-------------------------------------------------------------------
public class ServerLoginGUI extends JFrame implements ActionListener {
JTextField ServerIP = new JTextField(15);
JPasswordField ServerPassword = new JPasswordField(15);
JPanel ServerLoginPanel = new JPanel();
JButton LoginButton = new JButton("Login");
JTextArea Area;
JLabel ServerIPLabel = new JLabel("Server Address:");
JLabel ServerPasswordLabel = new JLabel("Password :");
GUI GUi;
public void actionPerformed(ActionEvent e) {
if (e.getSource() == LoginButton){
if (ServerIP.getText().isEmpty() || ServerPassword.getText().isEmpty()){
} //do nothing
else {
new ServerAccess(this);
// this is the .setText() that will generate a error
GUi.SiteNameField.setText("Test from the ServerLogin event!");
dispose();}
}
}
}
Вы уверены, что получаете ошибки времени выполнения? похоже, у вас больше ошибок во время компиляции, а? – Juvanis
Какое исключение выбрано? – aleroot
И ошибка ...? –