1
我正在使用netbeans编译器版本7.11。 我正在尝试创建一个GridLayout,但它在显示错误 的地方写了代码来为Layout创建按钮。无法在使用java netbeans编译器的网格布局中创建按钮
它给下面errors
no suitable constructor found for JButton(Java.lang.String.java.lang.String)
Constructor javax.swing.JButton.JButton(java.lang.String,javax.swing.Icon)is not applicable
(actual argument Java.lang.String cannot be converted to javax.swing.Icon by method
invocation conversion)
Constructor javax.swing.JButton.JButton(javax.swing.Action)is not applicable
(actual and formal argument lists differ in length)
Constructor javax.swing.JButton.JButton(java.lang.String)is not applicable
(actual and formal argument lists differ in length)
Constructor javax.swing.JButton.JButton(javax.swing.Icon)is not applicable
(actual and formal argument lists differ in length)
Constructor javax.swing.JButton.JButton()is not applicable
(actual and formal argument lists differ in length)
它显示7行到第11行这些错误下面是我进入到Java编译器的Netbeans的代码。
import java.awt.*;
import javax.swing.*;
public class Griddemo extends JFrame{
public Griddemo()
{
setLayout(new GridLayout(3,2));
add(new JButton("Row-1","Col-1")); ---- line7
add(new JButton("Row-1","Col-2")); ---- line8
add(new JButton("Row-2","Col-1")); ---- line9
add(new JButton("Row-2","Col-2")); ---- line10
add(new JButton("Row-3","Col-1")); ---- line11
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String args[])
{
new Griddemo();
}
}
+1,正是我想到的,但更快地回答方:-) – 2012-07-29 07:17:44
非常感谢它的工作:D – user1560596 2012-07-29 07:25:40
@ user1560596如果您对答案满意,您可以考虑通过接受他的答案来认可akf的努力回答 – MadProgrammer 2012-07-29 08:09:28