Java tutorial
/* * Created by JFormDesigner on Wed May 27 20:25:12 CEST 2015 */ package cz.nn.copytables.gui; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; import org.apache.commons.lang.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.util.ResourceBundle; /** * @author unknown */ public class CopyTablesGUI extends JPanel { private Logger logger = LoggerFactory.getLogger(CopyTablesGUI.class); public CopyTablesGUI() { initComponents(); } private void menuItemConfigActionPerformed(ActionEvent e) { logger.info("menuItem4"); // TODO add your code here } private void menuItemCloseFileActionPerformed(ActionEvent e) { logger.info("menuItem3"); // TODO add your code here } private void menuItemOpenFileActionPerformed(ActionEvent e) { logger.info("menuItem2"); // TODO add your code here } private void menuHelpMouseClicked(MouseEvent e) { logger.info("menuHelpMouseClicked"); } private void menuItemHelpActionPerformed(ActionEvent e) { String title = "HELP"; String message = "Help"; try { showDialog(title, message); } catch (Exception ex) { showErrorPane(ex.getMessage(), ExceptionUtils.getFullStackTrace(ex)); } } private void menuItemAboutActionPerformed(ActionEvent e) { String title = "ABOUT"; String message = "About"; try { showDialog(title, message); } catch (Exception ex) { showErrorPane(ex.getMessage(), ExceptionUtils.getFullStackTrace(ex)); } } private void showDialog(String title, String message) { JOptionPane pane = new JOptionPane(message, JOptionPane.INFORMATION_MESSAGE); JDialog dialog = pane.createDialog(this, title); dialog.setAlwaysOnTop(true); dialog.setVisible(true); logger.info("setVisible"); } void showErrorPane(String title, String msg) { logger.error(msg); JOptionPane pane = new JOptionPane(msg, JOptionPane.ERROR_MESSAGE); JDialog dialog = pane.createDialog("Application says: " + title); dialog.setAlwaysOnTop(true); dialog.setVisible(true); } private void menuItem2ActionPerformed(ActionEvent e) { // TODO add your code here } private void menuItem3ActionPerformed(ActionEvent e) { // TODO add your code here } private void menuItem4ActionPerformed(ActionEvent e) { // TODO add your code here } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Rudolf Rada ResourceBundle bundle = ResourceBundle.getBundle("locale"); menuBar = new JMenuBar(); menuFile = new JMenu(); menuItemOpenFile = new JMenuItem(); menuItemCloseFile = new JMenuItem(); menuItemConfig = new JMenuItem(); menuHelp = new JMenu(); menuItemHelp = new JMenuItem(); menuItemAbout = new JMenuItem(); CellConstraints cc = new CellConstraints(); //======== this ======== setBackground(new Color(204, 255, 204)); // JFormDesigner evaluation mark setBorder( new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); setLayout(new FormLayout("default", "default, $lgap, default")); //======== menuBar ======== { //======== menuFile ======== { menuFile.setText(bundle.getString("CopyTablesGUI.menuFile.text")); //---- menuItemOpenFile ---- menuItemOpenFile.setText(bundle.getString("CopyTablesGUI.menuItemOpenFile.text")); menuItemOpenFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { menuItem2ActionPerformed(e); } }); menuFile.add(menuItemOpenFile); //---- menuItemCloseFile ---- menuItemCloseFile.setText(bundle.getString("CopyTablesGUI.menuItemCloseFile.text")); menuItemCloseFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { menuItem3ActionPerformed(e); } }); menuFile.add(menuItemCloseFile); //---- menuItemConfig ---- menuItemConfig.setText(bundle.getString("CopyTablesGUI.menuItemConfig.text")); menuItemConfig.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { menuItem4ActionPerformed(e); } }); menuFile.add(menuItemConfig); } menuBar.add(menuFile); //======== menuHelp ======== { menuHelp.setText(bundle.getString("CopyTablesGUI.menuHelp.text")); //---- menuItemHelp ---- menuItemHelp.setText(bundle.getString("CopyTablesGUI.menuItemHelp.text")); menuItemHelp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { menuItemHelpActionPerformed(e); } }); menuHelp.add(menuItemHelp); //---- menuItemAbout ---- menuItemAbout.setText(bundle.getString("CopyTablesGUI.menuItemAbout.text")); menuItemAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { menuItemAboutActionPerformed(e); } }); menuHelp.add(menuItemAbout); } menuBar.add(menuHelp); } add(menuBar, cc.xy(1, 1)); // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // Generated using JFormDesigner Evaluation license - Rudolf Rada private JMenuBar menuBar; private JMenu menuFile; private JMenuItem menuItemOpenFile; private JMenuItem menuItemCloseFile; private JMenuItem menuItemConfig; private JMenu menuHelp; private JMenuItem menuItemHelp; private JMenuItem menuItemAbout; // JFormDesigner - End of variables declaration //GEN-END:variables }