java图形界面编程,要有运行的过程

 我来答
匿名用户
2012-06-04
展开全部
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;
}

}

}
Louis_cuti
2012-06-04 · 超过25用户采纳过TA的回答
知道答主
回答量:80
采纳率:0%
帮助的人:77.5万
展开全部
用Netbeans编辑器吧,Sun公司自己的,简单易用,很容易上手的,而且是中文界面
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式