📄 bookframe.java
字号:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JCheckBox;
import javax.swing.JRadioButton;
import javax.swing.JDesktopPane;
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.JTextField;
public class BookFrame extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JToolBar jToolBar = null;
private JPanel jPanel = null;
private JToolBar jToolBar1 = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JComboBox jComboBox = null;
private JRadioButton jRadioButton = null;
private JRadioButton jRadioButton1 = null;
private JDesktopPane jDesktopPane = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JDesktopPane jDesktopPane1 = null;
private JDesktopPane jDesktopPane2 = null;
private JLabel jLabel7 = null;
private JLabel jLabel8 = null;
private JLabel jLabel9 = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JButton jButton4 = null;
private JLabel jLabel14 = null;
private JLabel jLabel15 = null;
private JLabel jLabel16 = null;
private JButton jButton5 = null;
private JButton jButton6 = null;
private JButton jButton7 = null;
private JButton jButton8 = null;
private JScrollPane jScrollPane = null;
private JLabel jLabel5 = null;
private JScrollPane jScrollPane1 = null;
private JScrollPane jScrollPane2 = null;
private JScrollPane jScrollPane3 = null;
private JScrollPane jScrollPane4 = null;
private JScrollPane jScrollPane5 = null;
private JLabel jLabel6 = null;
private JLabel jLabel11 = null;
private JLabel jLabel12 = null;
private JLabel jLabel13 = null;
private JLabel jLabel17 = null;
private JLabel[] jLabelCollect = null;
private JLabel[] jLabelTextCollect = null;
private String[] idList = new String[6];
private Connection connection; // @jve:decl-index=0:
private ResultSet resultSet;
private InsertBookFrame insertBookFrame = null;
private JButton jButton9 = null;
private ButtonGroup buttonGroup;
private JTextField jTextField = null;
private Statement statement = null; // @jve:decl-index=0:
private String loadId = null;
private JButton jButton10 = null;
/**
* This is the default constructor
*/
public BookFrame(String loadId,Connection connection) {
super();
this.loadId = loadId;
this.connection = connection;
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(799, 695);
this.setContentPane(getJContentPane());
this.setTitle("Book");
this.setLocation(200, 50);
this.setResizable(false);
this.setVisible(true);
jLabelCollect = new JLabel[6];
jLabelCollect[0] = jLabel5;
jLabelCollect[1] = jLabel6;
jLabelCollect[2] = jLabel11;
jLabelCollect[3] = jLabel12;
jLabelCollect[4] = jLabel13;
jLabelCollect[5] = jLabel17;
//JLabel[] jLabelCollect = {jLabel5,jLabel6,jLabel11,jLabel12,jLabel13,jLabel17};
jLabelTextCollect = new JLabel[6];
jLabelTextCollect[0] = jLabel7;
jLabelTextCollect[1] = jLabel8;
jLabelTextCollect[2] = jLabel9;
jLabelTextCollect[3] = jLabel14;
jLabelTextCollect[4] = jLabel15;
jLabelTextCollect[5] = jLabel16;
try{
statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
CallableStatement cs = connection.prepareCall("{call TESTSP}",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String query = "select * from Reader where id = "+"'"+loadId+"'";
//System.out.println(query);
ResultSet readerResultSet = statement.executeQuery(query);
readerResultSet.next();
String id = readerResultSet.getString("id");
String name = readerResultSet.getString("name");
String department = readerResultSet.getString("department");
String sex = readerResultSet.getString("sex");
String Email = readerResultSet.getString("Email");
int birth_year = readerResultSet.getInt("birth_year");
int birth_month = readerResultSet.getInt("birth_month");
if(sex.trim().equals(new String("男"))){
jLabel.setIcon(new ImageIcon("Icon\\male.gif"));
}else{
jLabel.setIcon(new ImageIcon("Icon\\female.gif"));
}
String text ="<html>"
+"帐号:" + "<font color = blue>" + id +"</font>"
+"<br><br>"
+"姓名:" + "<font color = blue>" + name + "</font>"
+"<br><br>"
+"系别:" + "<font color = blue>" +department + "</font>"
+"<br><br>"
+"出生年月:" + "<font color = blue>"+ new Integer(birth_year).toString()+"年"+new Integer(birth_month).toString()+ "月"+"</font>"
+"<br><br>"
+"电子邮件:" + "<br><font color = blue>" +Email + "</font>"
+"<br><br>"
+"</html>";
jLabel1.setText(text);
//readerResultSet.next();
readerResultSet.close();
}catch(Exception sqlE){
sqlE.printStackTrace();
}
try{
String query = "select * from Book";
resultSet = statement.executeQuery(query);
resultSet.last();
int count = resultSet.getRow();
resultSet.first();
resultSet.previous();
/*
for(int i=1;i<=count/6+1;i++)
jComboBox1.addItem(new Integer(i));
*/
for(int i=0;i<6;i++){
if(resultSet.next()){
String id = resultSet.getString("id");
String name = resultSet.getString("name");
String text = "<html>"
+"编号:"+id
+"<br>"
+"书名:"+name
+"</html>";
jLabelTextCollect[i].setText(text);
jLabelCollect[i].setIcon(new ImageIcon(resultSet.getBytes("cover")));
idList[i] = id;
}else{
jLabelTextCollect[i].setText(null);
jLabelCollect[i].setIcon(null);
}
}
}catch(Exception sqlE){
sqlE.printStackTrace();
}
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(1);
//System.out.println("windowClosing()"); // TODO Auto-generated Event stub windowClosing()
}
});
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJToolBar(), null);
jContentPane.add(getJPanel(), null);
jContentPane.add(getJToolBar1(), null);
jContentPane.add(getJDesktopPane(), null);
jContentPane.add(getJDesktopPane1(), null);
jContentPane.add(getJDesktopPane2(), null);
}
return jContentPane;
}
/**
* This method initializes jToolBar
*
* @return javax.swing.JToolBar
*/
private JToolBar getJToolBar() {
if (jToolBar == null) {
jToolBar = new JToolBar();
jToolBar.setBounds(new Rectangle(156, 0, 15, 658));
}
return jToolBar;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(7, 91, 143, 215));
jLabel1.setText("");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(8, 5, 67, 78));
jLabel.setText("");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(-2, 1, 158, 317));
jPanel.add(jLabel, null);
jPanel.add(jLabel1, null);
}
return jPanel;
}
/**
* This method initializes jToolBar1
*
* @return javax.swing.JToolBar
*/
private JToolBar getJToolBar1() {
if (jToolBar1 == null) {
jToolBar1 = new JToolBar();
jToolBar1.setBounds(new Rectangle(168, 92, 623, 26));
}
return jToolBar1;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
String searchStr[] = {"按 编号 查找","按 书名 查找","按 类别 查找","按 作者 查找","按 出版社 查找"};
if (jComboBox == null) {
jComboBox = new JComboBox(searchStr);
jComboBox.setSelectedIndex(1);
jComboBox.setBounds(new Rectangle(114, 6, 167, 24));
}
return jComboBox;
}
/**
* This method initializes jRadioButton
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton() {
if (jRadioButton == null) {
jRadioButton = new JRadioButton();
jRadioButton.setText("全词匹配");
jRadioButton.setSelected(true);
jRadioButton.setBounds(new Rectangle(324, 42, 83, 26));
}
return jRadioButton;
}
/**
* This method initializes jRadioButton1
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton1() {
if (jRadioButton1 == null) {
jRadioButton1 = new JRadioButton();
jRadioButton1.setText("部分匹配");
jRadioButton1.setBounds(new Rectangle(446, 42, 81, 30));
}
return jRadioButton1;
}
/**
* This method initializes jDesktopPane
*
* @return javax.swing.JDesktopPane
*/
private JDesktopPane getJDesktopPane() {
if (jDesktopPane == null) {
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(18, 45, 81, 24));
jLabel3.setText("输入内容");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(18, 9, 81, 19));
jLabel2.setText("查找方式");
jDesktopPane = new JDesktopPane();
jDesktopPane.setBounds(new Rectangle(172, 5, 614, 83));
jDesktopPane.add(getJComboBox(), null);
jDesktopPane.add(getJRadioButton(), null);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -