Java Code:
import java.awt.GridLayout;
import javax.swing.*;
public class Screen
{
JButton start;
JButton reset;
JButton box[][] = new JButton[20][20];
Screen()
{
JFrame j = new JFrame();
j.setSize(700,500);
j.setLayout(new GridLayout(20,20));
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//create buttons
for(int row=0;row<20;row++)
{
for(int col=0;col<20;col++)
{
box[row][col] = new JButton();
j.add(box[row][col]);
}
}
//create start button
start = new JButton("Start");
j.add(start);
start.setLocation(0, 0);
//create reset button
reset = new JButton("Reset");
j.add(reset);
reset.setLocation(2, 0);
j.setVisible(true);
}
public static void main(String[] args)
{
new Screen();
}
}
I would like the borons to be placed on the bottom. I will be adding a scroll feature to it because this is going to be a program that shows the results of different path finding algorithms. Before I can even start that part I need to learn how to make the interface..
No comments:
Post a Comment