Okay so I am currently learning java, so my knowledge is limited. I have read through allot of threads but have not found exactly what I need.
package glasshelloworldredux; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class GlassHelloWorldRedux extends JFrame { private JFrame window; private JLabel message; private JButton button; private JPanel panel; private final int WINDOWWIDTH = 300, WINDOWHEIGHT = 150; public GlassHelloWorldRedux() { super("Glass Hello World Redux!"); setSize(WINDOWWIDTH, WINDOWHEIGHT); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); buildPanel(); add(panel); setVisible(true); } private void buildPanel() { message = new JLabel("Hello World!"); button = new JButton("Close"); panel = new JPanel(); panel.add(message); panel.add(button); button.addActionListener(new ButtonListener() ); } private class ButtonListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } } }
Here is my code excluding the main class, witch simply just calls this class. So I can get the frame to close by setting the visibility to false, but the program is still running. I cant seem to figure out what to do next to get the program to end when setVisible(false) is active. And help would be great full, and thank you all for your time.