Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package test;
  2.  
  3. import java.awt.FlowLayout;
  4. import java.awt.GridLayout;
  5.  
  6. import javax.swing.JButton;
  7. import javax.swing.JFrame;
  8. class App {
  9.     public static void main(String[] args)
  10.     {
  11.     int num = 15;
  12.     GridLayout experimentLayout = new GridLayout(0, 3);
  13.  
  14.     JFrame f=new JFrame();//creating instance of JFrame  
  15.            
  16.     f.setSize(400,500);//400 width and 500 height  
  17.     f.setLayout(experimentLayout);
  18.  
  19.     for(int i=1; i<=num; i++) {
  20.     f.add(new JButton("Button "+i));
  21.     }
  22.    
  23.     f.setVisible(true);//making the frame visible  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement