Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

GridLayout

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
/*ww  w  . j a v  a2 s  .co m*/
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main {
  public static void main(String[] args) {
    JFrame frame = new JFrame("GridLayout");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(3, 0));

    for (int i = 1; i <= 9; i++) {
      buttonPanel.add(new JButton("Button  " + i));
    }

    contentPane.add(buttonPanel, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
  }
}
Comment

GridLayout

GridLayout()
GridLayout(int rows,   int cols)
GridLayout(int rows,   int cols, int hgap,   int  vgap)
Comment

PREVIOUS NEXT
Code Example
Java :: java design patterns 
Java :: java append to array 
Java :: stringbuilder example in java 
Java :: Declaring a Java Method 
Java :: class property java 
Java :: loop and save letters in a string java 
Java :: declaring java variables 
Java :: android activity transition 
Java :: configure JWT on Springboot 
Java :: array methods in java 
Java :: java spring mvc 
Java :: how to encrypt password in properties file in spring boot 
Java :: abstract class java 
Java :: pass data to layout from navigation android studio 
Java :: how does plus works in Java 
Java :: l datetime anne month jour heure minute second in java 
Java :: preset arraylist java 
Java :: java and python begineers mcq with answers 
Java :: java method overloading 
Java :: view binding 
Java :: input method manager hide keyboard 
Java :: split email on dot java 
Java :: null check in line java 
Java :: Person[] people = in java 
Java :: java thyemleaf save table form to database 
Java :: difference between compile and execute in java 
Java :: java plugin spigot messsage console 
Java :: poo pledin 3.0 
Java :: FirebaseCrashlyticsPlugin.java uses or overrides a deprecated API. 
Java :: ["org.elasticsearch.bootstrap.startupexception: java.lang.illegalstateexception: failed to obtain node locks, 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =