The previous chapter introduced the registration page, now we are about to enter the topic ——— function page
I divide the function page into user function page and administrator function page
Ps: The system determines whether a user is a user or an administrator based on the login account ~~~~~~~~~
Let’s take a look at the user function page first:
The main page looks like this, each button function has been implemented, and the title is the current user name ~~~~~~~
View personal information:
Modify my information:
Revised information:
View the library uploaded by the administrator:
Code implementation:
package Library;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/** * User function options *@author hwt1070359898
*
*/
public class UserFunction extends Frame implements ActionListener{
// Define individual controls
private JButton btLookSelf=new JButton("View personal Information");
private JButton btModify=new JButton("Modification of Personal Data");
private JButton btLookBooks=new JButton("View library information");
private JButton btExit=new JButton(Log out of the system);
public UserFunction(a){
super("User:+User.num);// Serial port title
this.setLayout(null);// Set to manually set the location and size of each component
btLookSelf.setBounds(new Rectangle(50.80.300.50));// Modify personal information
btModify.setBounds(new Rectangle(50.150.300.50));// Modify personal information
btLookBooks.setBounds(new Rectangle(50.220.300.50));// Check the library information
btExit.setBounds(new Rectangle(50.290.300.50));// Exit the system
btLookSelf.addActionListener(this);
btModify.addActionListener(this);
btLookBooks.addActionListener(this);
btExit.addActionListener(this);
this.add(btLookSelf);
this.add(btModify);
this.add(btLookBooks);
this.add(btExit);
this.setSize(400.370);
GUIUtil.toCenter(this);// Center the window
this.setVisible(true);/ / visualization
this.setResizable(false);// Close the zoom window
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// Set error close operation
// Close the form event
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){ dispose(); }}); }private void setDefaultCloseOperation(int exitOnClose) {
// TODO Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==btLookSelf) {
String message="Your details are :\n";
message+="Student Number:"+User.num+"\n";
message+="Name:"+User.name+"\n";
message+="Username:"+User.username+"\n";
message+="Gender:+User.sex+"\n";
message+="Age:"+User.age+"\n";
message+="Class:"+User.clas+"\n";
JOptionPane.showMessageDialog(this,message);
}else if(e.getSource()==btModify) {
new ModifyDialog("Fixed student Number:"+User.num);
this.dispose();
}
else if(e.getSource()==btLookBooks) {
this.dispose();
new ShowBook();
}
else if(e.getSource()==btExit){
JOptionPane.showMessageDialog(this."Thank you for coming, welcome to continue to use this system next time!");
System.exit(0); }}}Copy the code
This is the case for user functions, and the next part is administrator functions ““““““““`
Any questions in the article are welcome to harass yo, the blogger hopes to progress with you ~~~~~~