This might not be exactly correct answer but this will do the job.
Suppose you have 2 Jframes namely Home.java and Second.java
the code for Second.java as below,
public static String selection = "";//static variable to store seletced value from combobox
Home h = new Home();//instance of Home Jframe
/**
* return selected value (called from Home Jframe)
*/
public static String getSeletced() {
return selection;
}
/**
* get selected value from comboBox event
*/
private void cmbLapActionPerformed(java.awt.event.ActionEvent evt) {
selection = cmbLap.getSelectedItem().toString();
h.isSelected = true;//this is to control data duplication
}
Now for the Home.java file we can use formWindowGainedFocus
event to update the jTextArea
. Home .java file contains following code,
public static boolean isSelected = false;//flag to check combo box is selected
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
System.out.println(isSelected);
if (isSelected) {
String text = new Second().getSeletced();
System.out.println(text);
txaData.append("Your Laptop: " + text + "\n");//appending data
isSelected = false;//to prevent duplication
}
}
This method can use to update jTextArea using data from another jFrame.