/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author STUDENT */ import java.awt.*; import java.awt.event.ActionEvent.*; import java.awt.event.ActionListener.*; import javax.swing.*; public class PanelDemo { public JFrame f; public JPanel p; public JLabel lblNum1,lblNum2,lblNum3; public PanelDemo(){ f= new JFrame("Grid Layout Demo"); p= new JPanel(); lblNum1= new JLabel("First Name"); lblNum2= new JLabel("Middle Name"); lblNum3= new JLabel("Last Name"); } public void launchFrame(){ p.setLayout(new GridLayout(3,1,5,5)); p.add(lblNum1); p.add(lblNum2); p.add(lblNum3); f.getContentPane().add(p); f.setSize(500,500); f.setDefaultCloseOperation(f.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); } /** * @param args the command line arguments */ public static void main(String[] args) { PanelDemo guiWindow2= new PanelDemo(); guiWindow2.launchFrame(); } }