在论坛里查找”焦点“。实有发现。

解决方案 »

  1.   

    //希望能对你有用.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;public class AboutDialog extends JFrame{
    JButton button = new JButton("About");

     public AboutDialog(){
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {System.exit(0);}
      });

    Container contentPane = getContentPane(); 
       contentPane.add(button,BorderLayout.CENTER);
    pack();
    setSize(300,300);//jframe
       setLocation(200,200);//jframe   button.addActionListener(new ActionListener() { 
           public void actionPerformed(ActionEvent se) { 
               try { new About().show();
               }
               catch (Exception mue) { 
                System.out.println("Error");
               }
           }
         }); }

    public static void main(String args[]){
      new AboutDialog().show();
    }
    }class About extends JDialog{
     public About(){
       setLocation(240,150);//jdialog
       setVisible(true); //jdialog
       setSize(100,100);//jdialog
     }