use JOptionPane.showInputDialog()

解决方案 »

  1.   

    那个好像只有一个 textField吧我想有多个怎么办??谢了!!
      

  2.   

    那你就干脆用JDialog,然后你就可以在上面加你想加的Component!
      

  3.   

    对,继承一个JDialog,给个例子你
    class AboutDialog
          extends JDialog
          implements ActionListener {    public AboutDialog(Frame parent, String title, String message) {
          super(parent, title, true);
          if (parent != null) {
            Dimension parentSize = parent.getSize();
            Point p = parent.getLocation();
            setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
          }
          JPanel messagePane = new JPanel();
          messagePane.add(new JLabel(message));
          getContentPane().add(messagePane);      JPanel buttonPane = new JPanel();
          JButton button = new JButton("OK");
          buttonPane.add(button);
          button.addActionListener(this);
          getContentPane().add(buttonPane, BorderLayout.SOUTH);
          setDefaultCloseOperation(DISPOSE_ON_CLOSE);
          this.pack();
          this.setVisible(true);
        }    public void actionPerformed(ActionEvent e) {
          this.setVisible(false);
          this.dispose();
        }
      }