📄 cateview.java
字号:
/* *CateView.java:建立资产类别管理界面(类)。 *包括:增、删、改3个子界面。 */
import javax.swing.*;
import java.awt.*;
public class CateView extends JDialog {
public CatePanel p1;
public CateView(ButPanel p2) {
getContentPane().setLayout(new BorderLayout());
p1 = new CatePanel();
getContentPane().add(p1,BorderLayout.CENTER);
getContentPane().add(p2,BorderLayout.SOUTH);
}
}
class CatePanel extends JPanel {
private Container cont;
private GridBagLayout layout;
private GridBagConstraints cons;
JLabel lblCateId ;
JLabel lblCateName ;
JLabel lblSubCateId ;
JLabel lblSubCateName ;
public JTextField jtfCateId ;
public JTextField jtfCateName ;
public JTextField jtfSubCateId ;
public JTextField jtfSubCateName ;
public CatePanel() {
cont = this;
layout = new GridBagLayout();
cont.setLayout(layout);
cons = new GridBagConstraints();
lblCateId = new JLabel("主类编号");
lblCateName = new JLabel("主类名称");
lblSubCateId = new JLabel("子类编号");
lblSubCateName = new JLabel("子类名称");
jtfCateId = new JTextField(10);
jtfCateName = new JTextField(10);
jtfSubCateId = new JTextField(10);
jtfSubCateName = new JTextField(10);
addComponent(lblCateId,0,0,1,1);
addComponent(jtfCateId,0,1,1,1);
addComponent(lblCateName,1,0,1,1);
addComponent(jtfCateName,1,1,1,1);
addComponent(lblSubCateId,2,0,1,1);
addComponent(jtfSubCateId,2,1,1,1);
addComponent(lblSubCateName,3,0,1,1);
addComponent(jtfSubCateName,3,1,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 AddCateView extends CateView {
public AddCateView(ButPanel p) {
super(p);
setTitle("增加类别");
}
}
class UptCateView extends CateView {
public UptCateView(ButPanel p) {
super(p);
setTitle("修改类别");
}
}
class DelCateView extends CateView {
public DelCateView(ButPanel p) {
super(p);
setTitle("删除类别");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -