Basically, I have somewhere in my main code where this line of code is called
editwindow clubeditwindow = new editwindow(1,"Club Edit");
This line opens a new JFrame that can basically edit a bunch of information from the main class. I have 2 buttons called save and cancel. When save is clicked, I want to take the values from the textfields and then put it into a new object and return that to the main class, and close the window. When cancel is clicked, I want it to just not do anything, which is simple enough.
Thanks in advance.
Don’t display the window as a JFrame but rather display it as a modal dialog. Then after it is no longer visible, the main GUI can query the object for any information that it holds. The simplest way to do this is to use a JOptionPane — they are clever little beasts if used correctly.
Here’s an example of what I mean. The JOptionPane holds JPane that displays information using a GridBagLayout.
ComplexOptionPane.java: displays the main JFrame.
PlayerEditorPanel.java which holds the JPanel that is displayed in a JOptionPane