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

January 2019
M T W T F S S
« Sep    
 123456
78910111213
14151617181920
21222324252627
28293031