cateview.java
来自「一个企业小型固定资产系统的源代码。发布出来让刚学习java的人研究。」· Java 代码 · 共 97 行
JAVA
97 行
package project;
/*
*CateView.java:建立资产类别管理界面(类)。
*包括:增、删、改3个子界面。
*/
import javax.swing.*;
import java.awt.*;
public class CateView extends JDialog {
public CatePanel p1;
public CateView(ButPanel p2) {
JLabel lblTiTle = new JLabel("类 编 辑");
lblTiTle.setFont(new Font("隶书", Font.PLAIN, 30));
lblTiTle.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().setLayout(new BorderLayout());
p1 = new CatePanel();
getContentPane().add(lblTiTle,BorderLayout.NORTH);
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 lblCateNId ;
JLabel lblCateName ;
public JTextField jtfCateId ;
public JTextField jtfCateNId ;
public JTextField jtfCateName ;
public CatePanel() {
cont = this;
layout = new GridBagLayout();
cont.setLayout(layout);
cons = new GridBagConstraints();
lblCateId = new JLabel("类 编 码");
lblCateNId = new JLabel("类 新 编 码");
lblCateName = new JLabel("本级类名称");
jtfCateId = new JTextField(10);
jtfCateNId = new JTextField(10);
jtfCateName = new JTextField(10);
addComponent(lblCateId,0,0,1,1);
addComponent(jtfCateId,0,1,1,1);
addComponent(lblCateNId,1,0,1,1);
addComponent(jtfCateNId,1,1,1,1);
addComponent(lblCateName,2,0,1,1);
addComponent(jtfCateName,2,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("增加类别");
p1.jtfCateNId.setEnabled(false);
}
}
class UptCateView extends CateView {
public UptCateView(ButPanel p) {
super(p);
setTitle("修改类别");
}
}
class DelCateView extends CateView {
public DelCateView(ButPanel p) {
super(p);
setTitle("删除类别");
p1.jtfCateNId.setEnabled(false);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?