Send a text into another JFrame
Hello guys plss ... help im getting error here
i have a 2 java file name JFrameA and JFrameB
now JFrameA has a textarea and jbutton then heres what iwant to do
if i write a text from textarea of JFrameA then click the button i want to send it
on the textArea of JFrameB and thesame with JFrameB i want to send the text from textarea of JFrameB to the textArea of JFrameA.
see my codes
//this is JFrameA.java
Code:
public class JFrameA extends javax.swing.JFrame {
/** Creates new form NewJFrame */
public JFrameA(){
initComponents();
}
JFrameA(String text) {
jTextArea1.setText(text);
}
@SuppressWarnings("unchecked")
//Generated Code
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new JFrameB(""+jTextArea1.getText());
}
//this is JFrameB.java
Code:
public class JFrameB extends javax.swing.JFrame {
public JFrameB() {
initComponents();
}
JFrameB(String strtext) {
jTextArea1.setText(""+strtext);
}
@SuppressWarnings("unchecked")
//Generated Code
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new JFrameA(""+jTextArea1.getText()); // TODO add your handling code here:
}
then this is my error message
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at codingerror.JFrameB.<init>(JFrameB.java:25)
at codingerror.JFrameA.jButton1ActionPerformed(JFrame A.java:73)
at codingerror.JFrameA.access$000(JFrameA.java:18)
at codingerror.JFrameA$1.actionPerformed(JFrameA.java :40)
thanks