⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userbasedialog.java

📁 好的超市源码供大家下载
💻 JAVA
字号:
package view.dialog.basedialog;

import java.awt.GridBagLayout;
import java.awt.event.MouseAdapter;
import java.util.Iterator;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import view.com.GBC;
import view.com.getcomponent.button.GetButton;
import vo.UserPwdVo;
import action.implementclass.mouseaction.UserTableInfoAction;
import dao.UserPwdDao;

/**
 * 用户情况基类
 * @author linfeng
 *
 */
public class UserBaseDialog extends JDialog {

  /**
   * user_id 用户编号
   * user_name 用户姓名
   * user_pwd 密码
   * phone 用户电话
   * user_type 用户类型
   * btnPanel 按钮面板
   * panel 用户面板
   * table 用户表格
   * button 按钮数组
   * names 字符串数组
   * tableData 字符串对象
   * mouseAction 鼠标事件
   */
  public static JTextField user_id, user_name, user_pwd, phone;
  protected static JComboBox user_type;
  private JPanel btnPanel;
  private JPanel panel;
  public static JTable table;
  protected JButton[] button;
  private String[] names = { "确定", "重置", "取消", "刷新" };
  public static String[] tableData;
  private MouseAdapter mouseAction;
  private String[] icon={"icon\\button\\确定.GIF","icon\\button\\重置.GIF","icon\\button\\取消.GIF","icon\\button\\刷新.GIF"};
  private String[] argActionCommand = { "确定", "重置", "取消", "刷新" };

  /**
   * 初始化各种组件
   */
  public void initialText() {
    user_id = new JTextField(12);
    user_name = new JTextField(12);
    user_pwd = new JTextField(12);
    user_type = new JComboBox();
    user_type.addItem("系统管理员");
    user_type.addItem("POS端用户");
    phone = new JTextField(12);

  }

  /**
   * 获得用户面板
   * @return panel 用户面板
   */
  public JPanel getPanel() {

    panel = new JPanel();
    initialText();
    panel.setLayout(new GridBagLayout());

    panel.add(new JLabel("用户编号"), new GBC(1, 0).setAnchor(GBC.EAST));
    panel.add(this.user_id, new GBC(2, 0).setInset(7).setWeight(3, 0));

    panel.add(new JLabel("用户名称"), new GBC(1, 1).setAnchor(GBC.EAST));
    panel.add(this.user_name, new GBC(2, 1).setInset(7).setWeight(3, 0));

    panel.add(new JLabel("用户密码"), new GBC(1, 2).setAnchor(GBC.EAST));
    panel.add(this.user_pwd, new GBC(2, 2).setInset(3).setWeight(3, 0));

    panel.add(new JLabel("用户类型"), new GBC(1, 3).setAnchor(GBC.EAST));
    panel.add(this.user_type, new GBC(2, 3).setInset(7).setWeight(3, 0));

    panel.add(new JLabel("用户电话"), new GBC(1, 4).setAnchor(GBC.EAST));
    panel.add(this.phone, new GBC(2, 4).setInset(7).setWeight(3, 0));

    return panel;
  }

  /**
   * 获得滚动条面板
   * @return sp 滚动条面板
   */
  public JScrollPane getJScrollPanel() {
    JScrollPane sp = new JScrollPane(getJTable());
    return sp;
  }

  /**
   * 获得用户表格
   * @return table 表格
   */
  public JTable getJTable() {
    if (table == null) {
      Object[][] data = {};
      String[] name = { "用户编号", "用户名称", "用户密码", "用户类型", "用户电话" };
      DefaultTableModel model = new DefaultTableModel(data, name) {
        public boolean isCellEditable(int row, int column) {
          return false;
        }
      };
      Vector v = new UserPwdDao().getUserInfo();
      Iterator iter = v.iterator();
      while (iter.hasNext()) {
        UserPwdVo value = (UserPwdVo) iter.next();
        Object[] objData = { new Integer(value.getUser_id()),
            value.getUser_name(), value.getPassword(), value.getUser_type(),
            new Long(value.getPhone()), };
        model.addRow(objData);
      }
      table = new JTable(model);
      mouseAction = new UserTableInfoAction(this);
      table.addMouseListener(mouseAction);
    }
    return table;
  }

  /**
   * 获得按钮面板
   * @return btnPanel 按钮面板
   */
  public JPanel getBtnPanel() {
    btnPanel = new JPanel();
    button = new JButton[names.length];
    button = new GetButton().getButton(button, names, icon, argActionCommand);
    btnPanel.add(button[0]);
    btnPanel.add(button[1]);
    btnPanel.add(button[2]);
    btnPanel.add(button[3]);
    btnPanel.setBorder(BorderFactory.createTitledBorder("按钮组"));
    return btnPanel;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -