I want to create a grid of 6*6 then next step is to put image Tiles column by column in each grid.A complete image is composition of all tiles in each grid. Then i want to draw lines over complete image formed by 6*6 grid. I have tried with JLabel and created 6*6 grid of JLabels and image is formed completely but i was trying to draw line over image formed , i am unable to do that. Line is starting from end of the image on right side. I am strucked at this point.Please tell me to do it in someway.
so... you want a 6*6 image tile grid? You can do that with the JPanel paint method. If you are not using JPanel, then: this is your main class
public class Main{
public static void main(String[] args){
MyWindow window = new MyWindow();
}
}
this is your MyWindow class:
public class MyWindow extends JFrame{
public MyWindow(){
super.setVisible(true);
super.setSize(500,500);
MyPanel panel = new MyPanel();
super.setContentPane(panel);
}
}
this is your MyPanel class:
public class MyPanel extends JPanel{
public MyPanel(){
super.setSize(500,500);
super.setVisible(true);
}
@Override
public void paint(Graphics g){
for(int i = 0; i < 6; i++){
for(int j = 0; j < 6; j++){
g.drawImage(theImage,i*10,j*10,null);// the tens are your image's dimensions. If your image is 100x50 then it must be i*100 and j*50
}
}
}
}
If you ARE using JPanel, then just copy the paint method. This will draw your image 36(6*6) times, in the form of a grid. I hope this has helped.
NOTE: I haven't tested this, I just wrote it directly on the post. If you have an error of some kind, just reply to me.