有个Dialog类,你可以用上那个
网上也很多

解决方案 »

  1.   

    写个dialog类,在想要调用的地方new一下,然后用dialog的show方法就行了。
      

  2.   

    不会吧,这么简单,写一个dialog,在构造里写上show或者setVisible(true),到时候new一下就行了
      

  3.   

    写一个Dialog类的子类A,在要调用这个类的那个类(容器)中生成一个A的对象a,然后将a.show()就行了。
      

  4.   

    在定义类晨加下implements 接口名就行了。还要加上import java.XXX.event.*;
      

  5.   


    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2004</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */public class Frame1 extends JFrame {
      JButton jButton1 = new JButton();public static void main(String[] args)
    {
        Frame1 test=new Frame1();
        test.show();
    }
      public Frame1() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      private void jbInit() throws Exception {
        jButton1.setBounds(new Rectangle(99, 81, 83, 28));
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setBounds(50,50,400,200);
        jButton1.setText("jButton1");
        jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));
        this.getContentPane().setLayout(null);
        this.getContentPane().add(jButton1, null);
      }  void jButton1_actionPerformed(ActionEvent e) {
        JOptionPane.showMessageDialog(this,"a message box is shown");
      }
    }class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener {
      Frame1 adaptee;  Frame1_jButton1_actionAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
      }
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
      }
    }新建文件Frame1.java,粘上代码,直接运行即可
      

  6.   

    showConfirmDialog
    public static int showConfirmDialog(Component parentComponent,
                                        Object message)
                                 throws HeadlessExceptionBrings up a dialog with the options Yes,
     No and Cancel; with the
     title, Select an Option.Parameters:parentComponent - determines the Frame in which the
    dialog is displayed; if null,
    or if the parentComponent has no
    Frame, a 
                      default Frame is usedmessage - the Object to display
    Returns:an integer indicating the option selected by the user
    Throws:
    HeadlessException - if
       GraphicsEnvironment.isHeadless returns
       true
      

  7.   

    showMessageDialog
    public static void showMessageDialog(Component parentComponent,
                                         Object message)
                                  throws HeadlessExceptionBrings up an information-message dialog titled "Message".Parameters:parentComponent - determines the Frame in
    which the dialog is displayed; if null,
    or if the parentComponent has no
    Frame, a default Frame is usedmessage - the Object to display
    Throws:
    HeadlessException - if
       GraphicsEnvironment.isHeadless returns
       true