Example usage for javax.swing JCheckBoxMenuItem isSelected

List of usage examples for javax.swing JCheckBoxMenuItem isSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBoxMenuItem isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Returns the state of the button.

Usage

From source file:gui.DownloadManagerGUI.java

private JMenuBar initMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    /////////////////////////////////////////////////////////////////////////
    JMenu fileMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.fileMenu.name"));
    exportDataItem = new JMenuItem("Export Data...");
    importDataItem = new JMenuItem("Import Data...");
    exitItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.exitItem.name"));
    exitItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.exitItem.iconPath")))); // NOI18N

    exportDataItem.setEnabled(false);//from   w  w w. j a  v a 2 s .c om
    importDataItem.setEnabled(false);

    //     fileMenu.add(exportDataItem);
    //     fileMenu.add(importDataItem);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);

    /////////////////////////////////////////////////////////////////////////
    JMenu windowMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.windowMenu.name"));
    JMenu showMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.showMenu.name"));
    prefsItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.prefsItem.name"));
    prefsItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.prefsItem.iconPath"))));

    JCheckBoxMenuItem showFormItem = new JCheckBoxMenuItem(
            messagesBundle.getString("downloadManagerGUI.showFormItem.name"));
    showFormItem.setSelected(true);

    showMenu.add(showFormItem);
    windowMenu.add(showMenu);
    windowMenu.add(prefsItem);

    exportDataItem.addActionListener(this);
    importDataItem.addActionListener(this);
    exitItem.addActionListener(this);
    prefsItem.addActionListener(this);

    /////////////////////////////////////////////////////////////////////////
    JMenu downloadsMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.downloadsMenu.name"));
    newDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.newDownloadItem.name"));
    newDownloadItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.newDownloadItem.iconPath"))));
    openItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openItem.name"));
    openFolderItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openFolderItem.name"));
    resumeItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.resumeItem.name"));
    resumeItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.resumeItem.iconPath"))));
    pauseItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseItem.name"));
    pauseItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseItem.iconPath"))));
    pauseAllItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseAllItem.name"));
    pauseAllItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseAllItem.iconPath"))));
    clearItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.clearItem.name"));
    clearItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.clearItem.iconPath"))));
    clearAllCompletedItem = new JMenuItem(
            messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.name"));
    clearAllCompletedItem.setIcon(new javax.swing.ImageIcon(getClass()
            .getResource(messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.iconPath"))));
    reJoinItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reJoinItem.name"));
    reJoinItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.reJoinItem.iconPath"))));
    reDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reDownloadItem.name"));
    reDownloadItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.reDownloadItem.iconPath"))));

    moveToQueueItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.moveToQueueItem.name"));

    removeFromQueueItem = new JMenuItem(
            messagesBundle.getString("downloadManagerGUI.removeFromQueueItem.name"));
    propertiesItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.propertiesItem.name"));
    propertiesItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.propertiesItem.iconPath"))));

    downloadsMenu.add(newDownloadItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(openItem);
    downloadsMenu.add(openFolderItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(resumeItem);
    downloadsMenu.add(pauseItem);
    downloadsMenu.add(pauseAllItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(clearItem);
    downloadsMenu.add(clearAllCompletedItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(reJoinItem);
    downloadsMenu.add(reDownloadItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(moveToQueueItem);
    downloadsMenu.add(removeFromQueueItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(propertiesItem);

    newDownloadItem.addActionListener(this);
    openItem.addActionListener(this);
    openFolderItem.addActionListener(this);
    resumeItem.addActionListener(this);
    pauseItem.addActionListener(this);
    pauseAllItem.addActionListener(this);
    clearItem.addActionListener(this);
    clearAllCompletedItem.addActionListener(this);
    reDownloadItem.addActionListener(this);
    moveToQueueItem.addActionListener(this);
    removeFromQueueItem.addActionListener(this);
    propertiesItem.addActionListener(this);

    setStateOfMenuItems();

    /////////////////////////////////////////////////////////////////////////
    JMenu helpMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.helpMenu.name"));
    aboutItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.aboutItem.name"));
    aboutItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.aboutItem.iconPath"))));

    helpMenu.add(aboutItem);

    aboutItem.addActionListener(this);

    menuBar.add(fileMenu);
    menuBar.add(windowMenu);
    menuBar.add(downloadsMenu);
    menuBar.add(helpMenu);

    showFormItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ev.getSource();

            if (menuItem.isSelected()) {
                mainSplitPane.setDividerLocation((int) categoryPanel.getMinimumSize().getWidth());
            }

            categoryPanel.setVisible(menuItem.isSelected());
        }
    });

    fileMenu.setMnemonic(KeyEvent.VK_F);
    exitItem.setMnemonic(KeyEvent.VK_X);

    prefsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));

    exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));

    importDataItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));

    return menuBar;
}

From source file:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java

private void showCameraDialogCheckboxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_showCameraDialogCheckboxActionPerformed
{//GEN-HEADEREND:event_showCameraDialogCheckboxActionPerformed

    final JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource();

    this.cameraPosDialog.setVisible(box.isSelected());
}

From source file:ffx.ui.KeywordPanel.java

/**
 * Handles input from KeywordPanel ToolBar buttons.
 *
 * {@inheritDoc}// w  ww .j  av a  2 s  .  c  o  m
 */
@Override
public void actionPerformed(ActionEvent evt) {
    String arg = evt.getActionCommand();
    switch (arg) {
    case "Open...":
        keyOpen();
        break;
    case "Close":
        keyClose();
        break;
    case "Save":
        keySave(currentKeyFile);
        break;
    case "Save As...":
        keySaveAs();
        break;
    case "Description":
        JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource();
        setDivider(box.isSelected());
        break;
    }
    if (evt.getSource() instanceof JComboBox) {
        loadKeywordGroup();
    }
}

From source file:jatoo.app.App.java

private JPopupMenu getWindowPopup(final Point location) {

    ////from w w w  . ja  v a2 s.co  m
    // hide

    final JMenuItem hideItem = new JMenuItem(getText("popup.hide"));
    hideItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            hide();
        }
    });

    //
    // send to back

    final JMenuItem sendToBackItem = new JMenuItem(getText("popup.send_to_back"));
    sendToBackItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            sendToBack();
        }
    });

    //
    // always on top

    final JCheckBoxMenuItem alwaysOnTopItem = new JCheckBoxMenuItem(getText("popup.always_on_top"),
            isAlwaysOnTop());
    alwaysOnTopItem.addItemListener(new ItemListener() {
        public void itemStateChanged(final ItemEvent e) {
            setAlwaysOnTop(alwaysOnTopItem.isSelected());
        }
    });

    //
    // transparency

    final JSlider transparencySlider = new JSlider(JSlider.VERTICAL, 0, 100, getTransparency());
    transparencySlider.setMajorTickSpacing(25);
    transparencySlider.setMinorTickSpacing(5);
    transparencySlider.setSnapToTicks(true);
    transparencySlider.setPaintTicks(true);
    transparencySlider.setPaintLabels(true);
    transparencySlider.addChangeListener(new ChangeListener() {
        public void stateChanged(final ChangeEvent e) {
            setTransparency(transparencySlider.getValue());
        }
    });

    final JMenu transparencyItem = new JMenu(getText("popup.transparency"));
    transparencyItem.add(transparencySlider);

    //
    // close

    final JMenuItem closeItem = new JMenuItem(getText("popup.close"), getIcon("close-016.png"));
    closeItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            System.exit(0);
        }
    });

    //
    // the popup

    JPopupMenu popup = new JPopupMenu(getTitle());

    popup.add(hideItem);
    popup.addSeparator();
    popup.add(sendToBackItem);
    popup.add(alwaysOnTopItem);
    popup.add(transparencyItem);
    popup.addSeparator();
    popup.add(closeItem);

    popup.setInvoker(popup);
    popup.setLocation(location);

    return popup;
}

From source file:com.alvermont.terraj.fracplanet.ui.AbstractTerrainViewerFrame.java

private void showControlsHelpCheckboxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_showControlsHelpCheckboxActionPerformed
{//GEN-HEADEREND:event_showControlsHelpCheckboxActionPerformed

    final JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource();

    if (this.controlsHelpDialog == null) {
        this.controlsHelpDialog = new ControlsHelpDialog(this, false);
        this.controlsHelpDialog.addWindowListener(new MyWindowAdapter(showControlsHelpCheckbox));
    }/*from w  w w .j av  a 2  s.co  m*/

    this.controlsHelpDialog.setVisible(box.isSelected());
}

From source file:net.sf.jabref.gui.openoffice.OpenOfficePanel.java

