图书信息管理java实现代码

图书信息管理与读者信息管理相似,共包括两部分,图书添加和图书查询与修改,图书信息添加要求正确输入图书的八项信息,并且ISBN编号唯一,实现过程中要将ISBN作为主键。下面看实现过程:

数据库中书籍:

添加书籍过程:

数据库内容增加:

图书的查询与修改:查询过程可以根据不同的条件查询,如ISBN,作者,出版社,图书名称等,默认将所有图书全部显示在列表中,输入查询条件后再表格中显示查询结果。

本模块用到标签面板,可以很方便的查询所需要的信息。修改过程输入ISBN编号后按回车键将在下方显示所有的图书信息,然后修改图书信息后所有内容就会更新。

图书查询:

图书信息修改:

添加图书源代码如下:AddBook.java

package pdsu.bbm.view; 

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import pdsu.bbm.dao.BookDao;
import pdsu.bbm.dao.BookTypeDao;
import pdsu.bbm.model.Book;
import pdsu.bbm.model.BookType;
public class AddBook extends JFrame implements ActionListener { 

 private JPanel contentPane;
 private JLabel label_1;
 private JLabel lbll;
 private JLabel label_2;
 private JLabel label_3;
 private JLabel label_4;
 private JLabel label_5;
 JPanel centerpPanel;
 JButton button1, button2, button3;
 private JComboBox comboBox_1;
 Image icon = new ImageIcon("image/icon.png").getImage();
 private JTextField ISBNfiled;
 private JTextField publishField;
 private JTextField publishDateField;
 private JTextField publishTime;
 private JTextField unitPriceField;
 private JTextField bookNameField;
 private JTextField authorFiled;
 public static void main(String[] args) {
 new AddBook();
 }
 public AddBook() {
 setTitle("添加图书信息");
 setSize(555, 333);
 setIconImage(icon);
 setLocationRelativeTo(null); 

 setTitle("添加图书信息");
 setSize(555, 334);
 setLocationRelativeTo(null);
 setVisible(true);
 centerpPanel = new JPanel();
 centerpPanel.setLayout(null);
 JLabel label1 = new JLabel("ISBN:");
 label1.setFont(new Font("宋体", Font.PLAIN, 20));
 label1.setBounds(71, 26, 95, 42);
 centerpPanel.add(label1); 

 ISBNfiled = new JTextField();
 ISBNfiled.setBounds(120, 30, 110, 30);
 centerpPanel.add(ISBNfiled);
 ISBNfiled.setColumns(10); 

 JLabel label = new JLabel("类 别:");
 label.setFont(new Font("宋体", Font.PLAIN, 20));
 label.setBounds(306, 30, 116, 35);
 centerpPanel.add(label); 

 label_1 = new JLabel("书 名:");
 label_1.setFont(new Font("宋体", Font.PLAIN, 20));
 label_1.setBounds(50, 75, 154, 50);
 centerpPanel.add(label_1); 

 lbll = new JLabel("作 者:");
 lbll.setFont(new Font("宋体", Font.PLAIN, 20));
 lbll.setBounds(306, 75, 137, 50);
 centerpPanel.add(lbll); 

 label_2 = new JLabel("出版社:");
 label_2.setFont(new Font("宋体", Font.PLAIN, 20));
 label_2.setBounds(50, 130, 154, 50);
 centerpPanel.add(label_2); 

 label_3 = new JLabel("出版日期:");
 label_3.setFont(new Font("宋体", Font.PLAIN, 20));
 label_3.setBounds(285, 135, 137, 50);
 centerpPanel.add(label_3); 

 publishField = new JTextField();
 publishField.setColumns(10);
 publishField.setBounds(120, 143, 110, 30);
 centerpPanel.add(publishField); 

 publishDateField = new JTextField();
 publishDateField.setColumns(10);
 publishDateField.setBounds(380, 143, 120, 30);
 centerpPanel.add(publishDateField); 

 label_4 = new JLabel("印刷次数:");
 label_4.setFont(new Font("宋体", Font.PLAIN, 20));
 label_4.setBounds(28, 190, 154, 50);
 centerpPanel.add(label_4); 

 publishTime = new JTextField();
 publishTime.setColumns(10);
 publishTime.setBounds(120, 203, 110, 30);
 centerpPanel.add(publishTime); 

 label_5 = new JLabel("单 价:");
 label_5.setFont(new Font("宋体", Font.PLAIN, 20));
 label_5.setBounds(305, 194, 84, 42);
 centerpPanel.add(label_5); 

 unitPriceField = new JTextField();
 unitPriceField.setColumns(10);
 unitPriceField.setBounds(380, 203, 120, 30);
 centerpPanel.add(unitPriceField);
 getContentPane().add(centerpPanel, BorderLayout.CENTER); 

 bookNameField = new JTextField();
 bookNameField.setColumns(10);
 bookNameField.setBounds(120, 86, 110, 30);
 centerpPanel.add(bookNameField); 

 authorFiled = new JTextField();
 authorFiled.setColumns(10);
 authorFiled.setBounds(380, 86, 120, 30);
 centerpPanel.add(authorFiled); 

 List<BookType> rs = BookTypeDao.selectBookType();
 Iterator<BookType> iterator = rs.iterator();
 String[] AllTypeName = new String[rs.size()];
 int i = 0;
 while (iterator.hasNext()) {
  String typename = iterator.next().getTypename();
  AllTypeName[i] = typename;
  i++;
 }
 comboBox_1 = new JComboBox(AllTypeName);
 comboBox_1.setBounds(380, 30, 120, 30);
 comboBox_1.setFont(new Font("宋体", Font.PLAIN, 16)); 

 centerpPanel.add(comboBox_1);
 ButtonGroup group = new ButtonGroup();
 JPanel panel2 = new JPanel();
 panel2.setLayout(new FlowLayout());
 button1 = new JButton("添加");
 button1.setFont(new Font("宋体", Font.PLAIN, 20)); 

 button2 = new JButton("关闭");
 button2.setFont(new Font("宋体", Font.PLAIN, 20));
 button3 = new JButton("重置");
 button3.setFont(new Font("宋体", Font.PLAIN, 20)); 

 panel2.add(button1);
 panel2.add(button3);
 panel2.add(button2);
 button1.addActionListener(this);
 button2.addActionListener(this);
 button3.addActionListener(this);
 getContentPane().add(panel2, BorderLayout.SOUTH); 

 setVisible(true);
 } 

 @SuppressWarnings("unused")
 public void actionPerformed(ActionEvent e) {
 if (e.getSource() == button1) {
  String Isbn = ISBNfiled.getText().toString(); 

  String bookname = bookNameField.getText();
  String author = authorFiled.getText();
  String selectType = comboBox_1.getSelectedItem().toString();
  String publish = publishField.getText();
  String publishdate = publishDateField.getText();
  String time = publishTime.getText().trim();
  String price = unitPriceField.getText().trim(); 

  if (Isbn.equals("") || bookname.equals("") || author.equals("")
   || selectType.equals("") || publish.equals("")
   || publishdate.equals("") || time.equals("")
   || price.equals("")) {
  JOptionPane.showMessageDialog(this, "请输入完整信息");
  return;
  } else {
  BookType bt = new BookType();
  Book book = new Book();
  book.setISBN(Isbn);
  book.setBookname(bookname);
  book.setAuthor(author);
  bt.setTypename(selectType);
  int m = 0;
  List<BookType> list = BookTypeDao
   .selectIdByTypename(selectType);
  Iterator<BookType> ite = list.iterator();
  while (ite.hasNext()) {
   m = ite.next().getId();
  }
  book.setTypeid(m + "");
  book.setPublish(publish);
  try {
   book.setPublishtime(Integer.parseInt(time));
   book.setUnitprice(Integer.parseInt(price));
  } catch (NumberFormatException e1) {
   e1.printStackTrace();
  } 

   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   Date regDate = null;
   try {
   regDate =sdf.parse(publishdate);
   } catch (ParseException e1) {
   JOptionPane.showMessageDialog(this, "请输入正确的日期");
   publishDateField.setText("");
   } 

   book.setPublishdate(regDate);
  if(regDate==null) return; 

   if (BookDao.selectBookByISBN(Isbn) != null) {
   JOptionPane.showMessageDialog(this, "该ISBN编号已存在");
   return;
  } else if (BookDao.insertBook(book) != 0) {
   JOptionPane.showMessageDialog(this, "添加成功");
  } else
   JOptionPane.showMessageDialog(this, "添加失败");
  }
 }
 if (e.getSource() == button3) {
  ISBNfiled.setText("");
  bookNameField.setText("");
  authorFiled.setText("");
  publishField.setText("");
  publishDateField.setText("");
  publishTime.setText("");
  unitPriceField.setText("");
 }
 if (e.getSource() == button2) {
  dispose();
  new MainWindow(); 

 }
 } 

}

