java帮我看看哪错了,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/07 10:58:23
public class LayoutTest extends JFrame
{
private static final int WINDTH =300;
private static final int HEIGHT= 300;
private JPanel p1;
private PanelTest p2;
private JLabel label;

public LayoutTest()
{
setSize(WINGTH,HEIGHT);
setVisibel(true);
setDefaultCloseOpation(JFrame.EXIT_ON_CLOSE);
P1 = new JPanel();
p2 = new PanelTest();
label = new JLabel();
p1.add(label);
add(p1,BorderLayout.NORTH);
add(p2,BorderLayout.CENTRE);
}

class PanelTest extends JPanel
{
public PanelTest()
{
JButton[] button = new JButton[9];
ActionListener ac = new Actionhander();
setLayout(new GridLayout(3,3));
for(int i = 0;i<9;i++)
{
String a = String.valueOf(i+1);
button[i] = new JButton(a);
add(button[i]);
button[i].ActionList

你问了几次啊?
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class T extends JFrame {
private static final int WINDTH = 300;
private static final int HEIGHT = 300;
private JPanel p1;
private PanelTest p2;
private JLabel label;

public T() {
setSize(WINDTH, HEIGHT);
setVisible(true);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p1 = new JPanel();
p2 = new PanelTest();
label = new JLabel();
p1.add(label);
add(p1, BorderLayout.NORTH);
add(p2, BorderLayout.CENTER);
}

class PanelTest extends JPanel {
public PanelTest() {
JButton[] button = new JButton[9];
A