View Single Post
Old Mar 10th, 2007, 9:29 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 928
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
No offense, but the multitude of fundamental problems with your code most likely indicates that your understanding of the Java language is insufficient to be working with GUIs. Instead of taking the time to write out an explanation for each problem, I rewrote the code for you to study.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class GUITest extends JFrame implements ActionListener {
    private static JButton[] bbox;
    
    public GUITest() {
        
        super("GUI Test");
        
        setLayout(new GridLayout(3,3));
        
        bbox = new JButton[9];
        
        for (int i = 0; i < bbox.length; i++) {
            bbox[i] = new JButton(Integer.toString(i));
            bbox[i].addActionListener(this);
            add(bbox[i]);
        }
        
        pack();
        
        setVisible(true);
        
    }

    public static void main(String args[]) {
        new GUITest();
    }

    public void actionPerformed(ActionEvent evt) {
        // This method is called when a button is clicked
    }
    
}

Last edited by titaniumdecoy; Mar 10th, 2007 at 9:48 PM.
titaniumdecoy is offline   Reply With Quote