📄 c04cafb78e50001d1dc6bad43998f314
字号:
import java .awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.border.*;
import javax.swing.*;
class Mypanel extends Panel implements ActionListener
{ Button sureButton,chargeButton;
Box baseBox,boxV1,boxV2,boxV3;
Label userLabel,pswLabel,repswLabel;
TextField noText,pswordText,repswText;
Mypanel()
{ sureButton=new Button("确定");
//chargeButton=new Button("修改");
userLabel=new Label("用户名",Label.LEFT);
pswLabel=new Label("密码",Label.LEFT);
repswLabel=new Label("重置密码",Label.LEFT);
noText=new TextField(10);
pswordText=new TextField(10);
repswText=new TextField(10);
boxV1=Box.createVerticalBox();
boxV1.add(userLabel);
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(pswLabel);
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(repswLabel);
boxV2=Box.createVerticalBox();
boxV2.add(noText);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(pswordText);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(repswText);
boxV3=Box.createVerticalBox();
boxV3.add(sureButton);
// boxV3.add(Box.createVerticalStrut(10));
// boxV3.add(chargeButton);
// boxV3.add(Box.createVerticalStrut(10));
baseBox=Box.createHorizontalBox();
baseBox.add(boxV1);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(boxV2);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(boxV3);
add(baseBox);
noText.addActionListener(this);
pswordText.addActionListener(this);
repswText.addActionListener(this);
sureButton.addActionListener(this);
// chargeButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
}
}
class managerWindow extends JFrame implements ActionListener
{ Button addButton,resetButton,delButton;
Mypanel panel1;
managerWindow(String s)
{ super(s);
setLayout(new FlowLayout());
panel1=new Mypanel();
addButton=new Button("添加");
resetButton=new Button("修改");
delButton=new Button("删除");
add(addButton);
add(resetButton);
add(delButton);
add(panel1);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setBounds(120,120,300,300);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{ /* Connection con=null;
Statement sql=null;
ResultSet rs=null;
if(e.getSource()==addButton)
{ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch ( ClassNotFoundException ee )
{ System.out.print( " " + ee );
}
try
{ con=DriverManager.getConnection("jdbc:odbc:sun","","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM login");
while(rs.next())
{ String no =rs.getString(1);
String name =rs.getString(2);
String english =rs.getString(3);
text1.append("学号"+no+" ");
text1.append("姓名"+name+" ");
text1.append("英语"+english+"\n");
}
con.close();
}
catch( SQLException cc)
{
System.out.println("mmmmmmmm");
}
}
else if(e.getSource()==button2)
{
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch ( ClassNotFoundException ee )
{ System.out.print( " " + ee );
}
try
{ con=DriverManager.getConnection("jdbc:odbc:sun","","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM 成绩信息表");
while(rs.next())
{ String no =rs.getString(1);
String name =rs.getString(2);
String datastruction =rs.getString(3);
text1.append("学号"+no+" ");
text1.append("姓名"+name+" ");
text1.append("数据结构"+datastruction+"\n");
}
con.close();
}
catch( SQLException cc)
{
System.out.println("mmmmmmmm");
}
}
else if(e.getSource()==button3)
{
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch ( ClassNotFoundException ee )
{ System.out.print( " " + ee );
}
try
{ con=DriverManager.getConnection("jdbc:odbc:sun","","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM 成绩信息表");
while(rs.next())
{ String no =rs.getString(1);
String name =rs.getString(2);
String managerial =rs.getString(3);
text1.append("学号"+no+" ");
text1.append("姓名"+name+" ");
text1.append("管理学"+managerial+"\n");
}
con.close();
}
catch( SQLException cc)
{
System.out.println("mmmmmmmm");
}
}
else
{
text1.setText(null);
}
}*/
}
}
/*public class Manager
{ public static void main(String args[])
{ managerWindow win=new managerWindow("系统管理");
}
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -