I'm building a simple Swing chat interface (I did it on JavaFX and it was quite easy) but something is going wrong and I don't understand why. Can anyone help?
From main class, I create a new ChatUI, like this:
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
chatFrame = new ChatUI();
UIHelper.chatFrameInit();
}
});
}
From the UIHelper class, I can easily set up my frame, like this:
public class UIHelper {
public static void chatFrameInit() {
chatFrame.setTitle("Your Chat");
chatFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
chatFrame.setVisible(true);
}
}
In order to append a text string to the textArea, i've created a public method into the ChatUI class:
public ChatUI() {
initComponents();
}
public void addChat(String t) {
jTextArea1.append(t);
}
...
// Variables declaration - do not modify
private javax.swing.JScrollPane jScrollPane2;
public javax.swing.JTextArea jTextArea1;
// End of variables declaration
}
The problem is that, if I try to refer to this method (and any other public methods and fields into the ChatUI class), I receive a "Cannot find symbol" error.