I create a jPanel and I open a new jDialog when I click on button (dlgSegments is a JDialog that opened):
JButton btnAddSegment = new JButton("Add GeoSegment");
btnAddSegment.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dlgSegments.setVisible(true);
}
});
Then in the opened jDialog I want to return the “selected” back to the jPanel which called this jDialog.
How can I implement it?
This is the button listener in the opened jDialog and seleced is the variable that I want to pass to the jPanel:
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
GeoSegment selected = lstSegments.getSelectedValue();
// i want to send back the selected value
}
});
One possible solution: If you create your Dialog send an DataObject to the Dialog via his constructor. The DataObject conatins the value you are interested in.
fill the DataObject with the selected value in the dialog.