你这个我没有调出来。给你一段调出来了。import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class MainClass extends JFrame {  public MainClass(String title) {
    super(title);
    setDefaultCloseOperation(EXIT_ON_CLOSE);    final JDesktopPane desk = new JDesktopPane();
    setContentPane(desk);
    JOptionPane.showInternalMessageDialog(desk, "The End");
  }  // A simple test program
  public static void main(String[] args) {
    MainClass td = new MainClass("Desktop");
    td.setSize(350, 250);
    td.setVisible(true);
  }
}

解决方案 »

  1.   

    换一下放进去的对像,把jp换成jb:import java.awt.event.ActionListener; 
    import java.awt.event.ActionEvent; 
    import javax.swing.JFrame; 
    import javax.swing.JPanel; 
    import javax.swing.JButton; 
    import javax.swing.JOptionPane; public class InternalA { 
        public static void main(String[] args) { 
            DialogF df = new DialogF(); 
            df.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            df.setVisible(true); 
        } 

    class DialogF extends JFrame { 
        public DialogF() { 
            setTitle("Dialog"); 
            setSize(200, 300); 
            
            final JPanel jp = new JPanel();
            final JButton jb = new JButton("OK"); 
            jb.addActionListener(new ActionListener() { 
                public void actionPerformed(ActionEvent e) { 
                    JOptionPane.showInternalMessageDialog(jb, "bu chu lai", 
                        "eeee", JOptionPane.WARNING_MESSAGE); 
                } 
            }); 
            jp.add(jb); 
            add(jp); 
        } 
      

  2.   

    3楼能给我讲讲 showInternalMessageDialog(jb, 这里放进去jb 和 jp 的具体区别吗?
    最好讲讲 放进去各种不同component 的效果 谢谢
      

  3.   

    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JButton;
    import javax.swing.JOptionPane;public class InternalA {
    public static void main(String[] args) {
    DialogF df = new DialogF();
    df.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    df.setVisible(true);
    }
    }class DialogF extends JFrame {
    public DialogF() {
    setTitle("Dialog");
    setSize(300, 200); final JPanel jp = new JPanel();
    JButton jb = new JButton("OK");
    add(jp);
    jb.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    JOptionPane.showInternalMessageDialog(jp.getParent(), "bu chu lai", "-_-#",
    JOptionPane.WARNING_MESSAGE);
    }
    });
    jp.add(jb);
    }
    }
    //改成这样子.//第一个参数Component parentComponent  显示在哪个容器里面
    @param parentComponent determines the Frame
          in which the dialog is displayed; if null
          or if the parentComponent has no
          Framea default Frame is used