private void showSettingsPopup() {
    JPopupMenu menu = new JPopupMenu();
    final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(
            Localization.lang("Automatically sync bibliography when inserting citations"),
            preferences.syncWhenCiting());
    final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem(
            Localization.lang("Look up BibTeX entries in the active tab only"));
    final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem(
            Localization.lang("Look up BibTeX entries in all open databases"));
    final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(useActiveBase);//  ww w.jav  a  2 s .  co m
    bg.add(useAllBases);
    if (preferences.useAllDatabases()) {
        useAllBases.setSelected(true);
    } else {
        useActiveBase.setSelected(true);
    }

    autoSync.addActionListener(e -> preferences.setSyncWhenCiting(autoSync.isSelected()));

    useAllBases.addActionListener(e -> preferences.setUseAllDatabases(useAllBases.isSelected()));

    useActiveBase.addActionListener(e -> preferences.setUseAllDatabases(!useActiveBase.isSelected()));

    clearConnectionSettings.addActionListener(e -> frame.output(preferences.clearConnectionSettings()));

    menu.add(autoSync);
    menu.addSeparator();
    menu.add(useActiveBase);
    menu.add(useAllBases);
    menu.addSeparator();
    menu.add(clearConnectionSettings);
    menu.show(settingsB, 0, settingsB.getHeight());
}

From source file:ffx.ui.ModelingPanel.java

/**
 * {@inheritDoc}// w  w  w  .j  a  v  a 2 s . c o m
 */
@Override
public void actionPerformed(ActionEvent evt) {
    synchronized (this) {
        String actionCommand = evt.getActionCommand();
        // A change to the selected TINKER Command
        switch (actionCommand) {
        case "FFXCommand":
            JComboBox jcb = (JComboBox) toolBar.getComponentAtIndex(2);
            String com = jcb.getSelectedItem().toString();
            if (!com.equals(activeCommand)) {
                activeCommand = com.toLowerCase();
                loadCommand();
            }
            break;
        case "LogSettings":
            // A change to the Log Settings.
            loadLogSettings();
            statusLabel.setText("  " + createCommandInput());
            break;
        case "Launch":
            // Launch the selected Force Field X command.
            runScript();
            break;
        case "NUCLEIC":
        case "PROTEIN":
            // Editor functions for the Protein and Nucleic Acid Builders
            builderCommandEvent(evt);
            break;
        case "Conditional":
            // Some command options are conditional on other input.
            conditionalCommandEvent(evt);
            break;
        case "End":
            // End the currently executing command.
            setEnd();
            break;
        case "Delete":
            // Delete log files.
            deleteLogs();
            break;
        case "Description":
            // Allow command descriptions to be hidden.
            JCheckBoxMenuItem box = (JCheckBoxMenuItem) evt.getSource();
            setDivider(box.isSelected());
            break;
        default:
            logger.log(Level.WARNING, "ModelingPanel ActionCommand not recognized: {0}", evt);
            break;
        }
    }
}

From source file:ucar.unidata.idv.control.chart.ChartWrapper.java

/**
 * Add the default menu items//  www.  j a v a 2 s.c  o  m
 *
 *
 * @param items List of menu items
 *
 * @return The items list
 */
