Untitled
unknown
plain_text
a year ago
1.6 kB
4
Indexable
Never
package LabPgm5b; import java.awt.*; import javax.swing.*; public class Pgm5b { JFrame frameObj; // constructor Pgm5b() { frameObj = new JFrame(); JButton btn1 = new JButton("1"); JButton btn2 = new JButton("2"); JButton btn3 = new JButton("3"); JButton btn4 = new JButton("4"); JButton btn5 = new JButton("5"); JButton btn6 = new JButton("6"); JButton btn7 = new JButton("7"); JButton btn8 = new JButton("8"); JButton btn9 = new JButton("9"); JButton btn10 = new JButton("10"); JButton btn11 = new JButton("11"); JButton btn12 = new JButton("12"); JButton btn13 = new JButton("13"); JButton btn14 = new JButton("14"); JButton btn15 = new JButton("15"); // adding buttons to the frame // since, we are using the parameterless constructor, therfore; // the number of columns is equal to the number of buttons we // are adding to the frame. The row count remains one. frameObj.add(btn1); frameObj.add(btn2); frameObj.add(btn3); frameObj.add(btn4); frameObj.add(btn5); frameObj.add(btn6); frameObj.add(btn7); frameObj.add(btn8); frameObj.add(btn9); frameObj.add(btn10); frameObj.add(btn11); frameObj.add(btn12); frameObj.add(btn13); frameObj.add(btn14); frameObj.add(btn15); // setting the grid layout using the parameterless constructor frameObj.setLayout(new GridLayout(4,4)); frameObj.setSize(300, 300); frameObj.setVisible(true); } // main method public static void main(String args[]) { new Pgm5b(); } }