Mega Code Archive

 
Categories / Java / Swing JFC
 

Create simple about dialog

import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class SimpleAboutDialog extends JDialog {   public SimpleAboutDialog(JFrame parent) {     super(parent, "About Dialog", true);     Box b = Box.createVerticalBox();     b.add(Box.createGlue());     b.add(new JLabel("Java source code, product and article"));     b.add(new JLabel("By Java source and support"));     b.add(new JLabel("At www.rntsoft.com"));     b.add(Box.createGlue());     getContentPane().add(b, "Center");     JPanel p2 = new JPanel();     JButton ok = new JButton("Ok");     p2.add(ok);     getContentPane().add(p2, "South");     ok.addActionListener(new ActionListener() {       public void actionPerformed(ActionEvent evt) {         setVisible(false);       }     });     setSize(250, 150);   }   public static void main(String[] args) {     JDialog f = new SimpleAboutDialog(new JFrame());     f.show();   } }