JPanel with setPreferredSize and Dimension

To set the preferred size for each JPanel object, you call its setPreferredSize() method. The argument is a Dimension object that specifies the width and height. Program       Program Source import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.BorderFactory; import java.awt.Dimension; import java.awt.FlowLayout; class Frame extends JFrame { Frame() { setTitle(“setPreferredSize”); setLayout(new FlowLayout()); setJPanelOne(); … Read more…

JPanel with BoxLayout

BoxLayout arranges components either in a row or in a column. The BoxLayout constructor requires two arguments. The first is a reference to the container to which the layout manager applies, and the second is a constant that can be either BoxLayout. X_AXIS for a row-wise arrangement or BoxLayout.Y_AXIS for a column-wise arrangement. Program   … Read more…