"can you provide code for this data Model?"
The second internal frame accepts a DataModel
object. The two will remain the same object when between the frames.
Note if you need something more complex (like back and forth interaction between the frames), you should look into some tutorial on Model View Controller architecture, where you will need to use PropertyChaneListeners
and such
public class DataModel {
private String data;
public DataModel() {
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
public class MyInternalFrame1 extends JInternalFrame {
private DataModel dataModel = new DataModel();
public DataModel getDataModel() {
return dataModel;
}
}
public class MyInternalFrame2 extends JInternalFrame {
private DataModel dataModel;
public MyInternaFrame1() {}
public MyIntenalFrame2(DataModel datModel) {
this.dataModel = dataModel;
}
public void setDataModel(DataModel dataModel) {
this.dataModel = dataModel;
}
}
In the Main GUI program, you can do something like this
public class GUI extends JFrame {
MyInternalFrame1 iFrame1 = new MyInternalFrame1();
....
// somewhere else in code
DataModel dataModel = iFrame1.getDataModel();
dataModel.setData("Hello");
new MyInternalFrame2(dataModel);
}