下面程序为什么不能将Button改成JButton
(出现Accessrestriction:Thetype'JButton'isnotAPI(restrictiononrequiredlibrary'C:\Program...
(出现Access restriction: The type 'JButton' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_60\lib\rt.jar')
import java.awt.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class student extends Frame {
public student(){
setTitle("请假系统");
Panel p1 =new Panel();
Panel p2 =new Panel();
Button j =new Button("登陆");
Label l1 =new Label("用户名");
Label l2 =new Label("密码");
TextField t1 =new TextField(10);
TextField t2 =new TextField(10);
p1.add(l1);
p1.add(t1);
p2.add(l2);
p2.add(t2);
add(p1);
add(p2);
add(j);
setLayout(new GridLayout(3,1,3,3));
setVisible(true);
setBounds(300,200,300,200);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
}
});
}
public static void main(String args[]){
new student();
}
} 展开
import java.awt.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class student extends Frame {
public student(){
setTitle("请假系统");
Panel p1 =new Panel();
Panel p2 =new Panel();
Button j =new Button("登陆");
Label l1 =new Label("用户名");
Label l2 =new Label("密码");
TextField t1 =new TextField(10);
TextField t2 =new TextField(10);
p1.add(l1);
p1.add(t1);
p2.add(l2);
p2.add(t2);
add(p1);
add(p2);
add(j);
setLayout(new GridLayout(3,1,3,3));
setVisible(true);
setBounds(300,200,300,200);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
}
});
}
public static void main(String args[]){
new student();
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询