📄 statisticpanel.java~25~
字号:
package mysiloer;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.table.DefaultTableModel;
import java.awt.event.*;
import javax.swing.JDialog;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.AbstractButton;
/**
* <p>Title: MySiloer</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: yskey</p>
*
* @author 杨涛
* @version 1.0
*/
public class StatisticPanel
extends JPanel {
private JSplitPane jSplitPane = new JSplitPane();
private BorderLayout borderLayout1 = new BorderLayout();
private JPanel jPanel1 = new JPanel();
private JToggleButton materialButton = new JToggleButton();
private JSplitPane jSplitPane1 = new JSplitPane();
private BoxLayout2 boxLayout21 = new BoxLayout2();
private JToggleButton productButton = new JToggleButton();
private Component component2;
private Component component3;
private JPanel controlPanel = new JPanel();
private JButton statisticButt = new JButton();
private Component component1;
private JPanel subPanel = new JPanel(new BorderLayout());
private ImageIcon materialIcon = new ImageIcon(this.getClass().getResource(
"material.jpg"));
private ImageIcon productIcon = new ImageIcon(this.getClass().getResource(
"product.jpg"));
private ImageIcon selectIcon = new ImageIcon(this.getClass().getResource(
"select.jpg"));
private ImageIcon updateIcon = new ImageIcon(this.getClass().getResource(
"update.jpg"));
private int type;
private JLabel label;
private ButtonGroup buttonGroup1 = new ButtonGroup();
public DataBase dataBase;
public TablePanel tablePanel = new TablePanel();
private JFrame frame;
GridBagLayout gridBagLayout1 = new GridBagLayout();
GridBagLayout gridBagLayout2 = new GridBagLayout();
public StatisticPanel(JFrame frame, int type, DataBase dataBase) {
try {
this.type = type;
this.dataBase = dataBase;
this.frame = frame;
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
component2 = Box.createVerticalStrut(64);
component3 = Box.createVerticalStrut(97);
component1 = Box.createVerticalStrut(84);
this.setLayout(borderLayout1);
jSplitPane.setLeftComponent(jPanel1);
materialButton.setMaximumSize(new Dimension(60, 60));
materialButton.setMinimumSize(new Dimension(60, 60));
materialButton.setToolTipText("原材料库");
materialButton.setSelected(true);
materialButton.setIcon(materialIcon);
materialButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
materialButton_actionPerformed(e);
}
});
jPanel1.setLayout(boxLayout21);
boxLayout21.setAxis(BoxLayout.Y_AXIS);
productButton.setMaximumSize(new Dimension(60, 60));
productButton.setMinimumSize(new Dimension(60, 60));
productButton.setPreferredSize(new Dimension(60, 60));
productButton.setToolTipText("成品库");
productButton.setIcon(productIcon);
productButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
productButton_actionPerformed(e);
}
});
jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT); // updateButton.setMinimumSize(new Dimension(83, 40));
statisticButt.setMaximumSize(new Dimension(100, 50));
statisticButt.setMinimumSize(new Dimension(100, 50));
statisticButt.setPreferredSize(new Dimension(100, 40));
statisticButt.setMargin(new Insets(2, 2, 2, 2));
statisticButt.setVerticalTextPosition(AbstractButton.CENTER);
statisticButt.setText("统计查询");
statisticButt.setIcon(updateIcon);
statisticButt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
updateButton_actionPerformed(e);
}
});
controlPanel.setLayout(gridBagLayout2);
this.add(jSplitPane, BorderLayout.CENTER);
jSplitPane.add(jPanel1, JSplitPane.TOP);
jPanel1.add(component1, null);
jPanel1.add(materialButton, null);
jPanel1.add(component2, null);
jPanel1.add(productButton, null);
jPanel1.add(component3, null);
jSplitPane.add(jSplitPane1, JSplitPane.BOTTOM);
jSplitPane1.add(controlPanel, JSplitPane.TOP);
jSplitPane1.add(subPanel, JSplitPane.BOTTOM);
// tablePanel.tbModel.addRow(new String[]{"hhhhhh","hhhhhh","hhhhh","hhhh","hhhhh"});
if (type == Type.MATERIALMANAGE) {
label = new JLabel(" 原材料库统计管理页面", JLabel.LEFT);
}
else if (type == Type.PRODUCTMANAGE) {
label = new JLabel(" 成品库统计管理页面", JLabel.LEFT);
}
label.setForeground(Color.blue);
label.setFont(new Font("宋体", Font.BOLD, 15));
subPanel.add(label, BorderLayout.NORTH);
subPanel.add(tablePanel, BorderLayout.CENTER);
buttonGroup1.add(materialButton);
buttonGroup1.add(productButton);
controlPanel.add(statisticButt, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(2, 114, 0, 101), 0, 0));
}
private void selectButton_actionPerformed(ActionEvent e) {
if (this.type == Type.MATERIALMANAGE) {
JDialog dialog = new StatisticDialog(frame, this, true);
dialog.setVisible(true);
}
else if (this.type == Type.PRODUCTMANAGE) {
//添加product成品库的页面的内容
// JDialog productSelectDialog = new ProductSelectDialog(frame, this, true);
// productSelectDialog.setVisible(true);
}
}
void materialButton_actionPerformed(ActionEvent e) {
setType(Type.MATERIALMANAGE);
subPanel.remove(label);
if (type == Type.MATERIALMANAGE) {
label = new JLabel(" 原材料库统计管理页面", JLabel.LEFT);
}
else if (type == Type.PRODUCTMANAGE) {
label = new JLabel(" 成品库统计管理页面", JLabel.LEFT);
}
label.setForeground(Color.blue);
label.setFont(new Font("宋体", Font.BOLD, 15));
subPanel.add(label, BorderLayout.NORTH);
resetTable();
validate();
}
private void setType(int type) {
this.type = type;
}
void productButton_actionPerformed(ActionEvent e) {
setType(Type.PRODUCTMANAGE);
subPanel.remove(label);
if (type == Type.MATERIALMANAGE) {
label = new JLabel(" 原材料库统计管理页面", JLabel.LEFT);
}
else if (type == Type.PRODUCTMANAGE) {
label = new JLabel(" 成品库统计管理页面", JLabel.LEFT);
}
label.setForeground(Color.blue);
label.setFont(new Font("宋体", Font.BOLD, 15));
subPanel.add(label, BorderLayout.NORTH);
resetTable();
// materialButton.setBackground(Color.red);
// productButton.setBackground(Color.green);
validate();
}
void updateButton_actionPerformed(ActionEvent e) {
if (this.type == Type.MATERIALMANAGE) {
JDialog dialog = new StatisticDialog(frame, this, true);
updateDialog.setVisible(true);
}
else if (this.type == Type.PRODUCTMANAGE) {
//添加product成品页面的内容
// JDialog updateDialog = new ProductUpdateDialog(frame, this, true);
// updateDialog.setVisible(true);
}
}
private void resetTable() {
int rowCount = this.tablePanel.tbModel.getRowCount();
int colCount = this.tablePanel.tbModel.getColumnCount();
Vector colName = new Vector();
for (int i = 0; i < rowCount; i++)
this.tablePanel.tbModel.removeRow(0);
for (int i = 0; i < rowCount; i++)
colName.add(" ");
this.tablePanel.tbModel.setColumnIdentifiers(colName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -