Does anyone know how to make a jbutton close a gui? I think it is like System.CLOSE(0); but that didnt work. it also could be exitActionPerformed(evt);
System.CLOSE(0);
exitActionPerformed(evt);
In Java 8, you can use Lambda expressions to make it simpler.
JButton btnClose = new JButton("Close"); btnClose.addActionListener(e -> System.exit(0));
JButton btnClose = new JButton("Close"); btnClose.addActionListener(e -> this.dispose());