Advertisement
zoro-10

DemoGridLayout.java

Mar 30th, 2024
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3.  
  4. public class DemoGridLayout {
  5.  
  6.   public static void main(String args[]) {
  7.     JFrame frame = new JFrame("Grid Layout");
  8.     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  9.     frame.setSize(300, 200);
  10.     JPanel panel = new JPanel(new GridLayout(2, 3));
  11.     JButton button1 = new JButton("Button1");
  12.     JButton button2 = new JButton("Button2");
  13.     JButton button3 = new JButton("Button3");
  14.     JButton button4 = new JButton("Button4");
  15.     JButton button5 = new JButton("Button5");
  16.     JButton button6 = new JButton("Button6");
  17.     panel.add(button1);
  18.     panel.add(button2);
  19.     panel.add(button3);
  20.     panel.add(button4);
  21.     panel.add(button5);
  22.     panel.add(button6);
  23.     frame.add(panel);
  24.     frame.setVisible(true);
  25.   }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement