Example usage for javax.swing JMenuBar add

List of usage examples for javax.swing JMenuBar add

Introduction

In this page you can find the example usage for javax.swing JMenuBar add.

Prototype

public JMenu add(JMenu c) 

Source Link

Document

Appends the specified menu to the end of the menu bar.

Usage

From source file:org.thelq.stackexchange.dbimport.gui.GUI.java

public GUI(Controller passedController) {
    //Initialize logger
    logAppender = new GUILogAppender(this);

    //Set our Look&Feel
    try {//from  w w  w  .jav  a 2  s .c  o m
        if (SystemUtils.IS_OS_WINDOWS)
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        else
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.warn("Defaulting to Swing L&F due to exception", e);
    }

    this.controller = passedController;
    frame = new JFrame();
    frame.setTitle("Unified StackExchange Data Dump Importer v" + Controller.VERSION);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    //Setup menu
    JMenuBar menuBar = new JMenuBar();
    menuAdd = new JMenuItem("Add Folders/Archives");
    menuAdd.setMnemonic(KeyEvent.VK_F);
    menuBar.add(menuAdd);
    frame.setJMenuBar(menuBar);

    //Primary panel
    FormLayout primaryLayout = new FormLayout("5dlu, pref:grow, 5dlu, 5dlu, pref",
            "pref, top:pref, pref, fill:140dlu:grow, pref, fill:80dlu");
    PanelBuilder primaryBuilder = new PanelBuilder(primaryLayout)
            .border(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    //DB Config panel
    primaryBuilder.addSeparator("Database Configuration", CC.xyw(1, 1, 2));
    FormLayout configLayout = new FormLayout("pref, 3dlu, pref:grow, 6dlu, pref",
            "pref, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow");
    configLayout.setHonorsVisibility(true);
    final PanelBuilder configBuilder = new PanelBuilder(configLayout);
    configBuilder.addLabel("Server", CC.xy(1, 2), dbType = new JComboBox<DatabaseOption>(), CC.xy(3, 2));
    configBuilder.add(dbAdvanced = new JCheckBox("Show advanced options"), CC.xy(5, 2));
    configBuilder.addLabel("JDBC Connection", CC.xy(1, 4), jdbcString = new JTextField(15), CC.xyw(3, 4, 3));
    configBuilder.addLabel("Username", CC.xy(1, 6), username = new JTextField(10), CC.xy(3, 6));
    configBuilder.addLabel("Password", CC.xy(1, 8), password = new JPasswordField(10), CC.xy(3, 8));
    configBuilder.add(importButton = new JButton("Import"), CC.xywh(5, 6, 1, 3));
    //Add hidden
    JLabel dialectLabel = new JLabel("Dialect");
    dialectLabel.setVisible(false);
    configBuilder.add(dialectLabel, CC.xy(1, 10), dialect = new JTextField(10), CC.xyw(3, 10, 3));
    dialect.setVisible(false);
    JLabel driverLabel = new JLabel("Driver");
    driverLabel.setVisible(false);
    configBuilder.add(driverLabel, CC.xy(1, 12), driver = new JTextField(10) {
        @Override
        public void setText(String text) {
            if (StringUtils.isBlank(text))
                log.debug("Text is blank", new RuntimeException("Text " + text + " is blank"));
            super.setText(text);
        }
    }, CC.xyw(3, 12, 3));
    driver.setVisible(false);
    primaryBuilder.add(configBuilder.getPanel(), CC.xy(2, 2));

    //Options
    primaryBuilder.addSeparator("Options", CC.xyw(4, 1, 2));
    FormLayout optionsLayout = new FormLayout("pref, 3dlu, pref:grow", "");
    DefaultFormBuilder optionsBuilder = new DefaultFormBuilder(optionsLayout);
    optionsBuilder.append(disableCreateTables = new JCheckBox("Disable Creating Tables"), 3);
    optionsBuilder.append("Global Table Prefix", globalTablePrefix = new JTextField(7));
    optionsBuilder.append("Threads", threads = new JSpinner());
    //Save a core for the database
    int numThreads = Runtime.getRuntime().availableProcessors();
    numThreads = (numThreads != 1) ? numThreads - 1 : numThreads;
    threads.setModel(new SpinnerNumberModel(numThreads, 1, 100, 1));
    optionsBuilder.append("Batch Size", batchSize = new JSpinner());
    batchSize.setModel(new SpinnerNumberModel(500, 1, 500000, 1));
    primaryBuilder.add(optionsBuilder.getPanel(), CC.xy(5, 2));

    //Locations
    primaryBuilder.addSeparator("Dump Locations", CC.xyw(1, 3, 5));
    FormLayout locationsLayout = new FormLayout("pref, 15dlu, pref, 5dlu, pref, 5dlu, pref:grow, 2dlu, pref",
            "");
    locationsBuilder = new DefaultFormBuilder(locationsLayout, new ScrollablePanel()).background(Color.WHITE)
            .lineGapSize(Sizes.ZERO);
    locationsPane = new JScrollPane(locationsBuilder.getPanel());
    locationsPane.getViewport().setBackground(Color.white);
    locationsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    locationsPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    primaryBuilder.add(locationsPane, CC.xyw(2, 4, 4));

    //Logger
    primaryBuilder.addSeparator("Log", CC.xyw(1, 5, 5));
    loggerText = new JTextPane();
    loggerText.setEditable(false);
    JPanel loggerTextPanel = new JPanel(new BorderLayout());
    loggerTextPanel.add(loggerText);
    JScrollPane loggerPane = new JScrollPane(loggerTextPanel);
    loggerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    loggerPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    JPanel loggerPanePanel = new JPanel(new BorderLayout());
    loggerPanePanel.add(loggerPane);
    primaryBuilder.add(loggerPanePanel, CC.xyw(2, 6, 4));

    menuAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //TODO: Allow 7z files but handle corner cases
            final JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            fc.setMultiSelectionEnabled(true);
            fc.setDialogTitle("Select Folders/Archives");
            fc.addChoosableFileFilter(new FileNameExtensionFilter("Archives", "7z", "zip"));
            fc.addChoosableFileFilter(new FileFilter() {
                @Getter
                protected String description = "Folders";

                @Override
                public boolean accept(File file) {
                    return file.isDirectory();
                }
            });

            if (fc.showOpenDialog(frame) != JFileChooser.APPROVE_OPTION)
                return;

            //Add files and folders in a seperate thread while updating gui in EDT
            importButton.setEnabled(false);
            for (File curFile : fc.getSelectedFiles()) {
                DumpContainer dumpContainer = null;
                try {
                    if (curFile.isDirectory())
                        dumpContainer = new FolderDumpContainer(curFile);
                    else
                        dumpContainer = new ArchiveDumpContainer(controller, curFile);
                    controller.addDumpContainer(dumpContainer);
                } catch (Exception ex) {
                    String type = (dumpContainer != null) ? dumpContainer.getType() : "";
                    LoggerFactory.getLogger(getClass()).error("Cannot open " + type, ex);
                    String location = (dumpContainer != null) ? Utils.getLongLocation(dumpContainer) : "";
                    showErrorDialog(ex, "Cannot open " + location, curFile.getAbsolutePath());
                    continue;
                }
            }
            updateLocations();
            importButton.setEnabled(true);
        }
    });

    //Add options (Could be in a map, but this is cleaner)
    dbType.addItem(new DatabaseOption().name("MySQL 5.5.3+")
            .jdbcString("jdbc:mysql://127.0.0.1:3306/stackexchange?rewriteBatchedStatements=true")
            .dialect("org.hibernate.dialect.MySQL5Dialect").driver("com.mysql.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("PostgreSQL 8.1")
            .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange")
            .dialect("org.hibernate.dialect.PostgreSQL81Dialect").driver("org.postgresql.Driver"));
    dbType.addItem(new DatabaseOption().name("PostgreSQL 8.2+")
            .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange")
            .dialect("org.hibernate.dialect.PostgreSQL82Dialect").driver("org.postgresql.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServerDialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server 2005+")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServer2005Dialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server 2008+")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServer2008Dialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("H2").jdbcString("jdbc:h2:stackexchange")
            .dialect("org.hibernate.dialect.H2Dialect").driver("org.h2.Driver"));
    dbType.setSelectedItem(null);
    dbType.addItemListener(new ItemListener() {
        boolean shownMysqlWarning = false;

        public void itemStateChanged(ItemEvent e) {
            //Don't run this twice for a single select
            if (e.getStateChange() == ItemEvent.DESELECTED)
                return;

            DatabaseOption selectedOption = (DatabaseOption) dbType.getSelectedItem();
            if (selectedOption.name().startsWith("MySQL") && !shownMysqlWarning) {
                //Hide popup so you don't have to click twice on the dialog 
                dbType.setPopupVisible(false);
                JOptionPane.showMessageDialog(frame,
                        "Warning: Your server must be configured with character_set_server=utf8mb4"
                                + "\nOtherwise, data dumps that contain 4 byte UTF-8 characters will fail",
                        "MySQL Warning", JOptionPane.WARNING_MESSAGE);
                shownMysqlWarning = true;
            }

            setDbOption(selectedOption);
        }
    });

    //Show and hide advanced options with checkbox
    dbAdvanced.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean selected = ((JCheckBox) e.getSource()).isSelected();
            driver.setVisible(selected);
            ((JLabel) driver.getClientProperty("labeledBy")).setVisible(selected);
            dialect.setVisible(selected);
            ((JLabel) dialect.getClientProperty("labeledBy")).setVisible(selected);
        }
    });

    importButton.addActionListener(new ActionListener() {
        protected void showImportError(String error) {
            JOptionPane.showMessageDialog(frame, error, "Configuration Error", JOptionPane.ERROR_MESSAGE);
        }

        protected void showInputErrorDatabase(String error) {
            if (dbType.getSelectedItem() == null)
                showImportError("No dbType specified, " + StringUtils.uncapitalize(error));
            else
                showImportError(error);
        }

        public void actionPerformed(ActionEvent e) {
            boolean validationPassed = false;
            if (controller.getDumpContainers().isEmpty())
                showImportError("Please add dump folders/archives");
            else if (StringUtils.isBlank(jdbcString.getText()))
                showInputErrorDatabase("Must specify JDBC String");
            else if (StringUtils.isBlank(driver.getText()))
                showInputErrorDatabase("Must specify driver");
            else if (StringUtils.isBlank(dialect.getText()))
                showInputErrorDatabase("Must specify hibernate dialect");
            else
                validationPassed = true;

            if (!validationPassed)
                return;

            //Disable all GUI components so they can't change anything during processing
            setGuiEnabled(false);

            //Run in new thread
            controller.getGeneralThreadPool().execute(new Runnable() {
                public void run() {
                    try {
                        start();
                    } catch (final Exception e) {
                        //Show an error message box
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                LoggerFactory.getLogger(getClass()).error("Cannot import", e);
                                showErrorDialog(e, "Cannot import", null);
                            }
                        });
                    }
                    //Renable GUI
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            setGuiEnabled(true);
                        }
                    });
                }
            });
        }
    });

    //Done, init logger
    logAppender.init();
    log.info("Finished creating GUI");

    //Display
    frame.setContentPane(primaryBuilder.getPanel());
    frame.pack();
    frame.setMinimumSize(frame.getSize());

    frame.setVisible(true);
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Create the application.//w w  w.j  ava2s  .  co m
 * 
 * @param name
 *          the name
 */
public MainWindow(String name) {
    super(name);
    setName("mainWindow");
    setMinimumSize(new Dimension(1000, 700));

    instance = this;

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnTmm = new JMenu("tinyMediaManager");
    mnTmm.setMnemonic(KeyEvent.VK_T);
    menuBar.add(mnTmm);

    if (!Globals.isDonator()) {
        mnTmm.add(new RegisterDonatorVersionAction());
    }

    mnTmm.add(new SettingsAction());
    mnTmm.addSeparator();
    mnTmm.add(new LaunchUpdaterAction());
    mnTmm.addSeparator();
    mnTmm.add(new ExitAction());
    initialize();

    // tools menu
    JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$
    tools.setMnemonic(KeyEvent.VK_O);
    tools.add(new ClearDatabaseAction());

    JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$
    cache.setMnemonic(KeyEvent.VK_C);
    tools.add(cache);
    JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction());
    clearImageCache.setMnemonic(KeyEvent.VK_I);
    cache.add(clearImageCache);

    JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction());
    rebuildImageCache.setMnemonic(KeyEvent.VK_R);
    cache.add(rebuildImageCache);

    JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$
    tmmFolder.setMnemonic(KeyEvent.VK_I);
    tools.add(tmmFolder);
    tmmFolder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path path = Paths.get(System.getProperty("user.dir"));
            try {
                // check whether this location exists
                if (Files.exists(path)) {
                    TmmUIHelper.openFile(path);
                }
            } catch (Exception ex) {
                LOGGER.error("open filemanager", ex);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path,
                        "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() }));
            }
        }
    });

    JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$
    tmmLogs.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmLogs);
    tmmLogs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog logDialog = new LogDialog();
            logDialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            logDialog.setVisible(true);
        }
    });

    JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$
    tmmMessages.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmMessages);
    tmmMessages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog messageDialog = MessageHistoryDialog.getInstance();
            messageDialog.setVisible(true);
        }
    });

    tools.addSeparator();
    final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$
    menuWakeOnLan.setMnemonic(KeyEvent.VK_W);
    menuWakeOnLan.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuWakeOnLan.removeAll();
            for (final WolDevice device : Globals.settings.getWolDevices()) {
                JMenuItem item = new JMenuItem(device.getName());
                item.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        Utils.sendWakeOnLanPacket(device.getMacAddress());
                    }
                });
                menuWakeOnLan.add(item);
            }
        }
    });
    tools.add(menuWakeOnLan);

    // activate/deactivate WakeOnLan menu item
    tools.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            if (Globals.settings.getWolDevices().size() > 0) {
                menuWakeOnLan.setEnabled(true);
            } else {
                menuWakeOnLan.setEnabled(false);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    if (Globals.isDebug()) {
        final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$

        JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$
        trace.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
                lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE);
                MessageManager.instance.pushMessage(new Message("Trace levels set!", ""));
                LOGGER.trace("if you see that, we're now on TRACE logging level ;)");
            }
        });

        debugMenu.add(trace);
        tools.add(debugMenu);
    }

    menuBar.add(tools);

    mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_C);
    mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B);
    menuBar.add(mnTmm);

    mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_H);
    menuBar.add(mnTmm);

    mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W);
    mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O);
    mnTmm.addSeparator();

    mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A);

    menuBar.add(Box.createGlue());

    if (!Globals.isDonator()) {
        JButton btnDonate = new JButton(new DonateAction());
        btnDonate.setBorderPainted(false);
        btnDonate.setFocusPainted(false);
        btnDonate.setContentAreaFilled(false);
        menuBar.add(btnDonate);
    }

    checkForUpdate();
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

/**
 * Create the panel.//from  w ww. ja v a2  s  .c  om
 */
public MoviePanel() {
    super();
    // load movielist
    LOGGER.debug("loading MovieList");
    movieList = MovieList.getInstance();
    sortedMovies = new SortedList<>(GlazedListsSwing.swingThreadProxyList(movieList.getMovies()),
            new MovieComparator());
    sortedMovies.setMode(SortedList.AVOID_MOVING_ELEMENTS);

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("500px:grow"), }));

    splitPaneHorizontal = new JSplitPane();
    splitPaneHorizontal.setContinuousLayout(true);
    add(splitPaneHorizontal, "2, 2, fill, fill");

    JPanel panelMovieList = new JPanel();
    splitPaneHorizontal.setLeftComponent(panelMovieList);
    panelMovieList.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { RowSpec.decode("26px"), FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("fill:max(200px;default):grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelMovieList.add(toolBar, "2, 1, left, fill");

    // udpate datasource
    // toolBar.add(actionUpdateDataSources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDataSources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            JMenuItem item = new JMenuItem(actionUpdateDataSources2);
            buttonUpdateDatasource.getPopupMenu().add(item);
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)));
            }

            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("movie.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    item = new JMenuItem(actionScrapeUnscraped);
    popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);

    toolBar.add(actionEditMovie);

    btnRen = new JButton("REN");
    btnRen.setAction(actionRename);
    toolBar.add(btnRen);

    btnMediaInformation = new JButton("MI");
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    JButton btnCreateOflline = new JButton();
    btnCreateOflline.setAction(new MovieCreateOfflineAction(false));
    toolBar.add(btnCreateOflline);

    textField = EnhancedTextField.createSearchTextField();
    panelMovieList.add(textField, "3, 1, right, bottom");
    textField.setColumns(13);

    // table = new JTable();
    // build JTable

    MatcherEditor<Movie> textMatcherEditor = new TextComponentMatcherEditor<>(textField, new MovieFilterator());
    MovieMatcherEditor movieMatcherEditor = new MovieMatcherEditor();
    FilterList<Movie> extendedFilteredMovies = new FilterList<>(sortedMovies, movieMatcherEditor);
    textFilteredMovies = new FilterList<>(extendedFilteredMovies, textMatcherEditor);
    movieSelectionModel = new MovieSelectionModel(sortedMovies, textFilteredMovies, movieMatcherEditor);
    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(textFilteredMovies),
            new MovieTableFormat());
    table = new ZebraJTable(movieTableModel);

    movieTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount()));
            // select first movie if nothing is selected
            ListSelectionModel selectionModel = table.getSelectionModel();
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() > 0) {
                selectionModel.setSelectionInterval(0, 0);
            }
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() == 0) {
                movieSelectionModel.setSelectedMovie(null);
            }
        }
    });

    // install and save the comparator on the Table
    movieSelectionModel.setTableComparatorChooser(
            TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN));

    // table = new MyTable();
    table.setNewFontSize((float) ((int) Math.round(getFont().getSize() * 0.916)));
    // scrollPane.setViewportView(table);

    // JScrollPane scrollPane = new JScrollPane(table);
    JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table);
    panelMovieList.add(scrollPane, "2, 3, 4, 1, fill, fill");

    {
        final JToggleButton filterButton = new JToggleButton(IconManager.FILTER);
        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
        panelMovieList.add(filterButton, "5, 1, right, bottom");

        // add a propertychangelistener which reacts on setting a filter
        movieSelectionModel.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("filterChanged".equals(evt.getPropertyName())) {
                    if (Boolean.TRUE.equals(evt.getNewValue())) {
                        filterButton.setIcon(IconManager.FILTER_ACTIVE);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                    } else {
                        filterButton.setIcon(IconManager.FILTER);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                    }
                }
            }
        });

        panelExtendedSearch = new MovieExtendedSearchPanel(movieSelectionModel);
        panelExtendedSearch.setVisible(false);
        // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
        filterButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (panelExtendedSearch.isVisible() == true) {
                    panelExtendedSearch.setVisible(false);
                } else {
                    panelExtendedSearch.setVisible(true);
                }
            }
        });
    }

    JPanel panelStatus = new JPanel();
    panelMovieList.add(panelStatus, "2, 6, 2, 1");
    panelStatus.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("1px"),
                    ColumnSpec.decode("146px:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("fill:default:grow"), }));

    panelMovieCount = new JPanel();
    panelStatus.add(panelMovieCount, "3, 1, left, fill");

    lblMovieCount = new JLabel(BUNDLE.getString("tmm.movies") + ":"); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCount);

    lblMovieCountFiltered = new JLabel("");
    panelMovieCount.add(lblMovieCountFiltered);

    lblMovieCountOf = new JLabel(BUNDLE.getString("tmm.of")); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCountOf);

    lblMovieCountTotal = new JLabel("");
    panelMovieCount.add(lblMovieCountTotal);

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new MovieInformationPanel(movieSelectionModel);
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPaneHorizontal.setRightComponent(layeredPaneRight);
    splitPaneHorizontal.setContinuousLayout(true);

    // beansbinding init
    initDataBindings();

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();

    // filter
    if (MovieModuleManager.MOVIE_SETTINGS.isStoreUiFilters()) {
        movieList.searchDuplicates();
        movieSelectionModel.filterMovies(MovieModuleManager.MOVIE_SETTINGS.getUiFilters());
    }
}

From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java

/**
 * Instantiates a new tv show panel.//w  w  w  .  ja v  a  2s .  com
 */
public TvShowPanel() {
    super();

    treeModel = new TvShowTreeModel(tvShowList.getTvShows());
    tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel();
    tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel();

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setContinuousLayout(true);
    add(splitPane, "2, 2, fill, fill");

    JPanel panelTvShowTree = new JPanel();
    splitPane.setLeftComponent(panelTvShowTree);
    panelTvShowTree.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, }));

    textField = EnhancedTextField.createSearchTextField();
    panelTvShowTree.add(textField, "4, 1, right, bottom");
    textField.setColumns(12);
    textField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(final DocumentEvent e) {
            applyFilter();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            applyFilter();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            applyFilter();
        }

        public void applyFilter() {
            TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel();
            if (StringUtils.isNotBlank(textField.getText())) {
                filteredModel.setFilter(SearchOptions.TEXT, textField.getText());
            } else {
                filteredModel.removeFilter(SearchOptions.TEXT);
            }

            filteredModel.filter(tree);
        }
    });

    final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER);
    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
    panelTvShowTree.add(btnFilter, "6, 1, default, bottom");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill");

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelTvShowTree.add(toolBar, "2, 1");

    // toolBar.add(actionUpdateDatasources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDatasources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2));
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds)));
            }
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow));
            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        @Override
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        @Override
        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    // item = new JMenuItem(actionScrapeUnscraped);
    // popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    item = new JMenuItem(actionScrapeNewItems);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);
    toolBar.add(actionEdit);

    JButton btnMediaInformation = new JButton();
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    // install drawing of full with
    tree = new ZebraJTree(treeModel) {
        private static final long serialVersionUID = 2422163883324014637L;

        @Override
        public void paintComponent(Graphics g) {
            width = this.getWidth();
            super.paintComponent(g);
        }
    };
    tvShowSelectionModel = new TvShowSelectionModel(tree);

    TreeUI ui = new TreeUI() {
        @Override
        protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds,
                TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
            bounds.width = width - bounds.x;
            super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
        }
    };
    tree.setUI(ui);

    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setCellRenderer(new TvShowTreeCellRenderer());
    tree.setRowHeight(0);
    scrollPane.setViewportView(tree);

    JPanel panelHeader = new JPanel() {
        private static final long serialVersionUID = -6914183798172482157L;

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0,
                    getWidth(), getHeight());
        }
    };
    scrollPane.setColumnHeaderView(panelHeader);
    panelHeader.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"),
                    ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, }));

    JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$
    lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER);
    panelHeader.add(lblTvShowsColumn, "2, 1");

    JLabel lblNfoColumn = new JLabel("");
    lblNfoColumn.setHorizontalAlignment(JLabel.CENTER);
    lblNfoColumn.setIcon(IconManager.INFO);
    lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$
    panelHeader.add(lblNfoColumn, "4, 1");

    JLabel lblImageColumn = new JLabel("");
    lblImageColumn.setHorizontalAlignment(JLabel.CENTER);
    lblImageColumn.setIcon(IconManager.IMAGE);
    lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$
    panelHeader.add(lblImageColumn, "5, 1");

    JLabel lblSubtitleColumn = new JLabel("");
    lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER);
    lblSubtitleColumn.setIcon(IconManager.SUBTITLE);
    lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$
    panelHeader.add(lblSubtitleColumn, "6, 1");

    JPanel panel = new JPanel();
    panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill");
    panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$
    panel.add(lblTvShowsT, "1, 2, fill, fill");

    lblTvShows = new JLabel("");
    panel.add(lblTvShows, "3, 2");

    JLabel labelSlash = new JLabel("/");
    panel.add(labelSlash, "5, 2");

    JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$
    panel.add(lblEpisodesT, "7, 2");

    lblEpisodes = new JLabel("");
    panel.add(lblEpisodes, "9, 2");

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new JPanel();
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree);
    panelExtendedSearch.setVisible(false);
    // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
    btnFilter.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (panelExtendedSearch.isVisible() == true) {
                panelExtendedSearch.setVisible(false);
            } else {
                panelExtendedSearch.setVisible(true);
            }
        }
    });
    // add a propertychangelistener which reacts on setting a filter
    tree.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if ("filterChanged".equals(evt.getPropertyName())) {
                if (Boolean.TRUE.equals(evt.getNewValue())) {
                    btnFilter.setIcon(IconManager.FILTER_ACTIVE);
                    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                } else {
                    btnFilter.setIcon(IconManager.FILTER);
                    btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                }
            }
        }
    });
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPane.setRightComponent(layeredPaneRight);
    panelRight.setLayout(new CardLayout(0, 0));

    JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel);
    panelRight.add(panelTvShow, "tvShow");

    JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel);
    panelRight.add(panelTvShowSeason, "tvShowSeason");

    JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel);
    panelRight.add(panelTvShowEpisode, "tvShowEpisode");

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            if (node != null) {
                // click on a tv show
                if (node.getUserObject() instanceof TvShow) {
                    TvShow tvShow = (TvShow) node.getUserObject();
                    tvShowSelectionModel.setSelectedTvShow(tvShow);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShow");
                }

                // click on a season
                if (node.getUserObject() instanceof TvShowSeason) {
                    TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject();
                    tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShowSeason");
                }

                // click on an episode
                if (node.getUserObject() instanceof TvShowEpisode) {
                    TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject();
                    tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode);
                    CardLayout cl = (CardLayout) (panelRight.getLayout());
                    cl.show(panelRight, "tvShowEpisode");
                }
            } else {
                // check if there is at least one tv show in the model
                TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot();
                if (root.getChildCount() == 0) {
                    // sets an inital show
                    tvShowSelectionModel.setSelectedTvShow(null);
                }
            }
        }
    });

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();
    initDataBindings();

    // selecting first TV show at startup
    if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) {
        DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel()
                .getRoot()).getFirstChild();
        tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath()));
        tree.setSelectionPath(new TreePath(firstLeaf.getPath()));
    }
}

From source file:org.tros.torgo.ControllerBase.java

/**
 * Initialize the window. This is called here from run() and not the
 * constructor so that the Service Provider doesn't load up all of the
 * necessary resources when the application loads.
 *///  w  w  w  .  j av a2  s.  c  o  m
private void initSwing() {
    this.torgoPanel = createConsole((Controller) this);
    this.torgoCanvas = createCanvas(torgoPanel);

    //init the GUI w/ the components...
    Container contentPane = window.getContentPane();
    JToolBar tb = createToolBar();
    if (tb != null) {
        contentPane.add(tb, BorderLayout.NORTH);
    }

    final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(NamedWindow.class);
    if (torgoCanvas != null) {
        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, torgoCanvas.getComponent(),
                torgoPanel.getComponent());
        int dividerLocation = prefs.getInt(this.getClass().getName() + "divider-location",
                window.getWidth() - 300);
        splitPane.setDividerLocation(dividerLocation);
        splitPane.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent pce) {
                prefs.putInt(this.getClass().getName() + "divider-location", splitPane.getDividerLocation());
            }
        });

        contentPane.add(splitPane);
    } else {
        contentPane.add(torgoPanel.getComponent());
    }

    JMenuBar mb = createMenuBar();
    if (mb == null) {
        mb = new TorgoMenuBar(window, this);
    }
    window.setJMenuBar(mb);
    JMenu helpMenu = new JMenu("Help");
    JMenuItem aboutMenu = new JMenuItem("About Torgo");
    try {
        java.util.Enumeration<URL> resources = ClassLoader.getSystemClassLoader()
                .getResources(ABOUT_MENU_TORGO_ICON);
        ImageIcon ico = new ImageIcon(resources.nextElement());
        aboutMenu.setIcon(ico);
    } catch (IOException ex) {
        Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex);
    }

    aboutMenu.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            AboutWindow aw = new AboutWindow();
            aw.setVisible(true);
        }
    });
    helpMenu.add(aboutMenu);

    JMenu vizMenu = new JMenu("Visualization");
    for (String name : TorgoToolkit.getVisualizers()) {
        JCheckBoxMenuItem item = new JCheckBoxMenuItem(name);
        viz.add(item);
        vizMenu.add(item);
    }
    if (vizMenu.getItemCount() > 0) {
        mb.add(vizMenu);
    }

    mb.add(helpMenu);
    window.setJMenuBar(mb);

    window.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {
        }

        /**
         * We only care if the window is closing so we can kill the
         * interpreter thread.
         *
         * @param e
         */
        @Override
        public void windowClosing(WindowEvent e) {
            stopInterpreter();
        }

        @Override
        public void windowClosed(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
}

From source file:org.wmediumd.WmediumdGraphView.java

public WmediumdGraphView() {

    JMenuBar menuBar;
    JMenu menu;/*w ww .  jav  a 2s  . c o m*/
    JMenuItem menuItem;

    setup();
    setupVisualization();
    setupMouse();

    // Let's add a menu for changing mouse modes
    menuBar = new JMenuBar();

    menu = new JMenu();
    menu.setText("File");
    menu.setIcon(null);

    menuItem = new JMenuItem("New file");
    menuItem.setIcon(UIManager.getIcon("FileView.fileIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            // TODO Use the Factory
            MyNode.nodeCount = 0;
            MyLink.linkCount = 0;
            graph.clear();
            frame.repaint();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem("Load file");
    menuItem.setIcon(UIManager.getIcon("FileChooser.upFolderIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            FileChooserLoad fl = new FileChooserLoad();
            if (fl.getMatrixList().rates() == MyLink.rates) {
                MyNode.nodeCount = 0;
                MyLink.linkCount = 0;
                graph.clear();
                graph.setDataFromMatrixList(fl.getMatrixList());
                frame.repaint();
            }

        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem("Save as...");
    menuItem.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (MyNode.nodeCount > 1) {
                System.out.println(generateConfigString());
                new FileChooserSave(generateConfigString());
            }
        }
    });
    menu.add(menuItem);

    menu.addSeparator();
    menuItem = new JMenuItem("Exit");
    menuItem.setIcon(UIManager.getIcon("InternalFrame.closeIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            System.exit(0);
        }
    });
    menu.add(menuItem);
    menuBar.add(menu);

    menu = graphMouse.getModeMenu(); // Obtain mode menu from the mouse
    menu.setText("Edit");
    menu.setIcon(null); // I'm using this in a main menu
    menu.setPreferredSize(new Dimension(40, 15)); // Change the size
    menuBar.add(menu);

    menu = new JMenu("Help");

    menuItem = new JMenuItem("Help");
    menuItem.setIcon(UIManager.getIcon("FileChooser.detailsViewIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            openURL("http://o11s.org/trac/wiki/MeshTestingWmediumd#a4.1.Usingwconfig");
        }
    });
    menu.add(menuItem);
    menu.addSeparator();

    menuItem = new JMenuItem("About");
    menuItem.setIcon(UIManager.getIcon("FileChooser.homeFolderIcon"));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {

            JOptionPane.showMessageDialog(
                    frame, "Wireless medium daemon\n" + "configuration tool <v0.2b>\n\n"
                            + "(C) 2011 - Javier Lopez\n" + "<jlopex@gmail.com>\n",
                    "About", JOptionPane.INFORMATION_MESSAGE);

        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
    vViewer.setGraphMouse(graphMouse);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(vViewer);
    frame.pack();
    frame.setVisible(true);
}

From source file:org.wso2.appserver.sample.flickr.client.FlickrServiceFrame.java

