📄 flowgui.java
字号:
package GUI;
import shujuku.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;
public class FlowGUI extends JFrame implements ActionListener
{
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);
BufferedReader in;
PrintWriter out; Socket socket;
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("返回主界面"))
{
dispose();
}
else if(e.getActionCommand().equals("退出"))
{
WindowConfirm guig=new WindowConfirm();
}
else if (e.getActionCommand().equals("出库")) {
/*String a = a1.getText();
String b = a2.getText();
SQLMethod2 liu=new SQLMethod2();
String s=liu.searchS(a,b);
liu.searchI(b);
if(liu.getB()&&liu.getB1())//liu.getB()
{
String s1=s.substring(0,s.indexOf(" "));
String s2=s.substring(s.indexOf(" ")+1);
GetDate gd=new GetDate();
String time=gd.getDate();
if(s1.equals("您要的图书已被借出"))
{
JOptionPane.showMessageDialog(this," 您要的图书已被借出 ");
//t[2].setText(s1);
}
else if(s1.equals("您的借书本数已经超出限制"))
JOptionPane.showMessageDialog(this," 您的借书本数已经超出限制 ");
else
{
a3.setEditable(true);
a3.setText(time);
liu.change(a,b,time);
JOptionPane.showMessageDialog(this," 借书成功!! ");}}*/}
else if (e.getActionCommand().equals("入库")) {
String a = a4.getText();
String b = a5.getText();
GetDate gd=new GetDate();
String time=gd.getDate();
SQLMethod2 liu=new SQLMethod2();
String sd=liu.huan(a,time);
if(!sd.equals(" "))
{
String s1=sd.substring(0,sd.indexOf(" "));
sd=sd.substring(sd.indexOf(" ")+1);
String s2=sd.substring(0,sd.indexOf(" "));
sd=sd.substring(sd.indexOf(" ")+1);
String s3=sd.substring(0);
a5.setEditable(true);
a6.setEditable(true);
a5.setText(s1);
a6.setText(time);
liu.gai(a);JOptionPane.showMessageDialog(this," 还书成功!! ");
}
else
JOptionPane.showMessageDialog(this," 查无此书 ");
}
}
public FlowGUI()
{
连接服务器();
setTitle("图书流通");
setSize(500,300);
Dimension screen = getToolkit().getScreenSize(); //得到屏幕尺寸
setLocation((screen.width-getSize().width)/2,(screen.height-getSize().height)/2); //设置窗口位置
Container con=getContentPane();
JTabbedPane t=new JTabbedPane();
con.add(t);
//借书标签
JPanel borrow=new JPanel();borrow.setBackground(Color.LIGHT_GRAY);
borrow.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
JPanel back=new JPanel();back.setBackground(Color.LIGHT_GRAY);
back.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
JPanel help=new JPanel();help.setBackground(Color.LIGHT_GRAY);
help.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
t.addTab("借书",borrow);t.addTab("还书",back);t.addTab("帮助", help);
JLabel bl=new JLabel("图书ID");JLabel rl=new JLabel("读者ID");
JLabel od=new JLabel("出借日期");
borrow.setLayout(new BorderLayout());
JPanel p=new JPanel();p.setBackground(Color.LIGHT_GRAY);p.setLayout(new GridLayout(6,1));
p.add(bl);p.add(a1);p.add(rl);p.add(a2);p.add(od);p.add(a3); a3.setEditable(false);
SQLMethod2 l = new SQLMethod2();
borrow.add(p,BorderLayout.CENTER);
JPanel buttonp=new JPanel();buttonp.setBackground(Color.LIGHT_GRAY);
buttonp.setLayout(new BoxLayout(buttonp,BoxLayout.Y_AXIS));
buttonp.add(strut1);
JButton chuku=new JButton("出库");chuku.addActionListener(this);
JButton suoding=new JButton("锁定屏幕");suoding.addActionListener(this);
JButton fanhui=new JButton("返回主界面");fanhui.addActionListener(this);
JButton tuichu=new JButton("退出");tuichu.addActionListener(this);
buttonp.add(chuku);buttonp.add(strut2);buttonp.add(suoding);buttonp.add(strut3);buttonp.add(fanhui);buttonp.add(strut4);buttonp.add(tuichu);
borrow.add(buttonp,BorderLayout.EAST);
//还书标签
JLabel bl2=new JLabel("图书ID");JLabel rl2=new JLabel("读者ID");
JLabel od2=new JLabel("归还日期");
back.setLayout(new BorderLayout());
JPanel p2=new JPanel();p2.setBackground(Color.LIGHT_GRAY);p2.setLayout(new GridLayout(6,1));
p2.add(bl2);p2.add(a4);p2.add(rl2);p2.add(a5);p2.add(od2);p2.add(a6);
a6.setText(l.year + "年" + l.month + "月" + l.day + "日");
back.add(p2,BorderLayout.CENTER);
JPanel buttonp2=new JPanel();buttonp2.setBackground(Color.LIGHT_GRAY);
buttonp2.setLayout(new BoxLayout(buttonp2,BoxLayout.Y_AXIS));
buttonp2.add(strut5);
JButton chuku2=new JButton("入库");chuku2.addActionListener(this);
JButton suoding2=new JButton("锁定屏幕");suoding2.addActionListener(this);
JButton fanhui2=new JButton("返回主界面");fanhui2.addActionListener(this);
JButton tuichu2=new JButton("退出");tuichu2.addActionListener(this);
buttonp2.add(chuku2);buttonp2.add(strut6);buttonp2.add(suoding2);buttonp2.add(strut7);buttonp2.add(fanhui2);buttonp2.add(strut8);buttonp2.add(tuichu2);
back.add(buttonp2,BorderLayout.EAST);
setVisible(true);
JLabel set=new JLabel(" 尚未设置此方法 ");
set.setFont(new Font("黑体",30,36));
JLabel ja=new JLabel(" 详情咨询NEWWORLD ");
ja.setFont(new Font("黑体",30,36));
help.add(set);help.add(ja);
}
public static void main(String args[])
{
FlowGUI gui=new FlowGUI();
gui.setVisible(true);
}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 + -