import javax.swing.*; 
import java.awt.*; 
import java.util.*; 
import java.text.*; 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class test extends JFrame implements Runnable{
int main_x=15;
int main_y=12;
int toppanel_height=40;
int height=main_y*20+toppanel_height+68;
int width=main_x*20+15;
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
public void run(){
try{
test frame=new test();
frame.setVisible(true);
new Thread(frame).start();
}catch(Exception e){
e.printStackTrace();
}
}
});
}
public test(){
super();
setBounds(0,0,width,height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
DPanel mainpanel=new DPanel();
getContentPane().add(mainpanel,BorderLayout.CENTER); }
class DPanel extends JPanel{
public void paint(Graphics g){
super.paint(g);
setLayout(null);
Graphics2D g2=(Graphics2D)g;
setBorder(BorderFactory.createLoweredBevelBorder());
g2.setColor(Color.GRAY);
g2.setStroke(new BasicStroke(1.5f));
final JButton btn[][]=new JButton[100][100];
for(int xx=0;xx<main_x;xx++){
for(int yy=0;yy<main_y;yy++){
btn[xx][yy]=new JButton();
btn[xx][yy].setBounds(xx*20+5,yy*20+5,20,20);
add(btn[xx][yy]);
btn[xx][yy].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
remove((JButton)e.getSource());
}
});
g2.drawLine(xx*20+5,5,xx*20+5,width-10);
g2.drawLine(5,yy*20+5,height-10,yy*20+5);
}
}
}
}
public void run(){
}
}