public FlickrServiceFrame() {

    this.setTitle("WSO2 AppServer FlickrClient Sample - Invokes Flickr in a RESTfull manner");

    for (int i = 1; i <= 50; i++) {
        cmbGetContactsPhotos.addItem(new Integer(i));
        cmbGetContactsPublicPhotosCount.addItem(new Integer(i));
        cmbUserCommentsPerPage.addItem(new Integer(i));
        cmbUserPhotosPerPage.addItem(new Integer(i));
    }//from  w  ww. ja v a 2 s .com
    for (int i = 1; i <= 400; i++) {
        cmbGrpPoolsGrpsPerPage.addItem(new Integer(i));
    }

    for (int i = 1; i <= 500; i++) {
        cmbGetFavoritesPerPage.addItem(new Integer(i));
        cmbGetNotInSetPerPage.addItem(new Integer(i));
        cmbGetRecentPerPage.addItem(new Integer(i));
        cmbGetUntaggedPerPage.addItem(new Integer(i));
        cmbGetWithGeoDataPerPage.addItem(new Integer(i));
        cmbGetWithoutGeoDataPerPage.addItem(new Integer(i));
        cmbRecentlyUpdatedPerPage.addItem(new Integer(i));
        cmbSearchPerPage.addItem(new Integer(i));
        cmbFavoritesGetPerPage.addItem(new Integer(i));
        cmbFavoritesGetPubPerPage.addItem(new Integer(i));
        cmbGroupsSearchPerPage.addItem(new Integer(i));
    }

    for (int i = 1; i <= 1000; i++) {
        cmbContactsGetPerPage.addItem(new Integer(i));
        cmbContactsGetPubPerPage.addItem(new Integer(i));
    }

    for (int i = 1; i <= 16; i++) {
        cmbGeoSetLocAccuracy.addItem(new Integer(i));
        cmbSearchAccuracy.addItem(new Integer(i));
    }

    for (int i = -90; i <= 90; i++) {
        cmbGeoSetLocLatitude.addItem(new Integer(i));
    }

    for (int i = -180; i <= 180; i++) {
        cmbGeoSetLocLongitude.addItem(new Integer(i));
    }

    cmbGeoSetLocLatitude.setSelectedIndex(89);
    cmbGeoSetLocLongitude.setSelectedIndex(179);
    cmbGeoSetLocAccuracy.setSelectedIndex(15);
    cmbSearchAccuracy.setSelectedIndex(15);
    cmbUserCommentsPerPage.setSelectedIndex(9);
    cmbUserPhotosPerPage.setSelectedIndex(9);
    cmbGetContactsPhotos.setSelectedIndex(9);
    cmbGetContactsPublicPhotosCount.setSelectedIndex(9);
    cmbContactsGetPerPage.setSelectedIndex(999);
    cmbContactsGetPubPerPage.setSelectedIndex(999);
    cmbGetFavoritesPerPage.setSelectedIndex(9);
    cmbGetNotInSetPerPage.setSelectedIndex(99);
    cmbGetRecentPerPage.setSelectedIndex(99);
    cmbGetUntaggedPerPage.setSelectedIndex(99);
    cmbGetWithGeoDataPerPage.setSelectedIndex(99);
    cmbGetWithoutGeoDataPerPage.setSelectedIndex(99);
    cmbRecentlyUpdatedPerPage.setSelectedIndex(99);
    cmbSearchPerPage.setSelectedIndex(99);
    cmbFavoritesGetPerPage.setSelectedIndex(99);
    cmbFavoritesGetPubPerPage.setSelectedIndex(99);
    cmbGroupsSearchPerPage.setSelectedIndex(99);
    cmbGrpPoolsGrpsPerPage.setSelectedIndex(399);

    cmbContactsGetFilter.addItem("");
    cmbContactsGetFilter.addItem(Filter._both);
    cmbContactsGetFilter.addItem(Filter._family);
    cmbContactsGetFilter.addItem(Filter._friends);
    cmbContactsGetFilter.addItem(Filter._neither);

    cmbGetWithGeoDataPrivacy.addItem("");
    cmbGetWithGeoDataPrivacy.addItem(Filter._both);
    cmbGetWithGeoDataPrivacy.addItem(Filter._family);
    cmbGetWithGeoDataPrivacy.addItem(Filter._friends);
    cmbGetWithGeoDataPrivacy.addItem(Filter._neither);

    cmbGetWithoutGeoDataPrivacy.addItem("");
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._both);
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._family);
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._friends);
    cmbGetWithoutGeoDataPrivacy.addItem(Filter._neither);

    JMenu configMenu = new JMenu("Configure");
    JMenuItem hostMenuItem = configMenu.add("Host");
    hostMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String result = JOptionPane.showInputDialog(getContentPane(), "Enter host address", host);
            if (result != null && !"".equals(result.trim())) {
                host = result;
            }
        }
    });
    JMenuItem portMenuItem = configMenu.add("Port");
    portMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String result = JOptionPane.showInputDialog(getContentPane(), "Enter port", port);
            if (result != null && !"".equals(result.trim())) {
                port = result;
            }
        }
    });

    JMenuItem keyMenuItem = configMenu.add("API KEY");
    keyMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getAPIKEY();
        }
    });

    JMenuItem secretMenuItem = configMenu.add("Secret");
    secretMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getSharedSecret();
        }
    });

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    menuBar.add(configMenu);

    // flickr.people Operations

    findByEmailInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPeopleEmail.getText().trim())) {
                showRequiredMessage("E-mail");
            } else {
                findByEmailOutput
                        .setText(client.flickrPeopleFindByEmail(txtPeopleEmail.getText(), key, host, port));
            }
        }
    });

    findByUsernameInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPeopleUsername.getText().trim())) {
                showRequiredMessage("Username");
            } else {
                findByUsernameOutput.setText(
                        client.flickrPeopleFindByUsername(txtPeopleUsername.getText(), key, host, port));
            }
        }
    });

    getInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPeopleGetInfo.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                getInfoOutput.setText(client.flickrPeopleGetInfo(txtPeopleGetInfo.getText(), key, host, port));
            }
        }
    });

    getPublicGroupsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetPublicGroups.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                getPublicGroupsOutput.setText(
                        client.flickrPeopleGetPublicGroups(txtGetPublicGroups.getText(), key, host, port));
            }
        }
    });
    getPublicPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetPublicPhotos.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                getPublicPhotosOutput.setText(
                        client.flickrPeopleGetPublicPhotos(txtGetPublicPhotos.getText(), key, host, port));
            }
        }
    });
    getUploadStatusInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {

            if (checkToken(READ))
                getUploadStatusOutput
                        .setText(client.flickrPeopleGetUploadStatus(sharedSecret, token, key, host, port));
        }
    });

    photosGetInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            String photoID = txtPhotosGetInfoPhotoID.getText();
            if ("".equals(photoID.trim())) {
                showRequiredMessage("PhotoID");
            } else {
                photosGetInfoOutput.setText(
                        client.flickrPhotosGetInfo(photoID, txtPhotosGetInfoSecret.getText(), key, host, port));
            }
        }

    });

    // flickr.activity Operations

    userCommentsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                userCommentsOutput.setText(client.flickrActivityUserComments(txtUserCommentsPage.getText(),
                        cmbUserCommentsPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
        }
    });

    userPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                userPhotosOutput.setText(client.flickrActivityUserPhotos(txtUserPhotosPage.getText(),
                        cmbUserPhotosPerPage.getSelectedItem().toString(), txtUserPhotosTimeFrame.getText(),
                        sharedSecret, token, key, host, port));
        }
    });

    // flickr.blog Operations

    blogsGetListInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                blogsGetListOutput.setText(client.flickrBlogsGetList(sharedSecret, token, key, host, port));
        }
    });

    postPhotoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPostPhotoBlogID.getText().trim())) {
                showRequiredMessage("Blog ID");
            } else if ("".equals(txtPostPhotoPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtPostPhotoTitle.getText().trim())) {
                showRequiredMessage("Title");
            } else if ("".equals(txtPostPhotoDescription.getText().trim())) {
                showRequiredMessage("Description");
            } else {
                if (checkToken(WRITE))
                    postPhotoOutput.setText(client.flickrBlogsPostPhoto(txtPostPhotoBlogID.getText(),
                            txtPostPhotoPhotoID.getText(), txtPostPhotoTitle.getText(),
                            txtPostPhotoDescription.getText(), txtPostPhotoPassword.getText(), sharedSecret,
                            token, key, host, port));
            }
        }
    });

    // flickr.photosets.comments operations

    photoSetsCommAddInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(PhotoSetsCommAddComment.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtPhotoSetsCommAddID.getText().trim())) {
                showRequiredMessage("Comment");
            } else {
                if (checkToken(WRITE))
                    photoSetsCommAddOutput
                            .setText(client.flickrPhotosetsCommentsAddComment(PhotoSetsCommAddComment.getText(),
                                    txtPhotoSetsCommAddID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photoSetsCommDelInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotoSetsCommDelID.getText().trim())) {
                showRequiredMessage("Comment ID");
            } else {
                if (checkToken(WRITE))
                    photoSetsCommDelOutput.setText(client.flickrPhotosetsCommentsDeleteComment(
                            txtPhotoSetsCommDelID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photoSetsCommEditInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotoSetsCommEditID.getText().trim())) {
                showRequiredMessage("Comment ID");
            } else if ("".equals(txtPhotoSetsCommEditComment.getText().trim())) {
                showRequiredMessage("Comment");
            } else {
                if (checkToken(WRITE))
                    PhotoSetsCommEditOutput.setText(
                            client.flickrPhotosetsCommentsEditComment(txtPhotoSetsCommEditComment.getText(),
                                    txtPhotoSetsCommEditID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photoSetsCommGetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotoSetsCommGetID.getText().trim())) {
                showRequiredMessage("Photoset ID");
            } else {
                photoSetsCommGetOutput.setText(client.flickrPhotosetsCommentsGetList(
                        txtPhotoSetsCommGetID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.contacts Operations

    contactsGetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            contactsGetOutput.setText(client.flickrContactsGetList(cmbContactsGetFilter.getSelectedItem(),
                    txtContactsGetPage.getText(), cmbContactsGetPerPage.getSelectedItem().toString(),
                    sharedSecret, token, key, host, port));
        }
    });

    contactsGetPubInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtContactsGetPubID.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                contactsGetPubOutput.setText(client.flickrContactsGetPublicList(txtContactsGetPubID.getText(),
                        txtContactsGetPubPage.getText(), cmbContactsGetPubPerPage.getSelectedItem().toString(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.favorites Operations

    favoritesAddInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtFavoritesAddID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    favoritesAddOutput.setText(client.flickrFavoritesAdd(txtFavoritesAddID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    favoritesGetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkFavoritesGetLicense.isSelected());
                extrasBean.setDate_taken(chkFavoritesGetDateTak.isSelected());
                extrasBean.setDate_upload(chkFavoritesGetDateUp.isSelected());
                extrasBean.setGeo(chkFavoritesGetGeo.isSelected());
                extrasBean.setIcon_server(chkFavoritesGetServer.isSelected());
                extrasBean.setLast_update(chkFavoritesGetLastUp.isSelected());
                extrasBean.setMachine_tags(chkFavoritesGetMachine.isSelected());
                extrasBean.setOriginal_format(chkFavoritesGetOriginal.isSelected());
                extrasBean.setOwner_name(chkFavoritesGetOwner.isSelected());
                extrasBean.setTags(chkFavoritesGetTags.isSelected());
                favoritesGetOutput.setText(client.flickrFavoritesGetList(txtFavoritesGetID.getText(),
                        txtFavoritesGetPage.getText(), cmbFavoritesGetPerPage.getSelectedItem().toString(),
                        extrasBean, sharedSecret, token, key, host, port));
            }
        }
    });

    favoritesGetPubInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtFavoritesGetPubID.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkFavoritesGetPubLicense.isSelected());
                extrasBean.setDate_taken(chkFavoritesGetPubDateTak.isSelected());
                extrasBean.setDate_upload(chkFavoritesGetPubDateUp.isSelected());
                extrasBean.setGeo(chkFavoritesGetPubGeo.isSelected());
                extrasBean.setIcon_server(chkFavoritesGetPubServer.isSelected());
                extrasBean.setLast_update(chkFavoritesGetPubLastUp.isSelected());
                extrasBean.setMachine_tags(chkFavoritesGetPubMachine.isSelected());
                extrasBean.setOriginal_format(chkFavoritesGetPubOriginal.isSelected());
                extrasBean.setOwner_name(chkFavoritesGetPubOwner.isSelected());
                extrasBean.setTags(chkFavoritesGetPubTags.isSelected());
                favoritesGetPubOutput.setText(client.flickrFavoritesGetPublicList(
                        txtFavoritesGetPubID.getText(), txtFavoritesGetPubPage.getText(),
                        cmbFavoritesGetPubPerPage.getSelectedItem().toString(), extrasBean, sharedSecret, token,
                        key, host, port));
            }
        }
    });

    favoritesRmvInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtFavoritesRmvID.getText().trim())) {
                showRequiredMessage("User ID");
            } else {
                if (checkToken(WRITE))
                    favoritesRmvOutput.setText(client.flickrFavoritesRemove(txtFavoritesRmvID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.photos.geo Operations

    geoGetLocInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoGetLocID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                geoGetLocOutput.setText(client.flickrPhotosGeoGetLocation(txtGeoGetLocID.getText(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    geoGetPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoGetPermsID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(READ))
                    geoGetPermsOutput.setText(client.flickrPhotosGeoGetPerms(txtGeoGetPermsID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    geoRmvLocInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoRmvLocID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    geoRmvLocOutput.setText(client.flickrPhotosGeoRemoveLocation(txtGeoRmvLocID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    geoSetPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGeoSetPermsID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    geoSetPermsOutput.setText(client.flickrPhotosGeoSetPerms(txtGeoSetPermsID.getText(),
                            chkGeoSetPermsPublic.isSelected(), chkGeoSetPermsContact.isSelected(),
                            chkGeoSetPermsFriend.isSelected(), chkGeoSetPermsFamily.isSelected(), sharedSecret,
                            token, key, host, port));
            }
        }
    });

    // flickr.groups Operations

    groupsBrowseInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                groupsBrowseOutput.setText(client.flickrGroupsBrowse(txtGroupsBrowseID.getText(), sharedSecret,
                        token, key, host, port));
        }
    });

    groupsGetInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGroupsGetInfoID.getText().trim())) {
                showRequiredMessage("Group ID");
            } else {
                groupsGetInfoOutput.setText(client.flickrGroupsGetInfo(txtGroupsGetInfoID.getText(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    groupsSearchInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGroupsSearchText.getText().trim())) {
                showRequiredMessage("Text");
            } else {
                if (checkToken(WRITE))
                    groupsSearchOutput.setText(client.flickrGroupsSearch(txtGroupsSearchText.getText(),
                            txtGroupsSearchPage.getText(), cmbGroupsSearchPerPage.getSelectedItem().toString(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    // flickr.groups.pools Operations

    grpPoolsAddInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGrpPoolsAddPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtGrpPoolsAddGroupID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                grpPoolsAddOutput.setText(client.flickrGroupsPoolsAdd(txtGrpPoolsAddPhotoID.getText(),
                        txtGrpPoolsAddGroupID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    grpPoolsContextInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGrpPoolsContextPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtGrpPoolsContextGrpID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                grpPoolsContextOutput
                        .setText(client.flickrGroupsPoolsGetContext(txtGrpPoolsContextPhotoID.getText(),
                                txtGrpPoolsContextGrpID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    grpPoolsGrpsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                grpPoolsGrpsOutput.setText(client.flickrGroupsPoolsGetGroups(txtGrpPoolsGrpsPage.getText(),
                        cmbGrpPoolsGrpsPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
        }
    });

    // flickr.photos Operations

    photosGetInfoInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotosGetInfoPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                photosGetInfoOutput.setText(client.flickrPhotosGetInfo(txtPhotosGetInfoPhotoID.getText(),
                        sharedSecret, key, host, port));
            }
        }
    });

    photosAddTagsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotosAddTagsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtAddTags.getText().trim())) {
                showRequiredMessage("Tags");
            } else {
                if (checkToken(WRITE))
                    photosAddTagsOutput.setText(client.flickrPhotosAddTags(txtPhotosAddTagsPhotoID.getText(),
                            txtAddTags.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    photosDeleteInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtPhotosDeletePhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(DELETE))
                    photosDeleteOutput.setText(client.flickrPhotosDelete(txtPhotosDeletePhotoID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    getAllContextsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetAllContextsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(DELETE))
                    getAllContextsOutput.setText(client.flickrPhotosGetAllContexts(
                            txtGetAllContextsPhotoID.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    getContactsPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetContactsPhotosLicense.isSelected());
                extrasBean.setDate_taken(chkGetContactsPhotosDateTaken.isSelected());
                extrasBean.setDate_upload(chkGetContactsPhotosUploadDate.isSelected());
                extrasBean.setIcon_server(chkGetContactsPhotosServer.isSelected());
                extrasBean.setLast_update(chkGetContactsPhotosLastUpdate.isSelected());
                extrasBean.setOriginal_format(chkGetContactsPhotosOriginal.isSelected());
                extrasBean.setOwner_name(chkGetContactsPhotosOwner.isSelected());

                getContactsPhotosOutput.setText(
                        client.flickrPhotosGetContactsPhotos(cmbGetContactsPhotos.getSelectedItem().toString(),
                                chkGetContactsPhotosFriends.isSelected(),
                                chkGetContactsPhotosSingle.isSelected(), chkGetContactsPhotosSelf.isSelected(),
                                extrasBean, sharedSecret, token, key, host, port));
            }
        }
    });

    getContactsPublicPhotosInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetContactsPhotosLicense.isSelected());
                extrasBean.setDate_taken(chkGetContactsPhotosDateTaken.isSelected());
                extrasBean.setDate_upload(chkGetContactsPhotosUploadDate.isSelected());
                extrasBean.setIcon_server(chkGetContactsPhotosServer.isSelected());
                extrasBean.setLast_update(chkGetContactsPhotosLastUpdate.isSelected());
                extrasBean.setOriginal_format(chkGetContactsPhotosOriginal.isSelected());
                extrasBean.setOwner_name(chkGetContactsPhotosOwner.isSelected());

                getContactsPublicPhotosOutput.setText(
                        client.flickrPhotosGetContactsPublicPhotos(txtGetContactsPublicPhotosUserID.getText(),
                                cmbGetContactsPublicPhotosCount.getSelectedItem().toString(),
                                chkGetContactsPublicPhotosFriends.isSelected(),
                                chkGetContactsPublicPhotosSingle.isSelected(),
                                chkGetContactsPublicPhotosSelf.isSelected(), extrasBean, sharedSecret, token,
                                key, host, port));
            }
        }
    });

    getContextInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetContextPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getContextOutput.setText(client.flickrPhotosGetContext(txtGetContextPhotoID.getText(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    getCountsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ))
                getCountsOutput.setText(client.flickrPhotosGetCounts(txtGetCountsDates.getText(),
                        txtGetCountsDatesTaken.getText(), sharedSecret, token, key, host, port));
        }
    });

    getExifInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetExifPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getExifOutput.setText(client.flickrPhotosGetExif(txtGetExifPhotoID.getText(),
                        txtGetExifSecret.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    getFavoritesInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetFavoritesPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getFavoritesOutput.setText(client.flickrPhotosGetFavorites(txtGetFavoritesPhotoID.getText(),
                        txtGetFavoritesPage.getText(), cmbGetFavoritesPerPage.getSelectedItem().toString(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    getNotInSetInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetNotInSetLicense.isSelected());
                extrasBean.setDate_taken(chkGetNotInSetDateTak.isSelected());
                extrasBean.setDate_upload(chkGetNotInSetDateUp.isSelected());
                extrasBean.setGeo(chkGetNotInSetGeo.isSelected());
                extrasBean.setIcon_server(chkGetNotInSetServer.isSelected());
                extrasBean.setLast_update(chkGetNotInSetLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetNotInSetMachine.isSelected());
                extrasBean.setOriginal_format(chkGetNotInSetOriginal.isSelected());
                extrasBean.setOwner_name(chkGetNotInSetOwner.isSelected());
                extrasBean.setTags(chkGetNotInSetTags.isSelected());
                getNotInSetOutput.setText(client.flickrPhotosGetNotInSet(txtGetNotInSetMinUpDate.getText(),
                        txtGetNotInSetMaxUpDate.getText(), txtGetNotInSetMinTakDate.getText(),
                        txtGetNotInSetMaxTakDate.getText(), cmbGetNotInSetPrivacy.getSelectedItem().toString(),
                        extrasBean, txtGetNotInSetPage.getText(),
                        cmbGetNotInSetPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
            }
        }
    });

    getPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetPermsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(READ))
                    getPermsOutput.setText(client.flickrPhotosGetPerms(txtGetPermsPhotoID.getText(),
                            sharedSecret, token, key, host, port));
            }
        }
    });

    getRecentInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            ExtrasBean extrasBean = new ExtrasBean();
            extrasBean.setLicense(chkGetRecentLicense.isSelected());
            extrasBean.setDate_taken(chkGetRecentDateTak.isSelected());
            extrasBean.setDate_upload(chkGetRecentDateUp.isSelected());
            extrasBean.setGeo(chkGetRecentGeo.isSelected());
            extrasBean.setIcon_server(chkGetRecentServer.isSelected());
            extrasBean.setLast_update(chkGetRecentLastUp.isSelected());
            extrasBean.setMachine_tags(chkGetRecentMachine.isSelected());
            extrasBean.setOriginal_format(chkGetRecentOriginal.isSelected());
            extrasBean.setOwner_name(chkGetRecentOwner.isSelected());
            extrasBean.setTags(chkGetRecentTags.isSelected());
            getRecentOutput.setText(client.flickrPhotosGetRecent(extrasBean, txtGetRecentPage.getText(),
                    cmbGetRecentPerPage.getSelectedItem().toString(), sharedSecret, token, key, host, port));
        }
    });

    getSizesInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtGetSizesPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                getSizesOutput.setText(client.flickrPhotosGetSizes(txtGetSizesPhotoID.getText(), sharedSecret,
                        token, key, host, port));
            }
        }
    });

    getUntaggedInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetUntaggedLicense.isSelected());
                extrasBean.setDate_taken(chkGetUntaggedDateTak.isSelected());
                extrasBean.setDate_upload(chkGetUntaggedDateUp.isSelected());
                extrasBean.setGeo(chkGetUntaggedGeo.isSelected());
                extrasBean.setIcon_server(chkGetUntaggedServer.isSelected());
                extrasBean.setLast_update(chkGetUntaggedLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetUntaggedMachine.isSelected());
                extrasBean.setOriginal_format(chkGetUntaggedOriginal.isSelected());
                extrasBean.setOwner_name(chkGetUntaggedOwner.isSelected());
                extrasBean.setTags(chkGetUntaggedTags.isSelected());
                getUntaggedOutput.setText(client.flickrPhotosGetUntagged(txtGetUntaggedMinUpDate.getText(),
                        txtGetUntaggedMaxUpDate.getText(), txtGetUntaggedMinTakDate.getText(),
                        txtGetUntaggedMaxTakDate.getText(), cmbGetUntaggedPrivacy.getSelectedItem().toString(),
                        extrasBean, txtGetUntaggedPage.getText(),
                        cmbGetUntaggedPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
            }
        }
    });

    getWithGeoDataInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetWithGeoDataLicense.isSelected());
                extrasBean.setDate_taken(chkGetWithGeoDataDateTak.isSelected());
                extrasBean.setDate_upload(chkGetWithGeoDataDateUp.isSelected());
                extrasBean.setGeo(chkGetWithGeoDataGeo.isSelected());
                extrasBean.setIcon_server(chkGetWithGeoDataServer.isSelected());
                extrasBean.setLast_update(chkGetWithGeoDataLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetWithGeoDataMachine.isSelected());
                extrasBean.setOriginal_format(chkGetWithGeoDataOriginal.isSelected());
                extrasBean.setOwner_name(chkGetWithGeoDataOwner.isSelected());
                extrasBean.setTags(chkGetWithGeoDataTags.isSelected());
                getWithGeoDataOutput.setText(client.flickrPhotosGetWithGeoData(
                        txtGetWithGeoDataMinUpDate.getText(), txtGetWithGeoDataMaxUpDate.getText(),
                        txtGetWithGeoDataMinTakDate.getText(), txtGetWithGeoDataMaxTakDate.getText(),
                        cmbGetWithGeoDataPrivacy.getSelectedItem().toString(), extrasBean,
                        txtGetWithGeoDataPage.getText(), cmbGetWithGeoDataPerPage.getSelectedItem().toString(),
                        sharedSecret, token, key, host, port));
            }
        }
    });

    getWithoutGeoDataInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkGetWithoutGeoDataLicense.isSelected());
                extrasBean.setDate_taken(chkGetWithoutGeoDataDateTak.isSelected());
                extrasBean.setDate_upload(chkGetWithoutGeoDataDateUp.isSelected());
                extrasBean.setGeo(chkGetWithoutGeoDataGeo.isSelected());
                extrasBean.setIcon_server(chkGetWithoutGeoDataServer.isSelected());
                extrasBean.setLast_update(chkGetWithoutGeoDataLastUp.isSelected());
                extrasBean.setMachine_tags(chkGetWithoutGeoDataMachine.isSelected());
                extrasBean.setOriginal_format(chkGetWithoutGeoDataOriginal.isSelected());
                extrasBean.setOwner_name(chkGetWithoutGeoDataOwner.isSelected());
                extrasBean.setTags(chkGetWithoutGeoDataTags.isSelected());
                getWithoutGeoDataOutput.setText(client.flickrPhotosGetWithoutGeoData(
                        txtGetWithoutGeoDataMinUpDate.getText(), txtGetWithoutGeoDataMaxUpDate.getText(),
                        txtGetWithoutGeoDataMinTakDate.getText(), txtGetWithoutGeoDataMaxTakDate.getText(),
                        cmbGetWithoutGeoDataPrivacy.getSelectedItem().toString(), extrasBean,
                        txtGetWithoutGeoDataPage.getText(),
                        cmbGetWithoutGeoDataPerPage.getSelectedItem().toString(), sharedSecret, token, key,
                        host, port));
            }
        }
    });

    recentlyUpdatedInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if (checkToken(READ)) {
                ExtrasBean extrasBean = new ExtrasBean();
                extrasBean.setLicense(chkRecentlyUpdatedLicense.isSelected());
                extrasBean.setDate_taken(chkRecentlyUpdatedDateTak.isSelected());
                extrasBean.setDate_upload(chkRecentlyUpdatedDateUp.isSelected());
                extrasBean.setGeo(chkRecentlyUpdatedGeo.isSelected());
                extrasBean.setIcon_server(chkRecentlyUpdatedServer.isSelected());
                extrasBean.setLast_update(chkRecentlyUpdatedLastUp.isSelected());
                extrasBean.setMachine_tags(chkRecentlyUpdatedMachine.isSelected());
                extrasBean.setOriginal_format(chkRecentlyUpdatedOriginal.isSelected());
                extrasBean.setOwner_name(chkRecentlyUpdatedOwner.isSelected());
                extrasBean.setTags(chkRecentlyUpdatedTags.isSelected());
                recentlyUpdatedOutput.setText(client.flickrPhotosRecentlyUpdated(
                        txtRecentlyUpdatedMinDate.getText(), extrasBean, txtRecentlyUpdatedPage.getText(),
                        cmbRecentlyUpdatedPerPage.getSelectedItem().toString(), sharedSecret, token, key, host,
                        port));
            }
        }
    });

    removeTagInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtRemoveTagTadID.getText().trim())) {
                showRequiredMessage("Tag ID");
            } else {
                removeTagOutput.setText(client.flickrPhotosRemoveTag(txtRemoveTagTadID.getText(), sharedSecret,
                        token, key, host, port));
            }
        }
    });

    searchInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            ExtrasBean extrasBean = new ExtrasBean();
            extrasBean.setLicense(chkSearchLicense.isSelected());
            extrasBean.setDate_taken(chkSearchDateTak.isSelected());
            extrasBean.setDate_upload(chkSearchDateUp.isSelected());
            extrasBean.setGeo(chkSearchGeo.isSelected());
            extrasBean.setIcon_server(chkSearchServer.isSelected());
            extrasBean.setLast_update(chkSearchLastUp.isSelected());
            extrasBean.setMachine_tags(chkSearchMachine.isSelected());
            extrasBean.setOriginal_format(chkSearchOriginal.isSelected());
            extrasBean.setOwner_name(chkSearchOwner.isSelected());
            extrasBean.setTags(chkSearchTags.isSelected());
            searchOutput.setText(client.flickrPhotosSearch(txtSearchUserID.getText(), txtSearchTags.getText(),
                    (AnyOrAll) cmbSearchTagMode.getSelectedItem(), txtSearchText.getText(),
                    txtSearchMinUpDate.getText(), txtSearchMaxUpDate.getText(), txtSearchMinTakDate.getText(),
                    txtMaxTakDate.getText(), txtSearchLicense.getText(),
                    (SortOrder) cmbSearchSort.getSelectedItem(), cmbSearchPrivacy.getSelectedItem().toString(),
                    cmbSearchAccuracy.getSelectedItem().toString(), txtSearchMachine.getText(),
                    (AnyOrAll) cmbSearchMachineMode.getSelectedItem(), txtSearchGroupID.getText(), extrasBean,
                    txtSearchPage.getText(), cmbSearchPerPage.getSelectedItem().toString(), sharedSecret, token,
                    key, host, port));
        }
    });

    setDatesInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtSetDatesPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    setDatesOutput.setText(client.flickrPhotosSetDates(txtSetDatesPhotoID.getText(),
                            txtSetDatesPosted.getText(), txtSetDatesTaken.getText(),
                            txtSetDatesGranularity.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    setMetaInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtSetMetaPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else if ("".equals(txtSetMetaTitle.getText().trim())) {
                showRequiredMessage("Title");
            } else if ("".equals(txtSetMetaDescription.getText().trim())) {
                showRequiredMessage("Description");
            } else {
                if (checkToken(WRITE))
                    setMetaOutput.setText(
                            client.flickrPhotosSetMeta(txtSetMetaPhotoID.getText(), txtSetMetaTitle.getText(),
                                    txtSetMetaDescription.getText(), sharedSecret, token, key, host, port));
            }
        }
    });

    setPermsInvoke.addActionListener(new ActionListener() {
        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            if ("".equals(txtSetPermsPhotoID.getText().trim())) {
                showRequiredMessage("Photo ID");
            } else {
                if (checkToken(WRITE))
                    setPermsOutput.setText(client.flickrPhotosSetPerms(txtSetPermsPhotoID.getText(),
                            chkSetPermsPublic.isSelected(), chkSetPermsFriends.isSelected(),
                            chkSetPermsFamily.isSelected(), cmbSetPermsComments.getSelectedItem().toString(),
                            cmbSetPermsMeta.getSelectedItem().toString(), sharedSecret, token, key, host,
                            port));
            }
        }
    });

}

