java 2 有新的封装类。 
JOptionPane
Look first.

解决方案 »

  1.   

    Examples: Show an error dialog that displays the message, 'alert': JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE); Show an internal information dialog with the message, 'information': JOptionPane.showInternalMessageDialog(frame, "information","information", JOptionPane.INFORMATION_MESSAGE);Show an information panel with the options yes/no and message 'choose one': JOptionPane.showConfirmDialog(null, 
    "choose one", "choose one", JOptionPane.YES_NO_OPTION);Show an internal information dialog with the options yes/no/cancel and message 'please choose one' and title information: JOptionPane.showInternalConfirmDialog(frame, 
    "please choose one", "information",
    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);Show a warning dialog with the options OK, CANCEL, title 'Warning', and message 'Click OK to continue': Object[] options = { "OK", "CANCEL" };
    JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning", 
    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
    null, options, options[0]);Show a dialog asking the user to type in a String: String inputValue = JOptionPane.showInputDialog("Please input a value"); Show a dialog asking the user to select a String: Object[] possibleValues = { "First", "Second", "Third" };
    Object selectedValue = JOptionPane.showInputDialog(null, 
    "Choose one", "Input",
    JOptionPane.INFORMATION_MESSAGE, null,
    possibleValues, possibleValues[0]);
      

  2.   

    import javax.swing.*;
    然后JOptionPane.showInformationDialog(参数);
        JOptionPane.showMessageDialog(参数);
    可以show很多形式的对话框.不过也有JDialog可用
      

  3.   

    import javax.swing.*;
    然后JOptionPane.showInformationDialog(参数);
        JOptionPane.showMessageDialog(参数);
    可以show很多形式的对话框.不过也有JDialog可用
      

  4.   

    如果你愿意可以用这样一个类(声明这不是我写的,只是用过):
    public class AboutDialog extends Dialog { public AboutDialog(Frame parent, boolean modal)
    {
    super(parent, modal);
            

    setLayout(null);
    setSize(249,150);
    setVisible(false);
    label1.setText("yourLableCation");
    add(label1);
    label1.setBounds(40,35,166,21);
    okButton.setLabel("yourButtonName");
    add(okButton);
    okButton.setBounds(95,85,66,27);
    setTitle("yourDiallogTitle");

            

    SymWindow aSymWindow = new SymWindow();
    this.addWindowListener(aSymWindow);
    SymAction lSymAction = new SymAction();
    okButton.addActionListener(lSymAction);
    }
        
    public AboutDialog(Frame parent, String title, boolean modal)
    {
    this(parent, modal);
    setTitle(title);
    } public void addNotify()
    {
    // Record the size of the window prior to calling parents addNotify.
                    Dimension d = getSize(); super.addNotify(); // Only do this once.
    if (fComponentsAdjusted)
    return; // Adjust components according to the insets
    Insets insets = getInsets();
    setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
    Component components[] = getComponents();
    for (int i = 0; i < components.length; i++)
    {
    Point p = components[i].getLocation();
    p.translate(insets.left, insets.top);
    components[i].setLocation(p);
    } // Used for addNotify check.
    fComponentsAdjusted = true;
    } public void setVisible(boolean b)
    {
        if (b)
        {
         Rectangle bounds = getParent().getBounds();
         Rectangle abounds = getBounds();     setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
          bounds.y + (bounds.height - abounds.height)/2);
        } super.setVisible(b);
    } //{{DECLARE_CONTROLS
    java.awt.Label label1 = new java.awt.Label();
    java.awt.Button okButton = new java.awt.Button();
    //}}
        
        // Used for addNotify check.
    boolean fComponentsAdjusted = false; class SymAction implements java.awt.event.ActionListener
    {
    public void actionPerformed(java.awt.event.ActionEvent event)
    {
    Object object = event.getSource();
    if (object == okButton)
    okButton_ActionPerformed(event);
    }
    } void okButton_ActionPerformed(java.awt.event.ActionEvent event)
    {
    // to do: code goes here.
     
    okButton_ActionPerformed_Interaction1(event);
    }
    void okButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
    {
    try {
    this.dispose();
    } catch (Exception e) {
    }
    }
    class SymWindow extends java.awt.event.WindowAdapter
    {
    public void windowClosing(java.awt.event.WindowEvent event)
    {
    Object object = event.getSource();
    if (object == AboutDialog.this)
    AboutDialog_WindowClosing(event);
    }
    } void AboutDialog_WindowClosing(java.awt.event.WindowEvent event)
    {
    // to do: code goes here.
     
    AboutDialog_WindowClosing_Interaction1(event);
    }
    void AboutDialog_WindowClosing_Interaction1(java.awt.event.WindowEvent event)
    {
    try {
    this.dispose();
    } catch (Exception e) {
    }
    }}
    /////////////////
    你可以添加你喜欢的构造方法,比如让Button,Lable的caption 是你要求的等,这样你可以做些稍微有个性的东西在其中。
    楼上说的JOptionPane.showMessageDialog(参数);也简单可行。
    供你参考!