Untitled
unknown
plain_text
4 years ago
566 B
7
Indexable
package midterm2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class midterm2task1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame frame = new JFrame();
frame.setSize(300, 200);
GridLayout grid = new GridLayout(3, 4);
frame.setLayout(grid);
JButton b1 = new JButton("1");
for(int i = 1; i<=12; i++) {
JButton b = new JButton(""+i);
int a = Integer.parseInt(b1.getLabel());
a++;
b.setLabel(""+a);
frame.add(b);
}
frame.setVisible(true);
}
}
Editor is loading...