From source file:picocash.components.HeaderPanel.java

private void init() {
    setLayout(new MigLayout("fill"));
    setBackgroundPainter(this);

    final JXLabel picocashLabel = createLabel(PICOCASH, picocashFont);

    final JMenu accountLabel = createMenu(ACCOUNT);
    accountLabel.add(getAction("newAccount"));
    accountLabel.add(getAction("editAccount"));
    accountLabel.add(getAction("deleteAccount"));

    final JMenu transactionLabel = createMenu(TRANSACTION);
    transactionLabel.add(getAction("newTransaction"));
    transactionLabel.add(getAction("editTransaction"));
    transactionLabel.add(getAction("deleteTransaction"));

    final JMenu settingsLabel = createMenu(SETTINGS);
    settingsLabel.add(getAction("managePayees"));
    settingsLabel.add(getAction("manageCategories"));
    settingsLabel.add(new Separator());
    settingsLabel.add(getAction("importAll"));
    settingsLabel.add(getAction("exportAll"));

    JMenuBar menuBar = new JMenuBar();
    menuBar.setBackground(new Color(0, 0, 0, 0));
    menuBar.add(accountLabel);
    menuBar.add(transactionLabel);/* w w  w  . j a  v a2 s  . c  o m*/
    menuBar.add(settingsLabel);

    final JXButton closeButton = new JXButton(getAction("quit"));
    closeButton.setBackgroundPainter(new MattePainter<JXButton>(TRANSPARENT));
    closeButton.setText(null);
    closeButton.setIcon(PicocashIcons.getSystemIcon("close"));
    closeButton.setFocusable(false);

    final JXButton minimizeButton = new JXButton(getAction("minimize"));
    minimizeButton.setBackgroundPainter(new MattePainter<JXButton>(TRANSPARENT));
    minimizeButton.setIcon(PicocashIcons.getSystemIcon("minimize"));
    minimizeButton.setText(null);
    minimizeButton.setFocusable(false);

    final JXButton maximizeButton = new JXButton(getAction("maximize"));
    maximizeButton.setBackgroundPainter(new MattePainter<JXButton>(TRANSPARENT));
    maximizeButton.setIcon(PicocashIcons.getSystemIcon("maximize"));
    maximizeButton.setText(null);
    maximizeButton.setFocusable(false);

    add(picocashLabel, "dock west, gapleft 10!");
    add(menuBar, "");
    add(minimizeButton, "gapleft push, split 3, w 12!, h 12!, top, gaptop 3!");
    add(maximizeButton, "w 12!, h 12!, top right, gaptop 3!");
    add(closeButton, " w 12!, h 12!, top right, gapright 10!, gaptop 3!");
}