protected List getPopupMenuItems(List items) {

    if (canDoParameters()) {
        items.add(GuiUtils.makeMenuItem("Add Field...", this, "addField"));
    }

    if (canDoJython() && (jython != null) && (jython.trim().length() > 0)) {
        items.add(GuiUtils.makeMenuItem("Apply Jython", this, "applyJython", jython));

    }

    items.add(GuiUtils.makeMenuItem("Remove Chart", this, "removeDisplayComponent"));

    items.add(GuiUtils.MENU_SEPARATOR);
    items.add(GuiUtils.makeMenuItem("Save Image...", this, "doSaveImage"));
    items.add(GuiUtils.makeMenuItem("Save Movie...", this, "doSaveMovie"));

    if (canDoDriveTime()) {
        items.add(GuiUtils.MENU_SEPARATOR);

        final JCheckBoxMenuItem mi1 = new JCheckBoxMenuItem("Show Animation Times", showTime);
        items.add(mi1);
        mi1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                showTime = mi1.isSelected();
            }
        });

        final JCheckBoxMenuItem mi2 = new JCheckBoxMenuItem("Drive Animation Times", driveTime);
        items.add(mi2);
        mi2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                driveTime = mi2.isSelected();
            }
        });

    }

    if (canDoTimeFilters() && (getDisplayGroup() != null)) {
        List comps = getDisplayGroup().getAncestorGroup().findDisplayComponents(ChartWrapper.class);
        JMenu filterMenu = null;
        boolean didSep = false;
        if (timeFilterSource != null) {
            filterMenu = new JMenu("Time Subset");
            didSep = true;
            items.add(GuiUtils.MENU_SEPARATOR);
            items.add(filterMenu);
            filterMenu.add(GuiUtils.makeMenuItem("Remove", ChartWrapper.this, "removeTimeFilterSource"));
        }

        for (int i = 0; i < comps.size(); i++) {
            ChartWrapper chartWrapper = (ChartWrapper) comps.get(i);
            if (chartWrapper.getTimeRanges() == null) {
                continue;
            }
            if (filterMenu == null) {
                filterMenu = new JMenu("Time Subset");
                if (!didSep) {
                    items.add(GuiUtils.MENU_SEPARATOR);
                }
                didSep = true;
                items.add(filterMenu);
            }
            filterMenu.add(GuiUtils.makeMenuItem("From: " + chartWrapper.getName(), ChartWrapper.this,
                    "setTimeFilterSource", chartWrapper));
        }

    }

    if (canDoTimeSelect() && (getDisplayGroup() != null)) {
        List comps = getDisplayGroup().getAncestorGroup().findDisplayComponents(ChartWrapper.class);
        JMenu filterMenu = null;
        boolean didSep = false;
        if (timeSelectSource != null) {
            filterMenu = new JMenu("Time Select");
            didSep = true;
            items.add(GuiUtils.MENU_SEPARATOR);
            items.add(filterMenu);
            filterMenu.add(GuiUtils.makeMenuItem("Remove", ChartWrapper.this, "removeTimeSelectSource"));
        }

        for (int i = 0; i < comps.size(); i++) {
            ChartWrapper chartWrapper = (ChartWrapper) comps.get(i);
            if ((chartWrapper == this) || !chartWrapper.canBeASourceForTimeSelectionEvents()) {
                continue;
            }

            if (filterMenu == null) {
                filterMenu = new JMenu("Time Select");
                if (!didSep) {
                    items.add(GuiUtils.MENU_SEPARATOR);
                }
                didSep = true;
                items.add(filterMenu);
            }
            filterMenu.add(GuiUtils.makeMenuItem("From: " + chartWrapper.getName(), ChartWrapper.this,
                    "setTimeSelectSource", chartWrapper));
        }

    }

    items.add(GuiUtils.MENU_SEPARATOR);
    items.add(GuiUtils.makeMenuItem("Properties...", this, "showProperties"));

    return items;

}

From source file:net.sf.jabref.openoffice.OpenOfficePanel.java

private void showSettingsPopup() {
    JPopupMenu menu = new JPopupMenu();
    final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(
            Localization.lang("Automatically sync bibliography when inserting citations"),
            Globals.prefs.getBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING));
    final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem(
            Localization.lang("Look up BibTeX entries in the active tab only"));
    final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem(
            Localization.lang("Look up BibTeX entries in all open databases"));
    final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(useActiveBase);/*from  ww  w  . j a  v a2  s .c  om*/
    bg.add(useAllBases);
    if (Globals.prefs.getBoolean(JabRefPreferences.USE_ALL_OPEN_BASES)) {
        useAllBases.setSelected(true);
    } else {
        useActiveBase.setSelected(true);
    }

    autoSync.addActionListener(
            e -> Globals.prefs.putBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING, autoSync.isSelected()));

    useAllBases.addActionListener(
            e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, useAllBases.isSelected()));

    useActiveBase.addActionListener(
            e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, !useActiveBase.isSelected()));

    clearConnectionSettings.addActionListener(e -> {

        Globals.prefs.clear(JabRefPreferences.OO_PATH);
        Globals.prefs.clear(JabRefPreferences.OO_EXECUTABLE_PATH);
        Globals.prefs.clear(JabRefPreferences.OO_JARS_PATH);
        frame.output(Localization.lang("Cleared connection settings."));

    });

    menu.add(autoSync);
    menu.addSeparator();
    menu.add(useActiveBase);
    menu.add(useAllBases);
    menu.addSeparator();
    menu.add(clearConnectionSettings);
    menu.show(settingsB, 0, settingsB.getHeight());
}

From source file:homenetapp.HomeNetAppGui.java

