JDialog Problem: How to make a simple "About" dialog box?

Hi, anyone can try me out the problem, how to make a simple "About" dialog box? I try to click on the MenuBar item, then request it display a JDialog, how? Following is my example code, what wrong code inside?

** Main.java**

============================

publcclass Mainextends JFrame{

public Main(){

super();

setJMenuBar();

initialize();

}

publicvoid setJMenuBar()

{

JMenuBar menubar =new JMenuBar();

setJMenuBar(menubar);

JMenu menu1 =new JMenu("File");

JMenuItem item =new JMenuItem("About");

item.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent ae){

// About about = new About(this);

// about.show();

}

});

menu1.add(item);

menubar.add(menu1);

}

publicstaticvoid main(String args[]){

Main main =new Main();

}

}

** About.java**

=============================

import java.awt.*;

import javax.swing.*;

publicclass Aboutextends JDialog{

JPanel jp_top, jp_center, jp_bottom;

public About(JFrame owner){

super(owner);

setDefaultCloseOperation( DISPOSE_ON_CLOSE );

Image img = Toolkit.getDefaultToolkit().getImage(DateChooser.class.getResource("Duke.gif"));

setIconImage( img );

setSize(500,800);

Container contentPane = getContentPane();

contentPane.setLayout(new BorderLayout());

contentPane.add(getTop(), BorderLayout.NORTH);

contentPane.add(getCenter(), BorderLayout.CENTER);

contentPane.add(getBottom(), BorderLayout.SOUTH);

setResizable(false);

pack();

setVisible(true);

}

public JPanel getTop(){

jp_top =new JPanel();

return jp_top;

}

public JPanel getCenter(){

jp_center =new JPanel();

return jp_center;

}

public JPanel getBottom(){

jp_bottom =new JPanel();

jp_bottom.setLayout(new BoxLayout(jp_bottom, BoxLayout.X_AXIS));

JButton jb =new JButton("OK");

jp_bottom.add(jb);

return jp_bottom;

}

}

[4099 byte] By [jiong_ronga] at [2007-11-27 9:41:54]
# 1

item.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

//About about = new About(this);

About about = new About(Main.this);

}

});

setIconImage( img );//won't work - dialogs get their icon from the parent

Michael_Dunna at 2007-7-12 23:44:14 > top of Java-index,Desktop,Core GUI APIs...
# 2

Code looks reasonable except

a) the code in the actionPerformed is commment out

b) the owner of the dialog should be the frame

If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

camickra at 2007-7-12 23:44:14 > top of Java-index,Desktop,Core GUI APIs...
# 3
Why the JDialog is also cannot on screen?
jiong_ronga at 2007-7-12 23:44:14 > top of Java-index,Desktop,Core GUI APIs...
# 4
cannot what?if your question is related to sizesetSize(500,800);later, in the constructor, you have pack(), which kills the above line
Michael_Dunna at 2007-7-12 23:44:14 > top of Java-index,Desktop,Core GUI APIs...
# 5
Thank You to Michael_Dunn, it works. and thank twice again, thank you very much.
jiong_ronga at 2007-7-12 23:44:14 > top of Java-index,Desktop,Core GUI APIs...