?? lendview.java
字號(hào):
/*
*LendView.java:建立固定資產(chǎn)借用與歸還管理界面(類(lèi))。
*包括:借用、歸還2個(gè)子界面。
*/
package zichan;
import javax.swing.*;
import java.awt.*;
import zichan.Mydialog;
import zichan.Share;
public class LendView extends JDialog {
public LendView() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public LendPanel p1;
public LendView(Mydialog p2) {
getContentPane().setLayout(new BorderLayout());
p1 = new LendPanel();
getContentPane().add(p1, BorderLayout.CENTER);
getContentPane().add(p2, BorderLayout.SOUTH);
}
private void jbInit() throws Exception {
}
}
class LendPanel extends JPanel {
private Container cont;
private GridBagLayout layout;
private GridBagConstraints cons;
String[] empno;
String[] isret = {"是", "否"};
JLabel lblAssetId;
JLabel lblAssetName;
JLabel lblModel;
JLabel lblPrice;
JLabel lblEmpno;
JLabel lblUsedate;
JLabel lblRetdate;
JLabel lblIsreturn;
JLabel lblLender;
JLabel lblRemarks;
public JTextField jtfAssetId;
public JTextField jtfAssetName;
public JTextField jtfModel;
public JTextField jtfPrice;
public JComboBox jcbEmpno;
public JTextField jtfUsedate;
public JTextField jtfRetdate;
public JComboBox jcbIsreturn;
public JTextField jtfLender;
public JTextField jtfRemarks;
public LendPanel() {
cont = this;
layout = new GridBagLayout();
cont.setLayout(layout);
cons = new GridBagConstraints();
lblAssetId = new JLabel("資產(chǎn)編號(hào)");
lblAssetName = new JLabel("資產(chǎn)名稱(chēng)");
lblModel = new JLabel("樣式");
lblPrice = new JLabel("價(jià)格");
lblEmpno = new JLabel("借用人");
lblUsedate = new JLabel("借用日期");
lblRetdate = new JLabel("歸還日期");
lblIsreturn = new JLabel("是否歸還");
lblLender = new JLabel("操作人");
lblRemarks = new JLabel("備注");
jtfAssetId = new JTextField(10);
jtfAssetName = new JTextField(10);
jtfModel = new JTextField(10);
jtfPrice = new JTextField(10);
jcbEmpno = new JComboBox();
EmpModel en = new EmpModel();
int cnt = en.selEmpCnt();
empno = new String[cnt];
en.selEmpNo(empno);
for (int i = 0; i < cnt; i++)
jcbEmpno.addItem(empno[i]);
jcbEmpno.setOpaque(true);
jcbEmpno.setPreferredSize(new Dimension(110, 20));
jcbEmpno.setBackground(Color.white);
jtfUsedate = new JTextField(10);
jtfRetdate = new JTextField(10);
jcbIsreturn = new JComboBox(isret);
jcbIsreturn.setOpaque(true);
jcbIsreturn.setPreferredSize(new Dimension(110, 20));
jcbIsreturn.setBackground(Color.white);
jtfLender = new JTextField(10);
jtfLender.setText(Share.operator);
jtfLender.setEnabled(false);
jtfRemarks = new JTextField(10);
addComponent(lblAssetId, 0, 0, 1, 1);
addComponent(jtfAssetId, 0, 1, 1, 1);
addComponent(lblAssetName, 0, 2, 1, 1);
addComponent(jtfAssetName, 0, 3, 1, 1);
addComponent(lblModel, 1, 0, 1, 1);
addComponent(jtfModel, 1, 1, 1, 1);
addComponent(lblPrice, 1, 2, 1, 1);
addComponent(jtfPrice, 1, 3, 1, 1);
addComponent(lblEmpno, 2, 0, 1, 1);
addComponent(jcbEmpno, 2, 1, 1, 1);
addComponent(lblUsedate, 2, 2, 1, 1);
addComponent(jtfUsedate, 2, 3, 1, 1);
addComponent(lblRetdate, 3, 0, 1, 1);
addComponent(jtfRetdate, 3, 1, 1, 1);
addComponent(lblIsreturn, 3, 2, 1, 1);
addComponent(jcbIsreturn, 3, 3, 1, 1);
addComponent(lblLender, 4, 0, 1, 1);
addComponent(jtfLender, 4, 1, 1, 1);
addComponent(lblRemarks, 4, 2, 1, 1);
addComponent(jtfRemarks, 4, 3, 1, 1);
setVisible(true);
}
private void addComponent(Component comp,
int row, int column, int width, int height) {
cons.gridx = column;
cons.gridy = row;
cons.gridwidth = width;
cons.gridheight = height;
layout.setConstraints(comp, cons);
cont.add(comp);
}
}
class LenLendView extends LendView {
public LenLendView(Mydialog p) {
super(p);
setTitle("借用資產(chǎn)");
}
}
class RetLendView extends LendView {
public RetLendView(Mydialog p) {
super(p);
setTitle("歸還資產(chǎn)");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -