代码如下:importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JTextField;importjavax.swing.text.Vi...
代码如下:
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.View;
import org.omg.CORBA.PUBLIC_MEMBER;
import com.sun.java.swing.plaf.windows.resources.windows;
import sun.awt.WindowClosingListener;
import sun.security.jgss.LoginConfigImpl;
public class MAIN
{
String usertext,passwordtext;
TextField user,password;
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button1=new JButton("登陆");
JButton button2=new JButton("重置");
Label label1 = new Label("账号:",Label.RIGHT);
Label label2 = new Label("密码:",Label.RIGHT);
MAIN(){
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==button1){
try
{
new Mysql1();
frame.setVisible(false);
} catch (SQLException e1)
{
e1.printStackTrace();
}
}
}
});
user = new TextField(12);
password = new TextField(8);
usertext=user.getText();
passwordtext=password.getText();
password.setEchoChar('*');
panel.add(label1);
panel.add(user);
panel.add(label2);
panel.add(password);
panel.add(button1);
panel.add(button2);
frame.add(panel);
frame.setLayout(new FlowLayout());
frame.setTitle("系统管理员登陆界面");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(500,150, 500, 500);
frame.setVisible(true);
}
public static void main(String[] args)
{
MAIN main = new MAIN();
}
}
我导入了rt.jar这个包,可还是报错说访问限制:由于对必需的库 C:\Program Files\Java\jre7\lib\rt.jar 具有一定限制,因此无法访问类型 JPanel?
展开