I am working on a project for aircraft seating and what i have to do is create square on the screen as seat. I got to draw 180 squares on the screen and it sounds easy but i have been stuck at it for about 10 days now my superviser doesn't know java so he can't help me on what i should do next and java superviser's told me they have no time to see me so if anyone here can help to guide me where i am goin wrong or how i should do it would be very helpful. Here is the code i have so far i think i am maybe close to gettin it working but then again i could be far off.
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Seating extends JFrame {
private JPanel boardPanel;
private JPanel panel2;
private Square board[][];
public Seating() {
boardPanel = new JPanel();
boardPanel.setLayout(new GridLayout(6,30,0,0));
//create board
board = new Square[6][30];
//rows in the board
for(int row = 0; row < board.length; row++)
{
//column on the board
for(int column = 0; column < board[row].length; column++)
{
//create square
board[row][column] = new Square(' ', 3 * row + column);
//add square
boardPanel.add(board[row][column]);
}
}
panel2 = new JPanel();
panel2.add(boardPanel, BorderLayout.CENTER);
add(panel2, BorderLayout.CENTER);
setSize(2000,1500);
setVisible(true);
}
private class Square extends JPanel
{
public Dimension getPreferedSize()
{
return new Dimension(20,20);
}
public Dimension getMinimumSize()
{
return getPreferedSize();
}
public void paintComponent(Graphics g)
{
super.paintComponents(g);
g.drawRect(0, 0, 19, 19);
}
}
}