From source file:pl.kotcrab.arget.gui.MainWindow.java

private void createMenuBars() {
    JMenuBar menuBar = new JMenuBar();
    menuBar.setBorder(new EmptyBorder(0, 0, 0, 0));
    setJMenuBar(menuBar);/*w  w w . ja  v  a  2 s  .c om*/

    JMenu argetMenu = new JMenu("Arget");
    serversMenu = new JMenu("Servers");
    JMenu contactsMenu = new JMenu("Contacts");
    JMenu viewMenu = new JMenu("View");
    JMenu helpMenu = new JMenu("Help");

    menuBar.add(argetMenu);
    menuBar.add(serversMenu);
    menuBar.add(contactsMenu);
    menuBar.add(viewMenu);
    menuBar.add(helpMenu);

    argetMenu.add(new MenuItem("Options...", MenuEventType.ARGET_EDIT_OPTIONS));
    argetMenu.add(new JSeparator());
    argetMenu.add(new MenuItem("Logout", MenuEventType.ARGET_LOGOUT));
    argetMenu.add(new MenuItem("Exit", MenuEventType.ARGET_EXIT));

    serversMenu.add(new MenuItem("Add Server...", MenuEventType.SERVERS_ADD));
    serversMenu.add(new MenuItem("Manage Servers...", MenuEventType.SERVERS_MANAGE));
    serversMenu.add(new MenuItem("Disconnect", MenuEventType.SERVERS_DISCONNECT));
    serversMenu.add(new JSeparator());

    viewMenu.add(new MenuItem("Show Home Screen", MenuEventType.VIEW_SHOW_HOME));
    viewMenu.add(new MenuItem("Show Log", MenuEventType.VIEW_SHOW_LOG));

    contactsMenu.add(new MenuItem("Show My Public Key...", MenuEventType.CONTACTS_SHOW_PUBLIC_KEY));
    contactsMenu.add(new MenuItem("Add Contact...", MenuEventType.CONTACTS_ADD));
    contactsMenu.add(new JSeparator());
    contactsMenu.add(new MenuItem("Refresh list", MenuEventType.CONTACTS_REFRESH));

    helpMenu.add(new MenuItem("About Arget", MenuEventType.HELP_ABOUT));

    addServersFromProfile();
}

