This the code (used at the screen-cam) to create at Run-Time the buttons inside your jPanel, which has a gridLayout of 6 columns and 14 Rows (as required by your project)
for (int Row=0;Row < seats.length;Row++)
for (int Column=0; Column < seats[Row].length; Column++) {
JButton b = new JButton();
b.setEnabled(false);
b.setBackground(Color.BLUE);
seats[Row][Column]=b;
jPanel1.add(b);
}
Make sure you place the code above in the correct position in your source code... inside
jbInit() method
make also sure that you have declared:
private JButton seats [][] = new JButton [14][6];
on top of your code inside :
public class _______ extends JFrame {
where all object declarations are...
Comments
Post a Comment