java 关于文本框的问题
importjava.awt.*;publicclassTextFieldextendsFrame{TextFieldtext1;publicTextField(){se...
import java.awt.*;
public class TextField extends Frame{
TextField text1;
public TextField()
{
setLayout(new FlowLayout());
text1=new TextField(20);
text1.setText("Welcom to java !" );
setSize(200,180);
setLocation(100,50);
add(text1);
setVisible(true);
}
public static void main(String[] args)
{
TextField myText=new TextField();
}
}
新手,在自学,不明白怎么错了 展开
public class TextField extends Frame{
TextField text1;
public TextField()
{
setLayout(new FlowLayout());
text1=new TextField(20);
text1.setText("Welcom to java !" );
setSize(200,180);
setLocation(100,50);
add(text1);
setVisible(true);
}
public static void main(String[] args)
{
TextField myText=new TextField();
}
}
新手,在自学,不明白怎么错了 展开
1个回答
展开全部
修改, 类里面的变量text1类型和类重复了,必须指明package
import java.awt.*;
public class TextField extends Frame { java.awt.TextField text1;
public TextField() {
setLayout(new FlowLayout());
text1 = new java.awt.TextField(20);
text1.setText("Welcom to java !");
setSize(200, 180);
setLocation(100, 50);
add(text1);
setVisible(true);
}
public static void main(String[] args) {
TextField myText = new TextField();
}
}
import java.awt.*;
public class TextField extends Frame { java.awt.TextField text1;
public TextField() {
setLayout(new FlowLayout());
text1 = new java.awt.TextField(20);
text1.setText("Welcom to java !");
setSize(200, 180);
setLocation(100, 50);
add(text1);
setVisible(true);
}
public static void main(String[] args) {
TextField myText = new TextField();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询