I have 14 JFrame
classes and one JFrame
class holding a JTable
which acts as a calendar. I want the date of a text field or any other component in any of the 14 JFrame
classes to be changed when the user selects the date from the JTable
calendar . Now, the frames appear one at a time and the jtable is instantiated from a JButton
on any of the 14 JFrame classes.
My dilemma is how to identify the JFrame
class that has instantiated the JFrame
that contains the JTable
so that it's text field value can be changed.
Code that instantiates the JFrame containing the table:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JFrame frmMain = new Calender();
frmMain.setVisible(true);
frmMain.setSize(367, 342);
}
Code that changes the value of the textfield from one of the 14 JFrame
classes :
@Override
public void mouseClicked(MouseEvent me) {
if (me.getClickCount()==2){
int selected1 = jTable1.getSelectionModel().getLeadSelectionIndex();
int selected2 =jTable1.getColumnModel().getSelectionModel().getLeadSelectionIndex();
Object c = jTable1.getModel().getValueAt(selected1, selected2);
SowInformation.jTextField4.setText(c.toString());
this.setVisible(false);
}
}
Where SowInformation
is one of the 14 JFrame
classes.