Skip to main content

Jpanel and GridLayout



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

Popular posts from this blog

How to create your Java Executable...

What is a package? A package is a collection of related classes... (physically in your hard-disk is a directory/folder) all files under the package will be compressed together in a jar file...(a java archive like zip) Your java application may contain one or more packages to logically group functionality. When you deploy your application you create one jar file per project . In this jar file you must specify which is the java class file that contains the main class (the starter class) of your project. Follow the instructions on the screen-cam to create your java "executable".

Java Objects - Basics!!!!

How to create and "use" an object in Java  In the following tutorial, I will explain how to create an Object in JAVA, and how you can "use" this object from a "tester" program... The object described is a cashRegistrer System in a Supermarket. Multiple instances of cashRegisters exist, each one of them has its own balance (money inside the machine).  This is an instance variable. The only operation the machines perform is to put money inside (and increase the balance). This operation is called payAmount and needs two inputs :         1) the amount of money the customer needs to pay, for example: 5.75 (amountPayable)         2) the amount of money that the customer gives to the cashier, for example: 10  (amountGiven) the same operation returns a value, which is the change that the cashier should give to the customer. if the amount of money the customer gives to the cashier  (amountGiven)  is less than ...

GUI Components

This presentation describes JAVA swing GUI components and Layout Managers Powerpoint presentation in movie mode....