String[] relation = {" = ", " != ", " > ", " < ", " >= ", " <= "};
JComboBox cbKey = new JComboBox(DataTableModel.n);
JComboBox cbRelation = new JComboBox(relation);
JTextField tfValue = new JTextField(10);
JOptionPane optionPane = new JOptionPane("选择查询条件", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
JDialog dialog=new JDialog(this, "查询", true);
JPanel pExp = new JPanel();
pExp.add(cbKey);
pExp.add(cbRelation);
pExp.add(tfValue);
JPanel pDialog = new JPanel(new BorderLayout());
dialog.setContentPane(pDialog);
dialog.getContentPane().add("North", pExp);
   dialog.getContentPane().add("South", optionPane);
   dialog.pack();
   dialog.setVisible(true);

解决方案 »

  1.   

    我是楼主,不好意思还没写完就发出去了想问的是能否在JDialog添加JComboBox、JTextField、JOptionPane等等混合使用,该如何混合使用。上面那段程序如何改进?我按"是""否"都没反应.
    JComboBox   cbKey   =   new   JComboBox(DataTableModel.n); 中是一些关键字
    JTextField   tfValue   =   new   JTextField(10); 是比较的值
    不想写button了,但又找不到怎么用.
      

  2.   

    如果添加那么多东西,你直接再写个JFrame嘛