This is my main class code:
public static void main(String[] args) {
JFrame f= new JFrame ("My Frame");
f.setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE);
JTabbedPane tp = new JTabbedPane();
tp.addTab("Pane1", new PaneFirst());
tp.addTab("Pane2", new PaneSecond());
f.add(tp);
f.pack();
f.setVisible(true);
}
In PaneFirst, I have a list of user-entered-value(textfields), lets say I have 5. And I store each of the value into an array(or maybe arraylist). How do I pass those 5 values from PaneFirst to PaneSecond?
(Sorry, I am new to Java and Object Oriented Programming language)
You really shouldn’t store the values on the pane object (“view”) but create a separate class that holds the values (“model”).
Then you can pass the reference to the model to both panes and if one pane changes values on model class, the other one will see the changes too. The follwing simple example is to show the idea in code. Your Model will look different but it should give an idea on how to implement, create and use it.