📄 lendview.java
字号:
/*
*LendView.java:建立固定资产借用与归还管理界面(类)。
*包括:借用、归还2个子界面。
*/
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("资产编号");
lblAssetName = new JLabel("资产名称");
lblModel = new JLabel("样式");
lblPrice = new JLabel("价格");
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("借用资产");
}
}
class RetLendView extends LendView {
public RetLendView(Mydialog p) {
super(p);
setTitle("归还资产");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -