// the Views: determine ordering of button and label with boolean import javax.swing.*; import java.awt.*; import java.awt.event.*; // setting up the layout of the View abstract class Layout { JFrame frame = new JFrame("MyFirstSwingApplication"); JPanel pane = new JPanel(); JButton but = new JButton("Click me"); JLabel lab = new JLabel("xyz"); Layout() { pane.setLayout(new GridLayout(2,1)); frame.getContentPane().add(pane); pane.add(but); pane.add(lab); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.pack(); frame.setVisible(true); } }