Java tutorial
package anl.verdi.gui; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dialog; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.WindowConstants; import org.jdesktop.swingx.JXHeader; import anl.verdi.util.VersionInfo; import com.jgoodies.forms.factories.Borders; import com.jgoodies.forms.factories.FormFactory; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.ColumnSpec; import com.jgoodies.forms.layout.FormLayout; import com.jgoodies.forms.layout.RowSpec; /** * @author User #2 */ public class AboutDialog extends JDialog { private static final long serialVersionUID = -8261331914096627049L; public AboutDialog(Frame owner) { super(owner); initComponents(); xHeader1.setDescription("Version: " + VersionInfo.getVersion() + " " + VersionInfo.getDate()); } public AboutDialog(Dialog owner) { super(owner); initComponents(); xHeader1.setDescription("Version: " + VersionInfo.getVersion() + " " + VersionInfo.getDate()); } private void okButtonActionPerformed(ActionEvent e) { this.dispose(); } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license dialogPane = new JPanel(); contentPanel = new JPanel(); scrollPane1 = new JScrollPane(); xHeader1 = new JXHeader(); buttonBar = new JPanel(); okButton = new JButton(); CellConstraints cc = new CellConstraints(); //======== this ======== setTitle("About VERDI"); setResizable(false); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); //======== dialogPane ======== { dialogPane.setBorder(Borders.DIALOG_BORDER); dialogPane.setLayout(new BorderLayout()); //======== contentPanel ======== { contentPanel.setLayout(new FormLayout("default:grow", "default")); //======== scrollPane1 ======== { //---- xHeader1 ---- xHeader1.setTitle("Visual Environment For Rich Data Interpretation (VERDI)"); xHeader1.setDescription("Version 1.0 06062007\n"); scrollPane1.setViewportView(xHeader1); } contentPanel.add(scrollPane1, cc.xy(1, 1)); } dialogPane.add(contentPanel, BorderLayout.CENTER); //======== buttonBar ======== { buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER); // 2014 RowSpec[] aRowSpec = RowSpec.decodeSpecs("pref"); buttonBar.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.GLUE_COLSPEC, FormFactory.BUTTON_COLSPEC }, aRowSpec)); // buttonBar.setLayout(new FormLayout( // new ColumnSpec[] { // FormFactory.GLUE_COLSPEC, // FormFactory.BUTTON_COLSPEC // }, // RowSpec.decodeSpecs("pref"))); //---- okButton ---- okButton.setText("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButtonActionPerformed(e); } }); buttonBar.add(okButton, cc.xy(2, 1)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } contentPane.add(dialogPane, BorderLayout.CENTER); pack(); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // Generated using JFormDesigner non-commercial license private JPanel dialogPane; private JPanel contentPanel; private JScrollPane scrollPane1; private JXHeader xHeader1; private JPanel buttonBar; private JButton okButton; // JFormDesigner - End of variables declaration //GEN-END:variables }