图书查询与修改源代码:BookSelectandModify.java

package pdsu.bbm.view; 

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.TableModel;
import pdsu.bbm.dao.BookDao;
import pdsu.bbm.dao.BookTypeDao;
import pdsu.bbm.model.Book;
import pdsu.bbm.model.BookType; 

public class BookSelectandModify extends JFrame implements ActionListener {
 // 设置序列号
 private static final long serialVersionUID = 1L;
 private JTabbedPane jtabbedPane; // 标签面板
 // selectJP查询面板 select_conditionJP下拉列表面板 select_resultJP结果按钮面板updateJP修改面板
 // updateJP修改面板,bookJP中间面板 buttonJP2按钮面板
 private JPanel selectJP, select_conditionJP, select_resultJP, buttonJP1,
  bookJP, updateJP, buttonJP2;//
 private JTextField selectJTF, ISBNJTF, booknameJTF, authorJTF,
  printtimeJTF, publishJTF, publishdateJTF, unitpriceJTF;
 private JLabel ISBNJL, booknameJL, authorJL, categoryJL, printtimeJL,
  publishJL, publishdateJL, unitpriceJL;
 // 重点!
 private JTable jtable;// 定义表格
 private JComboBox choiceJCB, booktypeJCB;
 private JScrollPane jscrollPane;
 private JButton selectJB, exitJB, updateJB, resetJB;// 查询按钮,退出按钮,修改按钮,关闭按钮
 private TableModel getSelect;
 private String[] title = { "ISBN", "图书序列", "图书名称", "作者", " 出版社 ",
  "出版日期", "印刷次数", "单价" };
 Image icon = new ImageIcon("image/icon.png").getImage(); 

 public BookSelectandModify() {
 super();
 setIconImage(icon);
 setTitle("图书查询与修改");
 setBounds(100, 100, 555, 400);
 setLocationRelativeTo(null);
 // JTabbedPane选项卡
 jtabbedPane = new JTabbedPane();
 add(jtabbedPane);
 selectJP = new JPanel();
 selectJP.setLayout(new BorderLayout());
 jtabbedPane.add("图书信息查询", selectJP); 

 // 查询条件面板
 select_conditionJP = new JPanel();
 choiceJCB = new JComboBox();
 String array[] = { "ISBN", "图书名称", "图书序列", "作者", "出版社","所有" };// 设置为一维数组
 for (int i = 0; i < array.length; i++) {
  choiceJCB.addItem(array[i]);
 }
 select_conditionJP.add(choiceJCB);
 selectJTF = new JTextField(20);
 select_conditionJP.add(selectJTF);
 selectJP.add(select_conditionJP, BorderLayout.NORTH);
 // 查询结果面板
 select_resultJP = new JPanel();
 BookDao dao = new BookDao();
 List<Book> list = dao.selectBook();
 jtable = new JTable(getSelect(list), title); 

 // !设置表格大小不变
 jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
 // !设置列宽
 jtable.getColumnModel().getColumn(4).setPreferredWidth(175);
 jscrollPane = new JScrollPane(jtable);// 把表格加入滚动面板
 // 显示滚动面板边框
 jscrollPane.setPreferredSize(new Dimension(450, 170));
 select_resultJP.add(jscrollPane);
 selectJP.add(select_resultJP, BorderLayout.CENTER);
 // 查询按钮面板
 buttonJP1 = new JPanel();
 selectJB = new JButton("查询");
 selectJB.setFont(new Font("宋体", Font.PLAIN, 20)); 

 selectJB.addActionListener(this);
 buttonJP1.add(selectJB);
 exitJB = new JButton("退出");
 exitJB.setFont(new Font("宋体", Font.PLAIN, 20));
 exitJB.addActionListener(this);
 buttonJP1.add(exitJB);
 selectJP.add(buttonJP1, BorderLayout.SOUTH);
 // 信息修改页面
 updateJP = new JPanel();
 updateJP.setLayout(new BorderLayout());
 jtabbedPane.addTab("图书信息修改", updateJP);
 bookJP = new JPanel();
 final GridLayout gridLayout = new GridLayout(8, 2);
 // 设置边框间的距离
 gridLayout.setVgap(8);
 gridLayout.setHgap(8);
 bookJP.setLayout(gridLayout);
 ISBNJL = new JLabel("ISBN:");
 ISBNJL.setFont(new Font("宋体",Font.PLAIN,20));
 ISBNJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(ISBNJL);
 ISBNJTF = new JTextField(20);
 ISBNJTF.addActionListener(this);
 bookJP.add(ISBNJTF);
 categoryJL = new JLabel("类 别:");
 categoryJL.setFont(new Font("宋体",Font.PLAIN,20));
 categoryJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(categoryJL);
 // 下拉列表
 List<BookType> list1 = BookTypeDao.selectBookType();
 Iterator<BookType> it = list1.iterator();
 String ty[] = new String[list1.size()];
 int i = 0;
 booktypeJCB = new JComboBox();
 while (it.hasNext()) {
  ty[i] = it.next().getTypename();
  booktypeJCB.addItem(ty[i]);
  i++;
 } 

 bookJP.add(booktypeJCB); 

 booknameJL = new JLabel("书 名:");
 booknameJL.setFont(new Font("宋体",Font.PLAIN,20));
 booknameJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(booknameJL);
 booknameJTF = new JTextField();
 booknameJTF.setColumns(20);
 bookJP.add(booknameJTF); 

 authorJL = new JLabel("作 者:");
 authorJL.setFont(new Font("宋体",Font.PLAIN,20));
 authorJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(authorJL);
 authorJTF = new JTextField();
 authorJTF.setColumns(20);
 bookJP.add(authorJTF); 

 publishJL = new JLabel("出版社:");
 publishJL.setFont(new Font("宋体",Font.PLAIN,20));
 publishJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(publishJL);
 publishJTF = new JTextField();
 bookJP.add(publishJTF); 

 publishdateJL = new JLabel("出版日期:");
 publishdateJL.setFont(new Font("宋体",Font.PLAIN,20));
 publishdateJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(publishdateJL);
 publishdateJTF = new JTextField();
 publishdateJTF.setHorizontalAlignment(SwingConstants.LEFT);
 bookJP.add(publishdateJTF); 

 printtimeJL = new JLabel("印刷次数:");
 printtimeJL.setFont(new Font("宋体",Font.PLAIN,20));
 printtimeJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(printtimeJL);
 printtimeJTF = new JTextField();
 bookJP.add(printtimeJTF); 

 unitpriceJL = new JLabel("单 价:");
 unitpriceJL.setFont(new Font("宋体",Font.PLAIN,20));
 unitpriceJL.setHorizontalAlignment(SwingConstants.CENTER);
 bookJP.add(unitpriceJL);
 unitpriceJTF = new JTextField();
 bookJP.add(unitpriceJTF);
 // 按钮面板
 // 按钮面板设计
 buttonJP2 = new JPanel();
 updateJB = new JButton("修改");
 updateJB.setFont(new Font("宋体", Font.PLAIN, 20)); 

 updateJB.addActionListener(this);
 resetJB = new JButton("关闭");
 resetJB.setFont(new Font("宋体", Font.PLAIN, 20)); 

 resetJB.addActionListener(this);
 buttonJP2.add(updateJB);
 buttonJP2.add(resetJB);
 updateJP.add(bookJP, BorderLayout.CENTER);
 updateJP.add(buttonJP2, BorderLayout.SOUTH);
 setVisible(true);
 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 } 

 // 将查询表格加入面板
 private Object[][] getSelect(List<Book> list) {
 // TODO Auto-generated method stub
 Object[][] objects = new Object[list.size()][title.length];
 for (int i = 0; i < list.size(); i++) {
  Book book = list.get(i);
  objects[i][0] = book.getISBN();
  objects[i][1] = book.getTypeid();// 图书序列
  objects[i][2] = book.getBookname();// 图书名称
  objects[i][3] = book.getAuthor();// 图书作者
  objects[i][4] = book.getPublish();// 出版社
  objects[i][5] = book.getPublishdate();// 出版日期
  objects[i][6] = book.getPublishtime();// 印刷次数
  objects[i][7] = book.getUnitprice();// 单价
 } 

 return objects; 

 }
 public void actionPerformed(ActionEvent e) {
 // TODO Auto-generated method stub
 if(e.getSource()==ISBNJTF){
  String isbn=ISBNJTF.getText();
  String typename=null;
  String id=BookDao.selectBookByISBN(isbn).getTypeid(); 

  typename=BookTypeDao.selectById(id);
  System.out.println(typename);
  booktypeJCB.setSelectedItem(typename);
  booknameJTF.setText(BookDao.selectBookByISBN(isbn).getBookname());
  authorJTF.setText(BookDao.selectBookByISBN(isbn).getAuthor());
  publishJTF.setText(BookDao.selectBookByISBN(isbn).getPublish());
  publishdateJTF.setText(BookDao.selectBookByISBN(isbn).getPublishdate()+"");
  printtimeJTF.setText(BookDao.selectBookByISBN(isbn).getPublishtime()+"");
  unitpriceJTF.setText(BookDao.selectBookByISBN(isbn).getUnitprice()+""); 

 }
 if (e.getSource() == selectJB) {// 按照ISBN编码查找
  int r = choiceJCB.getSelectedIndex();
  if (r == 0) {
  String name = selectJTF.getText().trim();
  // 强制转换为线性表类型
  List<Book> list = new ArrayList<Book>();
  Book book = BookDao.selectBookByISBN(name);
  if (book == null) {
   JOptionPane.showMessageDialog(this, "该编码不存在!");
  } else {
   list.add(book);
   Object[][] data = getSelect(list);
   jtable = new JTable(data, title);
   jtable.getColumnModel().getColumn(4).setPreferredWidth(175);
   jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 

   jscrollPane.setViewportView(jtable); 

  }
  } 

  if (r == 1) {// 根据图书名称查询信息
  String name = selectJTF.getText().toString();
  List<Book> list = BookDao.selectBookByName(name);
  // 判断线性表是否为空
  if (list == null || list.size() == 0) {
   JOptionPane.showMessageDialog(this, "该图书不存在!");
  } else {
   Object[][] data = getSelect(list);
   jtable = new JTable(data, title);
   tianjia();
  }
  }
  if (r == 2) {// 根据图书序列查询信息
  String name = selectJTF.getText().toString();
  List<Book> list = BookDao.selectBookByType(name);
  // 判断线性表是否为空
  if (list == null || list.size() == 0) {
   JOptionPane.showMessageDialog(this, "该图书不存在!");
  } else {
   Object[][] data = getSelect(list);
   jtable = new JTable(data, title);
   tianjia();
  }
  }
  if (r == 3) { // 根据作者进行查找
  String name = selectJTF.getText().toString();
  // 根据作者进行查找
  List<Book> list = BookDao.selectBookByAuthor(name);
  // 判断线性表是否为空
  if (list == null || list.size() == 0) {
   JOptionPane.showMessageDialog(this, "该图书不存在!");
  } else {
   Object[][] data = getSelect(list);
   jtable = new JTable(data, title);
   tianjia();
  }
  }
  if (r == 4) {// 根据出版社进行查找
  String name = selectJTF.getText().toString();
  List<Book> list = BookDao.selectBookByPublish(name);
  if (list == null || list.size() == 0) {
   JOptionPane.showMessageDialog(this, "该图书不存在!");
  } else {
   Object[][] data = getSelect(list);
   jtable = new JTable(data, title);
   tianjia(); 

  }
  }
  if(r==5){
  List<Book> list =BookDao.selectBook();
  }
 }
 if (e.getSource() == updateJB) {
  String ISBN = ISBNJTF.getText().trim();
  String typename = ((String) booktypeJCB.getSelectedItem()).trim();
  String id = BookTypeDao.selectByTypename(typename);
  String bookname = booknameJTF.getText();
  String author = authorJTF.getText();
  String publish = publishJTF.getText();
  String publishdate = publishdateJTF.getText(); 

  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  Date regDate = null;
  try {
  regDate = sdf.parse(publishdate);
  } catch (Exception e2) {
  e2.printStackTrace();
  JOptionPane.showMessageDialog(this, "请输入正确的日期格式!");
  }
  if (regDate == null)
  return;
  int publishtime = Integer.parseInt(printtimeJTF.getText());
  int unitprice = Integer.parseInt(unitpriceJTF.getText());
  // 封装对象
  Book book = new Book();
  book.setISBN(ISBN);
  book.setTypeid(id);
  book.setBookname(bookname);
  book.setAuthor(author);
  book.setPublish(publish);
  book.setPublishdate(regDate);
  book.setPublishtime(publishtime);
  book.setUnitprice(unitprice);
  book.setTypename(typename);
  int result = BookDao.update(book);
  List<Book> list2 = new ArrayList<Book>();
  list2.add(book); 

  // System.out.println(list2); 

  if (result == 1) {
  JOptionPane.showMessageDialog(this, "修改成功!");
  BookDao bk=new BookDao();
  List<Book> list =bk.selectBook();
  jtable =new JTable(getSelect(list),title);
  tianjia(); 

  } else {
  JOptionPane.showMessageDialog(this, "修改失败!");
  }
 }
 if (e.getSource() == resetJB) {
  dispose();
  new MainWindow();
 }
 if (e.getSource() == exitJB) {
  dispose();
  new MainWindow();
 }
 } 

 private void tianjia() {
 jtable.getColumnModel().getColumn(4).setPreferredWidth(175);
 jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 

 jscrollPane.setViewportView(jtable); 

 } 

 public static void main(String[] args) {
 new BookSelectandModify(); 

 }
} 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • 图书管理系统java版

    本文的目的就是通过图书管理系统掌握数据库编程技术,能正确连接数据库,能对数据库中信息进行查询.插入.删除.修改. 内容:在数据库中创建一张书目信息表,包括书名.作者.出版社.出版日期.书号.价格字段.设计一个GUI界面进行书目管理.在该界面上有四个选项卡,分别是查询.插入.删除.修改.点击查询选项卡,出现的界面上有书名.作者.出版社.书号四个文本框,一个按钮和一个只读文本区.文本框内容可以为空,输入相应的查询信息后(例如根据书名查询可以仅输入书名),点击界面上的"查询"按钮,可以在界面

  • 图书管理系统java代码实现

    本文实例为大家分享了java实现图书管理系统的具体代码,供大家参考,具体内容如下 /* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称:    <图书管理系统--java>                          * 作    者:       刘江波                       * 完成日期:    2012     年  3    

  • 一个简陋的java图书管理系统

    本文代码为原创一个简陋的管理系统,只做功能的测试.并没有去完善所有应有的功能,只做了输入输出查找,仅供参考! 菜单部分: import java.util.Scanner; public class Menu { int Min = 1; int Max = 3; public void getMenu(){ System.out.println("1.显示/2.输入/3.查找"); } public void getFindMenu(){ System.out.println(&qu

  • 图书信息管理java实现代码

    图书信息管理与读者信息管理相似,共包括两部分,图书添加和图书查询与修改,图书信息添加要求正确输入图书的八项信息,并且ISBN编号唯一,实现过程中要将ISBN作为主键.下面看实现过程: 数据库中书籍: 添加书籍过程: 数据库内容增加: 图书的查询与修改:查询过程可以根据不同的条件查询,如ISBN,作者,出版社,图书名称等,默认将所有图书全部显示在列表中,输入查询条件后再表格中显示查询结果. 本模块用到标签面板,可以很方便的查询所需要的信息.修改过程输入ISBN编号后按回车键将在下方显示所有的图书信

  • Java实现图书管理系统的示例代码

    目录 一.功能介绍 二.Main包 三.User包 1. User 2. AdminUser 3. NormalUser 四.book包 1. Book 2. BookList 五.operations包 1. IOperation接口 2. AddOperation 3. BorrowOperation 4. DelOperation 5. DisplayOperation 6. ExitOperation 7. FindOperation 8. ReturnOperation 一.功能介绍

  • JavaSE实现图书管理系统的示例代码

    目录 前言 1. 项目需求 2. 实现思路 3. 代码实现 包的设计 book包 operations包 user包 4. 实现效果 前言 这篇博客是在学习了一部分Java基础语法之后的练习项目,通过这个小项目的练习,对Java中的类和对象,抽象类和接口,面向对象的继承.多态和封装.组合等进行熟悉理解:抽象出不同的对象,将对象进行合理的设计,完成对象之间的交互,面向对象进行编程. 1. 项目需求 图书管理系统,面向管理员和普通用户使用,对管理员的开放的功能有:添加图书,删除图书,查找图书,显示图

  • HTTP基本认证(Basic Authentication)的JAVA实例代码

    大家在登录网站的时候,大部分时候是通过一个表单提交登录信息. 但是有时候浏览器会弹出一个登录验证的对话框,如下图,这就是使用HTTP基本认证. 下面来看看一看这个认证的工作过程: 第一步: 客户端发送http request 给服务器,服务器验证该用户是否已经登录验证过了,如果没有的话, 服务器会返回一个401 Unauthozied给客户端,并且在Response 的 header "WWW-Authenticate" 中添加信息. 如下图. 第三步: 服务器将Authorizati

  • Java线程代码的实现方法

    一.线程Java代码实现 1.继承Thread 声明Thread的子类 public class MyThread extends Thread { public void run(){ System.out.println("MyThread running"); } } 运行thread子类的方法 MyThread myThread = new MyThread(); myTread.start(); 2.创建Thread的匿名子类 Thread thread = new Thre

  • 二维码生成Java实现代码

    本文实例为大家分享了二维码生成Java实现代码,供大家参考,具体内容如下 package com.yihaomen.barcode; import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Shape; import java.awt.geom.RoundRectangle2D; import java.awt

  • Java 普通代码块静态代码块执行顺序(实例讲解)

    如下所示: class B { public B() { super(); System.out.println("构造器B"); } { System.out.println("普通的代码块B"); } static{ System.out.println("静态代码块B"); } } public class ClassA extends B { public ClassA() { super(); System.out.println(&q

  • Java计算程序代码执行时间的方法小结

    本文实例总结了Java计算程序代码执行时间的方法.分享给大家供大家参考,具体如下: 有时候为了排查性能问题,需要记录完成某个操作需要的时间,我们可以使用System类的currentTimeMillis()方法来返回当前的毫秒数,并保存到一个变量中,在方法执行完毕后再次调用 System的currentTimeMillis()方法,并计算两次调用之间的差值,就是方法执行所消耗的毫秒数. 如方法一: long startTime = System.currentTimeMillis(); //获取

  • 实例解析JAVA中代码的加载顺序

    Java中代码的加载顺序所能了解的知识点 类的依赖关系 static代码块的加载时间 继承类中构造器的隐式调用 非static的成员变量初始化时间 main方法和static的加载顺序 测试代码如下: public class App { private static App d = new App(); private SubClass t = new SubClass(); static{ System.out.println("App static");//6 } public

随机推荐