📄 guiclass.java
字号:
package GUI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.border.*;
import shujuku.SQLMethod;
public class GUIClass extends JFrame implements ActionListener
{
SQLMethod Seach=new SQLMethod();
Socket socket;
BufferedReader in;
PrintWriter out;
JTextField a1=new JTextField(15);
JTextField a2=new JTextField(15); JPasswordField te2;
JTextField a3=new JTextField(15); JPasswordField te3;
JTextField a4=new JTextField(15);
JTextField a5=new JTextField(15);
JTextField a6=new JTextField(15);
Component strut1=Box.createVerticalStrut(80);Component strut2=Box.createVerticalStrut(25);Component strut3=Box.createVerticalStrut(25);Component strut4=Box.createVerticalStrut(25);
Component strut5=Box.createVerticalStrut(80);Component strut6=Box.createVerticalStrut(25);Component strut7=Box.createVerticalStrut(25);Component strut8=Box.createVerticalStrut(25);
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("图书查询"))
{
SelsctGUI gu=new SelsctGUI();
}
else if(e.getActionCommand().equals("退出"))
{
WindowConfirm gui=new WindowConfirm();
}
else if(e.getActionCommand().equals("系统操作"))
{
OperatePasswordGUI gi=new OperatePasswordGUI();
}
else if(e.getActionCommand().equals("图书流通"))
{
FlowPasswordGUI gi=new FlowPasswordGUI();
}
else if(e.getActionCommand().equals("帮助"))
{
JLabel s=new JLabel("版权所有,伪版必究",JLabel.RIGHT);
JLabel sc=new JLabel("版权所有人:李茂瑞",JLabel.RIGHT);
JLabel sd=new JLabel("您可以通过图书查询来查询您想借阅的书");
JLabel sds=new JLabel("您可以通过图书流通来查看您的图书记录");
JLabel cds=new JLabel("您可以通过系统操作来进行数据库的修改");
sd.setFont(new Font("黑体",20,15));
sds.setFont(new Font("黑体",20,15));
cds.setFont(new Font("黑体",20,15));
//JTextArea ja=new JTextArea(5,18);
//ja.setText(" 欢迎使用,谢谢");
// ja.setEditable(false);
JFrame r=new JFrame("帮助");r.setBackground(Color.LIGHT_GRAY);
r.setSize(400,200);
Dimension screen = getToolkit().getScreenSize();
r.setLocation((screen.width-getSize().width)/2,(screen.height-getSize().height)/2);
Container cn=r.getContentPane();
JPanel pa=new JPanel();
cn.add(pa);
pa.add(s);
pa.add(sc);
pa.add(sd);
pa.add(sds);
pa.add(cds);
r.setVisible(true);
}
}
public GUIClass()
{连接服务器();
setSize(500,300);
setTitle("图书管理系统");
Dimension screen = getToolkit().getScreenSize(); //得到屏幕尺寸
setLocation((screen.width-getSize().width)/2,(screen.height-getSize().height)/2); //设置窗口位置
addWindowListener(new WindowDestroyer());
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
JLabel shouye=new JLabel();shouye.setBackground(Color.LIGHT_GRAY);
shouye.setFont(new Font("宋体",Font.PLAIN,56));
shouye.setText(" 图书管理系统");
Container con=getContentPane();JPanel buttonPanel=new JPanel(new FlowLayout());
buttonPanel.setBackground(Color.LIGHT_GRAY);
con.setLayout(new BorderLayout());
JButton b1=new JButton("图书查询");
b1.addActionListener(this);buttonPanel.add(b1);
JButton b2=new JButton("图书流通");
b2.addActionListener(this); buttonPanel.add(b2);
JButton b3=new JButton("系统操作");
b3.addActionListener(this); buttonPanel.add(b3);
JButton b4=new JButton("帮助");
b4.addActionListener(this); buttonPanel.add(b4);
JButton b5=new JButton("退出");
b5.addActionListener(this); buttonPanel.add(b5);
con.add(buttonPanel,BorderLayout.SOUTH);
con.add(shouye);
}
private class WindowDestroyer extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
WindowConfirm gui=new WindowConfirm();
}
}
public static void main(String args[])
{
GUIClass gui=new GUIClass();
gui.setVisible(true);
}
public boolean 身份验证(String 身份信息)
{
String i;boolean 通过验证;
try
{
out.println(身份信息);
i=in.readLine();
if(i.equals("通过验证"))
{
return true;
}
else{return false;}
}
catch(Exception ne){return false;}
}
// 连接服务器的方法
public void 连接服务器()
{
try
{
InetAddress addr=InetAddress.getLocalHost();
socket=new Socket(addr,2026);
in=new BufferedReader(new InputStreamReader(socket.getInputStream()));
out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
}
catch(Exception exc){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -