java button 问题
时间:2014-04-01
来源:互联网
我试左加E句
panel.add(square[1][1]);
但系就出左error了
希望ching们帮帮手

import java.awt.*;
public class ChessBoard{
private JFrame a;
private JPanel panel;
private ImageIcon i;
private ChessSquare[][] square = new ChessSquare[8][8];
public ChessBoard(){
a = new JFrame(); // Create a blank window
panel = new JPanel(); // Create a panel
square[1][1] = new ChessSquare();
panel.add(square[1][1]);
a.setContentPane(panel); // Use panel on Window
GridLayout layout = new GridLayout(8, 8,1,1);
panel.setLayout(layout);
a.setTitle("Wizard Chess"); // Change window title
a.setSize(300,300); // Change window size
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
a.setVisible(true); // Make it visible
}
}
import java.awt.*;
public class ChessSquare
{
private JButton b;
public ChessSquare() {
b = new JButton("i am button");
}
public JButton getB(){
return b;
}
}
panel.add(square[1][1]);
^
method Container.add(Component,Object,int) is not applicable
(actual and formal argument lists differ in length)
method Container.add(Component,Object) is not applicable
(actual and formal argument lists differ in length)
method Container.add(Component,int) is not applicable
(actual and formal argument lists differ in length)
method Container.add(String,Component) is not applicable
(actual and formal argument lists differ in length)
method Container.add(Component) is not applicable
(actual argument ChessSquare cannot be converted to Component by method in
vocation conversion)
method Component.add(PopupMenu) is not applicable
(actual argument ChessSquare cannot be converted to PopupMenu by method in
vocation conversion)
1 error
作者: peteraobo 发布时间: 2014-04-01

作者: Susan﹏汪汪 发布时间: 2014-04-01
汪汪唔识java


身边冇咩人识java

作者: peteraobo 发布时间: 2014-04-01
作者: Susan﹏汪汪 发布时间: 2014-04-01
ChessSquare系你的自定义class....JPanel当然不能add(ChessSquare)
作者: peteraobo 发布时间: 2014-04-01
咁...我要系ChessSquare入面先add个button,之后再系Chessboard到引入番?
汪汪唔识Java
作者: Susan﹏汪汪 发布时间: 2014-04-01
作者: peteraobo 发布时间: 2014-04-01
继续等吧(泣)
{
public ChessSquare() {
super("i am button");
}
}
作者: assembly.jc 发布时间: 2014-04-01
你成个ChessSquare要重写,可以依#8咁改改佢
作者: sinson123 发布时间: 2014-04-01
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28