I have two frames and I want to click the button in frame2 and disable the button in frame1. Is this possible? The program begins its execution from frame1 and opens frame2. It's from this frame2 where I want to disable that button in frame1 But it does NOT work.....How can it be done?
additional information: I have a similar problems like this when I work with panels as well. I just don't get it. Plz help!
Here is the coding for frame1 where the program begins execution:
public class Frame1 extends javax.swing.JFrame {
Frame2 frm2 = new Frame2();
public Frame1() {
initComponents();
}
public void buttonDisable(){
Btn1.setEnabled(false);
}
private void Btn1ActionPerformed(java.awt.event.ActionEvent evt) {
frm2.setVisible(true);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new Frame1().setVisible(true);
}
});
}
public javax.swing.JButton Btn1;
}
Here is the coding for frame2 where I want to disable that button from:
public class Frame2 extends javax.swing.JFrame {
public Frame2() {
initComponents();
}
private void Btn2ActionPerformed(java.awt.event.ActionEvent evt) {
Frame1 frm1 = new Frame1();
frm1.buttonDisable();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new Frame2().setVisible(true);
}
});
}
public javax.swing.JButton Btn2;
}