java图形界面编程,要有运行的过程
发布网友
发布时间:2022-05-09 22:28
我来回答
共2个回答
热心网友
时间:2023-10-25 09:22
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
public class BorrowerInfoPanel {
private JLabel oldKeyLabel, newKeyLabel;
private JPasswordField oldKeyField, newKeyField, confirmKeyField;
private JPanel infoPanel;
private JLabel name1, name2;
private JLabel position1, position2;
private JLabel id1, id2;
private JLabel mail1, mail2;
private JLabel maxBorrowNum1, maxBorrowNum2;
private JLabel maxBorrowTime1, maxBorrowTime2;
private JLabel maxContinueBorrowTime1, maxContinueBorrowTime2;
private JButton change_bt;
private Borrower borrower;
private JFrame frame = new JFrame();;
private JDialog jd = new JDialog(frame, "修改密码", true);
public BorrowerInfoPanel() {
infoPanel = new JPanel();
borrower = new Borrower("1", "dg", "123456");
name1 = new JLabel("姓名");
name2 = new JLabel(borrower.getBorrowerName());
position1 = new JLabel("身份");
position2 = new JLabel("本科生");
id1 = new JLabel("编号");
id2 = new JLabel(borrower.getBorrowerNum());
mail1 = new JLabel("邮箱");
mail2 = new JLabel("453636@qq.com");
maxBorrowNum1 = new JLabel("最大借阅册数");
maxBorrowNum2 = new JLabel("borrower.maxBorrowedNumber");
maxBorrowTime1 = new JLabel("最长借阅时间");
maxBorrowTime2 = new JLabel("31天");
maxContinueBorrowTime1 = new JLabel("最大续借次数");
maxContinueBorrowTime2 = new JLabel("borrower.maxContinueBorrowTime");
change_bt = new JButton("修改密码");
infoPanel.setLayout(new GridLayout(8, 2));
infoPanel.setBorder(new TitledBorder(borrower.getBorrowerName()
+ ":你好!"));
infoPanel.add(id1);
infoPanel.add(id2);
infoPanel.add(name1);
infoPanel.add(name2);
infoPanel.add(position1);
infoPanel.add(position2);
infoPanel.add(mail1);
infoPanel.add(mail2);
infoPanel.add(maxBorrowNum1);
infoPanel.add(maxBorrowNum2);
infoPanel.add(maxBorrowTime1);
infoPanel.add(maxBorrowTime2);
infoPanel.add(maxContinueBorrowTime1);
infoPanel.add(maxContinueBorrowTime2);
infoPanel.add(new JLabel());
infoPanel.add(change_bt);
oldKeyLabel = new JLabel(" 旧密码");
newKeyLabel = new JLabel(" 新密码");
oldKeyField = new JPasswordField(10);
newKeyField = new JPasswordField(10);
confirmKeyField = new JPasswordField(10);
oldKeyField.setEditable(true);
newKeyField.setEditable(true);
confirmKeyField.setEditable(true);
}
public void init() {
change_bt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jd.setVisible(true);// TODO Auto-generated method stub
}
});
jd.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
jd.setVisible(false);
}
});
jd.setLocation(620, 340);
JPanel jp = new JPanel();
JPanel jp2 = new JPanel();
jp.add(oldKeyField);
jp.add(oldKeyLabel);
jp2.add(newKeyField);
jp2.add(newKeyLabel);
Box top = Box.createVerticalBox();
top.add(jp);
top.add(jp2);
jd.add(top);
jd.pack();
jd.setResizable(false);
frame.setLocation(450, 240);
frame.add(infoPanel);
frame.pack();
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new BorrowerInfoPanel().init();
}
class Borrower {
private String borrowerName;
public String getBorrowerName() {
return borrowerName;
}
public void setBorrowerName(String borrowerName) {
this.borrowerName = borrowerName;
}
public String getBorrowerNum() {
return borrowerNum;
}
public void setBorrowerNum(String borrowerNum) {
this.borrowerNum = borrowerNum;
}
public String getPassword() {
return password;
}
public void setId(String id) {
this.password = id;
}
private String borrowerNum;
private String password;
public Borrower(String borrowerNum, String borrowerName, String password) {
this.password = password;
this.borrowerName = borrowerName;
this.borrowerNum = borrowerNum;
}
}
}
热心网友
时间:2023-10-25 09:23
用Netbeans编辑器吧,Sun公司自己的,简单易用,很容易上手的,而且是中文界面