Java_Grid_and_Buttons
Java_Grid_and_Buttons
Question: Write Java program to demonstrate Grid of 5*5 (Advanced Java Program)
Answer:
import javax.swing.*;
import java.awt.*;
// Create a JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
// Set layout for the frame as GridLayout with 5 rows and 5 columns
frame.add(button);
frame.setVisible(true);
Answer:
import javax.swing.*;
import java.awt.*;
// Create a JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 300);
// Set layout for the frame as GridLayout with 2 rows and 5 columns
frame.add(button);
frame.setVisible(true);