Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TryGridLayout {
static JFrame aWindow = new JFrame("This is a Grid Layout");
public static void main(String[] args) {
aWindow.setBounds(100,100,1024,768);
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(3,4);
Container content = aWindow.getContentPane();
content.setLayout(grid);
JButton button = null;
for(int i = 1; i <= 10; i++) {
content.add(button = new JButton("Press "+ i));
}
aWindow.setVisible(true);
}
}
program code extracted from ivor hortons java 5
1.can action listeners be added to the buttons in this program???
2.why is JFrame static ???
3.usually in college we write like "public classname extends JFrame", but it is not used in this program code , what diff does this make ???
i couldnt find suitable answers in complete reference java 2 ,, so askin here!!!!