private void startHomeNetApp() {

    this.addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent winEvt) {
            // Perhaps ask user if they want to save any unsaved files first.
            exit();//  www . j a va2  s. c  om
        }
    });

    homenetapp.homenet.addPortListener(new homenet.PortListener() {

        ArrayList<String> local = new ArrayList<String>();
        ArrayList<String> remote = new ArrayList<String>();

        private boolean isRemote(String port) {
            return port.equals("xmlrpc");
        }

        public void portAdded(String port) {
            // System.out.println("portAddedEvent");
            if (isRemote(port)) {
                remote.add(port);
                remoteStatusLabel.setText("Connected");
            } else {
                local.add(port);
                localStatusLabel.setText("Connected");
            }
        }

        public void portRemoved(String port) {
            //System.out.println("portRemovedEvent");
            if (isRemote(port)) {
                remote.remove(port);
                if (remote.size() < 1) {
                    remoteStatusLabel.setText("Not Connected");
                }
            } else {
                local.remove(port);
                if (local.size() < 1) {
                    localStatusLabel.setText("Not Connected");
                }
            }
        }

        public void portSendingStart(String port) {
            // System.out.println("portSendingStartEvent");
            if (isRemote(port)) {
                remoteSendingLabel.setText("(X)");
            } else {
                localSendingLabel.setText("(X)");
            }
        }

        public void portSendingEnd(String port) {
            // System.out.println("portSendingEndEvent");
            if (isRemote(port)) {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        remoteSendingLabel.setText("( )");
                    }
                };
                delayThread.start();

            } else {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        localSendingLabel.setText("( )");
                    }
                };
                delayThread.start();

            }
        }

        public void portReceivingStart(String port) {
            //  System.out.println("portRecievingStartEvent");
            if (isRemote(port)) {
                remoteReceivingLabel.setText("(X)");
            } else {
                localReceivingLabel.setText("(X)");
            }
        }

        public void portReceivingEnd(String port) {
            //   System.out.println("portRecievingEndEvent");
            if (isRemote(port)) {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        remoteReceivingLabel.setText("( )");
                    }
                };
                delayThread.start();

            } else {
                Thread delayThread = new Thread() {
                    public void run() {
                        try {
                            Thread.sleep(500);
                        } catch (Exception e) {
                        }
                        localReceivingLabel.setText("( )");
                    }
                };
                delayThread.start();

            }
        }
    });

    try {
        homenetapp.start();
    } catch (Exception e) {
        //show popup and exit program
        javax.swing.JOptionPane.showMessageDialog(null, "Error: " + e.getMessage(), "Error",
                javax.swing.JOptionPane.ERROR_MESSAGE);
        System.err.println(e.getMessage());
    }

    loadSettings();

    SendPacketFrame.setLocationRelativeTo(null);

    homenetapp.homenet.addPacketListener(new homenet.PacketListener() {

        public void packetRecieved(homenet.Packet packet) {
            addPacketToList(packet);
        }
    });

    homenetapp.serialmanager.addListener(new SerialListener() {

        public void portAdded(String name) {
            //    System.out.println("portAddedEvent");

            javax.swing.JCheckBoxMenuItem serialPortCheckBox = new javax.swing.JCheckBoxMenuItem(name);

            serialPortCheckBox.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    JCheckBoxMenuItem checkbox = (JCheckBoxMenuItem) evt.getSource();
                    if (checkbox.isSelected()) {
                        try {
                            homenetapp.serialmanager.activatePort(checkbox.getText());
                        } catch (Exception e) {
                            javax.swing.JOptionPane.showMessageDialog(null,
                                    "Port " + checkbox.getText() + " Error: " + e.getMessage(), "Error",
                                    javax.swing.JOptionPane.ERROR_MESSAGE);
                        }
                    } else {
                        homenetapp.serialmanager.deactivatePort(checkbox.getText());
                    }
                }
            });

            // serialPortCheckBox.setMnemonic(java.awt.event.KeyEvent.VK_1);
            menuItems.put(name, serialPortCheckBox);
            menuSerialPorts.add(serialPortCheckBox);

        }

        public void portRemoved(String name) {
            // System.out.println("portRemovedEvent");
            menuSerialPorts.remove(menuItems.get(name));
        }

        public void portActivated(String name) {
            //  System.out.println("portActivatedEvent");
            menuItems.get(name).setSelected(true);

        }

        public void portDeactivated(String name) {
            //  System.out.println("portDeactivatedEvent");
            menuItems.get(name).setSelected(false);
        }
    });

    try {
        homenetapp.serialmanager.start();
    } catch (Exception e) {
        javax.swing.JOptionPane.showMessageDialog(null, "Port Error: " + e.getMessage(), "Error",
                javax.swing.JOptionPane.ERROR_MESSAGE);
    }
}