How to close the program in Java completely in Swing

A Java Swing application can be closed using the following code segment to retrieve the parent of the container, check if it is a JFrame and then dispose the JFrame:

public class btnCancelListener implements ActionListener { public void actionPerformed(ActionEvent ev) { Container bframe = btnCancel.getParent(); bframe = bframe.getParent(); while (! (bframe instanceof JFrame)) { System.out.println(“Done”); . . . → Read More: How to close the program in Java completely in Swing

How to restrict size of JButton in GridLayout in Java

If you put the following code in Java with only the lines in blue in your Java Swing program, you will find that whenever the Java dialog is resized, the button grows and looks ugly as it occupies the full row of the GridLayout. Code Segment as below.

parameterPanel.setLayout(new GridLayout(2,1)); JButton parameterButton = new JButton(“Parameters”); . . . → Read More: How to restrict size of JButton in GridLayout in Java

June 2019
M T W T F S S
« Feb    
 12
3456789
10111213141516
17181920212223
24252627282930