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

📄 setdialog.java.svn-base

📁 通讯采集软件
💻 SVN-BASE
字号:
package collector.gui.view;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SetDialog
    extends JDialog {
  JPanel jPanel1 = new JPanel();
  BorderLayout borderLayout1 = new BorderLayout();
  JPanel jPanel3 = new JPanel();
  JComboBox TypeComboBox = new JComboBox();
  JLabel jLabel1 = new JLabel();
  JPanel jPanel2 = new JPanel();
  JButton ConfirmButton = new JButton();
  JButton CancelButton = new JButton();
  FlowLayout flowLayout2 = new FlowLayout();
  FlowLayout flowLayout1 = new FlowLayout();
  private DataPursueFrame parentframe = null;

  public SetDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    parentframe = (DataPursueFrame) parent;
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    initTypeComboBox();
    this.updateview();
    int count = this.TypeComboBox.getItemCount();
    for (int i = 0; i < count; i++) {
      System.out.println("count: " + i + " = " +
                         this.TypeComboBox.getItemAt(i).toString());
    }
  }

  public SetDialog() {
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    initTypeComboBox();
    this.updateview();
  }

  private void jbInit() throws Exception {
    pack();
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().
        getScreenSize();
    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    this.setTitle("选中");
    setSize(new Dimension(365, 103));
    setLocation( (screenSize.width - 344) / 2, (screenSize.height - 214) / 2);
    jPanel1.setLayout(borderLayout1);
    TypeComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
    TypeComboBox.setMinimumSize(new Dimension(120, 22));
    TypeComboBox.setPreferredSize(new Dimension(120, 22));
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
    jLabel1.setText("状态计量单元");
    jPanel3.setLayout(flowLayout2);
    jPanel2.setDebugGraphicsOptions(0);
    jPanel2.setOpaque(true);
    jPanel2.setPreferredSize(new Dimension(10, 40));
    jPanel2.setInputVerifier(null);
    jPanel2.setLayout(flowLayout1);
    ConfirmButton.setFont(new java.awt.Font("Dialog", 0, 12));
    ConfirmButton.setMaximumSize(new Dimension(70, 24));
    ConfirmButton.setMinimumSize(new Dimension(70, 24));
    ConfirmButton.setPreferredSize(new Dimension(70, 24));
    ConfirmButton.setText("确定");
    ConfirmButton.addActionListener(new SetDialog_ConfirmButton_actionAdapter(this));
    CancelButton.setFont(new java.awt.Font("Dialog", 0, 12));
    CancelButton.setMaximumSize(new Dimension(70, 24));
    CancelButton.setMinimumSize(new Dimension(70, 24));
    CancelButton.setPreferredSize(new Dimension(70, 24));
    CancelButton.setText("取消");
    CancelButton.addActionListener(new SetDialog_CancelButton_actionAdapter(this));
    jPanel3.setDebugGraphicsOptions(0);
    jPanel3.setMaximumSize(new Dimension(32767, 32767));
    jPanel3.setMinimumSize(new Dimension(241, 30));
    jPanel3.setPreferredSize(new Dimension(241, 30));
    flowLayout2.setHgap(10);
    flowLayout2.setVgap(7);
    flowLayout1.setVgap(10);
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jPanel3, BorderLayout.CENTER);
    jPanel3.add(TypeComboBox, null);
    jPanel3.add(jLabel1, null);
    jPanel1.add(jPanel2, BorderLayout.SOUTH);
    jPanel2.add(ConfirmButton, null);
    jPanel2.add(CancelButton, null);
  }

  private void initTypeComboBox() {
    DefaultComboBoxModel m_model = new DefaultComboBoxModel();
    m_model.addElement(new String("正常"));
    m_model.addElement(new String("延时"));
    m_model.addElement(new String("故障"));
    m_model.addElement(new String("未知"));
    TypeComboBox.setModel(m_model);
    TypeComboBox.setSelectedIndex( -1);
    System.out.println("already add combo item");
  }

  public void updateview() {
    this.validate();
    this.repaint();
  }

  public static void main(String[] args) {
    SetDialog SetDialog1 = new SetDialog();
    SetDialog1.show();
  }

  void ConfirmButton_actionPerformed(ActionEvent e) {
    Object obj = this.TypeComboBox.getSelectedItem();
    String m_str = (String) obj;
    if (m_str.equals("正常")) {
      this.parentframe.select_type = 0;
    }
    else if (m_str.equals("延时")) {
      this.parentframe.select_type = 1;
    }
    else if (m_str.equals("故障")) {
      this.parentframe.select_type = 2;
    }
    else if (m_str.equals("未知")) {
      this.parentframe.select_type = -1;
    }
    else {
      this.parentframe.select_type = -1;
    }
    this.dispose();
  }

  void CancelButton_actionPerformed(ActionEvent e) {
    this.dispose();
  }
}

class SetDialog_ConfirmButton_actionAdapter
    implements java.awt.event.ActionListener {
  SetDialog adaptee;

  SetDialog_ConfirmButton_actionAdapter(SetDialog adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.ConfirmButton_actionPerformed(e);
  }
}

class SetDialog_CancelButton_actionAdapter
    implements java.awt.event.ActionListener {
  SetDialog adaptee;

  SetDialog_CancelButton_actionAdapter(SetDialog adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.CancelButton_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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