Summary of this section
This section mainly realizes the final function of the software and some summary of the project.
About the function of software
The function of the software is to pop up a dialog box, tell the user some information about the software, and use the JDialog of swing to complete.
The specific code in AboutSoftDialog.java is as follows:
package bookManageSystem.view; import bookManageSystem.tools.ComponentTools; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; public class AboutSoftDialog extends JDialog implements ActionListener, MouseListener { private ComponentTools componentTools = new ComponentTools(); private JPanel aboutSoftPanel; private Box totalHBox, leftHBox, rightVBox; private JLabel iconLabel, systemLabel, editionLabel, hyperlinkLabel; private JButton closeButton; AboutSoftDialog() { // Set related properties of Dialog this.setTitle("About software"); this.setBounds(400, 400, 500, 300); this.setContentPane(this.createAboutSoftPanel()); this.setVisible(false); // Register event listeners for buttons closeButton.addActionListener(this); // Register mouse event listeners for tags hyperlinkLabel.addMouseListener(this); } /** * Create Dialog's content panel * * @return Return a JPanel */ private JPanel createAboutSoftPanel() { aboutSoftPanel = new JPanel(); aboutSoftPanel.setLayout(new BorderLayout()); totalHBox = Box.createHorizontalBox(); leftHBox = Box.createHorizontalBox(); iconLabel = new JLabel(); iconLabel.setIcon(componentTools.iconSize(new ImageIcon("src/bookManageSystem/images/panda.png"), 160, 160)); leftHBox.add(iconLabel); totalHBox.add(leftHBox); rightVBox = Box.createVerticalBox(); systemLabel = new JLabel("Library management system"); systemLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 30)); editionLabel = new JLabel("Version 1.0"); editionLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 30)); hyperlinkLabel = new JLabel("<html><u>Relevant GitHub link</u></html>"); hyperlinkLabel.setForeground(new Color(0, 149, 200)); hyperlinkLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 20)); rightVBox.add(systemLabel); rightVBox.add(Box.createVerticalStrut(50)); rightVBox.add(editionLabel); rightVBox.add(Box.createVerticalStrut(50)); rightVBox.add(hyperlinkLabel); totalHBox.add(Box.createHorizontalStrut(20)); totalHBox.add(rightVBox); aboutSoftPanel.add(totalHBox, BorderLayout.NORTH); closeButton = new JButton("Close"); Box buttonHBox = Box.createHorizontalBox(); buttonHBox.add(closeButton); aboutSoftPanel.add(buttonHBox, BorderLayout.EAST); return aboutSoftPanel; } @Override public void actionPerformed(ActionEvent e) { // Event handling of the close button if (e.getSource() == closeButton) { // Set the Dialog not to be displayed this.setVisible(false); } } @Override public void mouseClicked(MouseEvent e) { // Mouse click event // Open the default browser locally through the computer and then open the location indicated by the URI Desktop desktop = Desktop.getDesktop(); try { desktop.browse(new URI("https://github.com/lck100/JavaExerciseProject/tree/master/1" + ".%E7%AE%A1%E5%AE%B6%E5%A9%86%E7%B3%BB%E7%BB%9F/%E7%AE%A1%E5%AE%B6%E5%A9%86%E7%B3%BB%E7%BB%9F%EF%BC%88JavaFX%E7%89%88%EF%BC%89")); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } @Override public void mousePressed(MouseEvent e) { // Mouse down event hyperlinkLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); hyperlinkLabel.setForeground(new Color(0, 0, 0)); } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }
The results of running the project are as follows:
Project summary
This project basically involves most of the basic knowledge of Java, especially the application of swing and JDBC, so if you can complete this project alone, the simple application of java basic knowledge should be enough.
The difficulty of this project is the handling of button events and JDBC's addition, deletion, modification and query of database table records. The first time you use the database, it may be difficult to install MySQL. Look up more data on the Internet.
You can search the WeChat public number [Java instance program] or scan the underlying two-dimensional code to pay more attention to the public number.
Note: in the background of public address reply [20200211] can get the source code of this section.