import java.awt.Color;import java.awt.Container;import java.awt.GridLayout;import javax.swing.*;public class gridlayout extends JFrame { gridlayout(){ setTitle("GridLayout"); setBounds(0, 0, 350, 300);setVisible(true);Container contentpane = getContentPane();contentpane.setLayout(new GridLayout());prueba panel1 = new prueba();contentpane.add(panel1); } public static void main(String[]args){ gridlayout laventana = new gridlayout(); }}
import java.awt.GridLayout;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JPanel;public class prueba extends JPanel { prueba(){ setLayout(new GridLayout(5,4)); add(new JButton("CLs")); add(new JButton("Bck")); add(new JLabel("")); add(new JButton("Close")); add(new JButton("7")); add(new JButton("8")); add(new JButton("9")); add(new JButton("/")); add(new JButton("4")); add(new JButton("5")); add(new JButton("6")); add(new JButton("*")); add(new JButton("1")); add(new JButton("2")); add(new JButton("3")); add(new JButton("-")); add(new JButton("0")); add(new JButton(".")); add(new JButton("=")); add(new JButton("+")); } }