From source file:pl.otros.logview.gui.LogViewMainFrame.java

private void initMenu() {
    JMenuBar menuBar = getJMenuBar();
    if (menuBar == null) {
        menuBar = new JMenuBar();
        setJMenuBar(menuBar);//from   www  .  j  av  a2  s  .  c o m
    }
    menuBar.removeAll();
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    JLabel labelOpenLog = new JLabel("Open log", Icons.FOLDER_OPEN, SwingConstants.LEFT);
    Font menuGroupFont = labelOpenLog.getFont().deriveFont(13f).deriveFont(Font.BOLD);
    labelOpenLog.setFont(menuGroupFont);
    fileMenu.add(labelOpenLog);
    JMenuItem openAutoDetectLog = new JMenuItem("Open log with autodetect type");
    openAutoDetectLog.addActionListener(new ImportLogWithAutoDetectedImporterActionListener(otrosApplication));
    openAutoDetectLog.setMnemonic(KeyEvent.VK_O);
    openAutoDetectLog.setIcon(Icons.WIZARD);
    fileMenu.add(openAutoDetectLog);
    JMenuItem tailAutoDetectLog = new JMenuItem("Tail log with autodetect type");
    tailAutoDetectLog.addActionListener(new TailLogWithAutoDetectActionListener(otrosApplication));
    tailAutoDetectLog.setMnemonic(KeyEvent.VK_T);
    tailAutoDetectLog.setIcon(Icons.ARROW_REPEAT);
    fileMenu.add(tailAutoDetectLog);
    fileMenu.add(new TailMultipleFilesIntoOneView(otrosApplication));
    fileMenu.add(new ConnectToSocketHubAppenderAction(otrosApplication));
    fileMenu.add(new JSeparator());
    JLabel labelLogInvestigation = new JLabel("Log investigation", SwingConstants.LEFT);
    labelLogInvestigation.setFont(menuGroupFont);
    fileMenu.add(labelLogInvestigation);
    fileMenu.add(new OpenLogInvestigationAction(otrosApplication));
    JMenuItem saveLogsInvest = new JMenuItem(new SaveLogInvestigationAction(otrosApplication));
    enableDisableComponetsForTabs.addComponet(saveLogsInvest);
    fileMenu.add(saveLogsInvest);
    fileMenu.add(new JSeparator());
    LogImporter[] importers = new LogImporter[0];
    importers = logImportersContainer.getElements().toArray(importers);
    for (LogImporter logImporter : importers) {
        JMenuItem openLog = new JMenuItem("Open " + logImporter.getName() + " log");
        openLog.addActionListener(new ImportLogWithGivenImporterActionListener(otrosApplication, logImporter));
        if (logImporter.getKeyStrokeAccelelator() != null) {
            openLog.setAccelerator(KeyStroke.getKeyStroke(logImporter.getKeyStrokeAccelelator()));
        }
        if (logImporter.getMnemonic() > 0) {
            openLog.setMnemonic(logImporter.getMnemonic());
        }
        Icon icon = logImporter.getIcon();
        if (icon != null) {
            openLog.setIcon(icon);
        }
        fileMenu.add(openLog);
    }
    fileMenu.add(new JSeparator());
    JLabel labelTailLog = new JLabel("Tail log [from begging of file]", Icons.ARROW_REPEAT,
            SwingConstants.LEFT);
    labelTailLog.setFont(menuGroupFont);
    fileMenu.add(labelTailLog);
    for (LogImporter logImporter : importers) {
        JMenuItem openLog = new JMenuItem("Tail " + logImporter.getName() + " log");
        openLog.addActionListener(new TailLogActionListener(otrosApplication, logImporter));
        if (logImporter.getKeyStrokeAccelelator() != null) {
            openLog.setAccelerator(KeyStroke.getKeyStroke(logImporter.getKeyStrokeAccelelator()));
        }
        if (logImporter.getMnemonic() > 0) {
            openLog.setMnemonic(logImporter.getMnemonic());
        }
        Icon icon = logImporter.getIcon();
        if (icon != null) {
            openLog.setIcon(icon);
        }
        fileMenu.add(openLog);
    }
    JMenuItem exitMenuItem = new JMenuItem("Exit", 'e');
    exitMenuItem.setIcon(Icons.TURN_OFF);
    exitMenuItem.setAccelerator(KeyStroke.getKeyStroke("control F4"));
    exitAction = new ExitAction(this);
    exitMenuItem.addActionListener(exitAction);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitMenuItem);
    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    JMenuItem closeAll = new JMenuItem(new CloseAllTabsAction(otrosApplication));
    enableDisableComponetsForTabs.addComponet(closeAll);
    ArrayList<SocketLogReader> logReaders = new ArrayList<SocketLogReader>();
    toolsMenu.add(new JMenuItem(new StartSocketListener(otrosApplication, logReaders)));
    toolsMenu.add(new JMenuItem(new StopAllSocketListeners(otrosApplication, logReaders)));
    toolsMenu.add(new ShowMarkersEditor(otrosApplication));
    toolsMenu.add(new ShowLog4jPatternParserEditor(otrosApplication));
    toolsMenu.add(new ShowMessageColorizerEditor(otrosApplication));
    toolsMenu.add(new ShowLoadedPlugins(otrosApplication));
    toolsMenu.add(new ShowOlvLogs(otrosApplication));
    toolsMenu.add(new OpenPreferencesAction(otrosApplication));
    toolsMenu.add(closeAll);
    JMenu pluginsMenu = new JMenu("Plugins");
    otrosApplication.setPluginsMenu(pluginsMenu);
    JMenu helpMenu = new JMenu("Help");
    JMenuItem about = new JMenuItem("About");
    AboutAction action = new AboutAction(otrosApplication);
    action.putValue(Action.NAME, "About");
    about.setAction(action);
    helpMenu.add(about);
    helpMenu.add(new GoToDonatePageAction(otrosApplication));
    JMenuItem checkForNewVersion = new JMenuItem(new CheckForNewVersionAction(otrosApplication));
    helpMenu.add(checkForNewVersion);
    helpMenu.add(new GettingStartedAction(otrosApplication));
    menuBar.add(fileMenu);
    menuBar.add(toolsMenu);
    menuBar.add(pluginsMenu);
    menuBar.add(helpMenu);
}