Example usage for javax.swing JButton setPressedIcon

List of usage examples for javax.swing JButton setPressedIcon

Introduction

In this page you can find the example usage for javax.swing JButton setPressedIcon.

Prototype

@BeanProperty(visualUpdate = true, description = "The pressed icon for the button.")
public void setPressedIcon(Icon pressedIcon) 

Source Link

Document

Sets the pressed icon for the button.

Usage

From source file:op.users.PnlUser.java

private CollapsiblePane createCP4(final Users user) {
    final String key = user.getUID() + ".xusers";
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        try {//from  w ww . j  a  v  a  2  s  . c  o  m
            cpMap.get(key).setCollapsed(true);
        } catch (PropertyVetoException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    }
    final CollapsiblePane cp = cpMap.get(key);
    DefaultCPTitle cptitle = new DefaultCPTitle("<html><font size=+1>" + user.toString()
            + (UsersTools.isQualified(user) ? ", " + SYSTools.xx("opde.users.qualifiedNurse") : "")
            + "</font></html>", new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        cp.setCollapsed(!cp.isCollapsed());
                    } catch (PropertyVetoException pve) {
                        // BAH!
                    }
                }
            });

    /***
     *       ____ _                            ______        __
     *      / ___| |__   __ _ _ __   __ _  ___|  _ \ \      / /
     *     | |   | '_ \ / _` | '_ \ / _` |/ _ \ |_) \ \ /\ / /
     *     | |___| | | | (_| | | | | (_| |  __/  __/ \ V  V /
     *      \____|_| |_|\__,_|_| |_|\__, |\___|_|     \_/\_/
     *                              |___/
     */
    final JButton btnChangePW = new JButton(SYSConst.icon22password);
    btnChangePW.setPressedIcon(SYSConst.icon22passwordPressed);
    btnChangePW.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnChangePW.setContentAreaFilled(false);
    btnChangePW.setBorder(null);
    btnChangePW.setToolTipText(SYSTools.xx("opde.users.btnChangePW.tooltip"));
    btnChangePW.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {

            EntityManager em = OPDE.createEM();
            try {
                em.getTransaction().begin();
                Users myUser = em.merge(usermap.get(user.getUID()));
                String newpw = SYSTools.generatePassword(myUser.getVorname(), myUser.getName());
                em.lock(myUser, LockModeType.OPTIMISTIC);
                myUser.setMd5pw(SYSTools.hashword(newpw));
                em.getTransaction().commit();

                lstUsers.remove(user);
                lstUsers.add(myUser);
                usermap.put(key, myUser);
                Collections.sort(lstUsers);

                SYSTools.printpw(newpw, myUser);

                OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("opde.users.pwchanged")));
            } catch (OptimisticLockException ole) {
                OPDE.warn(ole);
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }

                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
            } catch (Exception e) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                OPDE.fatal(e);
            } finally {
                em.close();
            }

        }
    });
    btnChangePW.setEnabled(user.isActive());
    cptitle.getRight().add(btnChangePW);

    /***
     *      _     _            _        _   _           ___                  _   _
     *     | |__ | |_ _ __    / \   ___| |_(_)_   _____|_ _|_ __   __ _  ___| |_(_)_   _____
     *     | '_ \| __| '_ \  / _ \ / __| __| \ \ / / _ \| || '_ \ / _` |/ __| __| \ \ / / _ \
     *     | |_) | |_| | | |/ ___ \ (__| |_| |\ V /  __/| || | | | (_| | (__| |_| |\ V /  __/
     *     |_.__/ \__|_| |_/_/   \_\___|\__|_| \_/ \___|___|_| |_|\__,_|\___|\__|_| \_/ \___|
     *
     */
    final JButton btnActiveInactive = new JButton(
            user.isActive() ? SYSConst.icon22stop : SYSConst.icon22playerPlay);
    btnActiveInactive
            .setPressedIcon(user.isActive() ? SYSConst.icon22stopPressed : SYSConst.icon22playerPlayPressed);
    btnActiveInactive.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnActiveInactive.setContentAreaFilled(false);
    btnActiveInactive.setBorder(null);
    btnActiveInactive.setToolTipText(SYSTools
            .xx(internalClassID + (user.isActive() ? ".btnActiveInactive.stop" : ".btnActiveInactive.play")));
    btnActiveInactive.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {

            EntityManager em = OPDE.createEM();
            try {
                em.getTransaction().begin();
                Users myUser = em.merge(usermap.get(user.getUID()));
                em.lock(myUser, LockModeType.OPTIMISTIC);

                myUser.setStatus(myUser.isActive() ? UsersTools.STATUS_INACTIVE : UsersTools.STATUS_ACTIVE);
                em.getTransaction().commit();
                lstUsers.remove(user);
                lstUsers.add(myUser);
                usermap.put(myUser.getUID(), myUser);
                Collections.sort(lstUsers);
                CollapsiblePane cp = createCP4(myUser);
                boolean wasCollapsed = cpMap.get(key).isCollapsed();
                cpMap.put(key, cp);

                cp.setCollapsed(myUser.isActive() ? wasCollapsed : true);
                buildPanel();
            } catch (OptimisticLockException ole) {
                OPDE.warn(ole);
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                    OPDE.getMainframe().emptyFrame();
                    OPDE.getMainframe().afterLogin();
                }
                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
            } catch (Exception e) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                OPDE.fatal(e);
            } finally {
                em.close();
            }
        }

    });
    cptitle.getRight().add(btnActiveInactive);

    /***
     *               _ _ _
     *       ___  __| (_) |_
     *      / _ \/ _` | | __|
     *     |  __/ (_| | | |_
     *      \___|\__,_|_|\__|
     *
     */
    final JButton btnEdit = new JButton(SYSConst.icon22edit3);
    btnEdit.setPressedIcon(SYSConst.icon22edit3Pressed);
    btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnEdit.setContentAreaFilled(false);
    btnEdit.setBorder(null);
    btnEdit.setToolTipText(SYSTools.xx("opde.users.btnEdit"));
    btnEdit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {

            new DlgUser(user, new Closure() {
                @Override
                public void execute(Object o) {
                    if (o != null) {
                        EntityManager em = OPDE.createEM();
                        try {
                            em.getTransaction().begin();
                            Users myUser = em.merge((Users) o);
                            em.lock(myUser, LockModeType.OPTIMISTIC);
                            em.getTransaction().commit();
                            lstUsers.remove(user);
                            lstUsers.add(myUser);
                            usermap.put(myUser.getUID(), myUser);
                            Collections.sort(lstUsers);
                            CollapsiblePane cp = createCP4(myUser);
                            boolean wasCollapsed = cpMap.get(key).isCollapsed();
                            cpMap.put(key, cp);

                            cp.setCollapsed(myUser.isActive() ? wasCollapsed : true);
                            buildPanel();
                        } catch (OptimisticLockException ole) {
                            OPDE.warn(ole);
                            if (em.getTransaction().isActive()) {
                                em.getTransaction().rollback();
                            }
                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                OPDE.getMainframe().emptyFrame();
                                OPDE.getMainframe().afterLogin();
                            }
                            OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                        } catch (Exception e) {
                            if (em.getTransaction().isActive()) {
                                em.getTransaction().rollback();
                            }
                            OPDE.fatal(e);
                        } finally {
                            em.close();
                        }
                    }
                }
            });
        }

    });
    cptitle.getRight().add(btnEdit);

    cp.setTitleLabelComponent(cptitle.getMain());
    cp.setSlidingDirection(SwingConstants.SOUTH);

    /***
     *       ___ ___  _  _ _____ ___ _  _ _____
     *      / __/ _ \| \| |_   _| __| \| |_   _|
     *     | (_| (_) | .` | | | | _|| .` | | |
     *      \___\___/|_|\_| |_| |___|_|\_| |_|
     *
     */

    cp.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            if (!contentMap.containsKey(key)) {
                contentMap.put(key, new PnlEditMemberships(user, lstGroups));
            }
            cp.setContentPane(contentMap.get(key));
            cp.setOpaque(false);
        }
    }

    );
    cp.setBackground(UsersTools.getBG1(user));
    cp.setCollapsible(user.isActive());

    cp.setHorizontalAlignment(SwingConstants.LEADING);
    cp.setOpaque(false);

    return cp;
}

From source file:op.users.PnlUser.java

private CollapsiblePane createCP4(final Groups group) {
    final String key = group.getGID() + ".xgroups";
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH);

        cpMap.get(key).setBackground(bg);
        cpMap.get(key).setForeground(fg);

        cpMap.get(key).addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
            @Override/*  w  w w  .j  av  a 2s  .c  o  m*/
            public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
                if (!contentMap.containsKey(key)) {
                    contentMap.put(key, createContentPanel4(group));
                }
                cpMap.get(key).setContentPane(contentMap.get(key));
            }
        });
        cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING);
        cpMap.get(key).setOpaque(false);
        try {
            cpMap.get(key).setCollapsed(true);
        } catch (PropertyVetoException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    }
    final CollapsiblePane cp = cpMap.get(key);

    DefaultCPTitle cpTitle = new DefaultCPTitle("<html><font size=+1>" + group.getGID().toUpperCase()
            + (group.isQualified() ? ", " + SYSTools.xx("opde.users.qualifiedGroup") : "") + "</font></html>",
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        cp.setCollapsed(!cp.isCollapsed());
                    } catch (PropertyVetoException pve) {
                        // BAH!
                    }
                }
            });

    /***
     *          _      _      _
     *       __| | ___| | ___| |_ ___    __ _ _ __ ___  _   _ _ __
     *      / _` |/ _ \ |/ _ \ __/ _ \  / _` | '__/ _ \| | | | '_ \
     *     | (_| |  __/ |  __/ ||  __/ | (_| | | | (_) | |_| | |_) |
     *      \__,_|\___|_|\___|\__\___|  \__, |_|  \___/ \__,_| .__/
     *                                  |___/                |_|
     */
    final JButton btnDeleteGroup = new JButton(SYSConst.icon22delete);
    btnDeleteGroup.setPressedIcon(SYSConst.icon22deletePressed);
    btnDeleteGroup.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnDeleteGroup.setContentAreaFilled(false);
    btnDeleteGroup.setBorder(null);
    btnDeleteGroup.setToolTipText(SYSTools.xx("opde.users.btnDeleteGroup"));
    btnDeleteGroup.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + group.getGID() + "</i><br/>"
                    + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() {
                        @Override
                        public void execute(Object o) {
                            if (o.equals(JOptionPane.YES_OPTION)) {
                                EntityManager em = OPDE.createEM();
                                try {
                                    em.getTransaction().begin();
                                    Groups myGroup = em.merge(group);
                                    em.remove(myGroup);
                                    em.getTransaction().commit();
                                    lstGroups.remove(group);
                                    cpMap.remove(key);
                                    buildPanel();
                                } catch (OptimisticLockException ole) {
                                    OPDE.warn(ole);
                                    if (em.getTransaction().isActive()) {
                                        em.getTransaction().rollback();
                                    }
                                    if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                        OPDE.getMainframe().emptyFrame();
                                        OPDE.getMainframe().afterLogin();
                                    }
                                    OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                                } catch (Exception e) {
                                    if (em.getTransaction().isActive()) {
                                        em.getTransaction().rollback();
                                    }
                                    OPDE.fatal(e);
                                } finally {
                                    em.close();
                                }
                            }
                        }
                    });

        }

    });
    btnDeleteGroup.setEnabled(!group.isSystem());
    cpTitle.getRight().add(btnDeleteGroup);

    cp.setTitleLabelComponent(cpTitle.getMain());

    if (!cp.isCollapsed()) {
        if (!contentMap.containsKey(key)) {
            contentMap.put(key, createContentPanel4(group));
        }
        cp.setContentPane(contentMap.get(key));
    }

    return cp;
}

From source file:org.apache.jmeter.util.JMeterUtils.java

/**
 * Create a button with the netscape style
 *
 * @param name/*w w w. j  a  v a  2  s  .  c  o  m*/
 *            Description of Parameter
 * @param listener
 *            Description of Parameter
 * @return Description of the Returned Value
 * @deprecated (3.0) not used
 */
@Deprecated
public static JButton createButton(String name, ActionListener listener) {
    JButton button = new JButton(getImage(name + ".on.gif")); // $NON-NLS-1$
    button.setDisabledIcon(getImage(name + ".off.gif")); // $NON-NLS-1$
    button.setRolloverIcon(getImage(name + ".over.gif")); // $NON-NLS-1$
    button.setPressedIcon(getImage(name + ".down.gif")); // $NON-NLS-1$
    button.setActionCommand(name);
    button.addActionListener(listener);
    button.setRolloverEnabled(true);
    button.setFocusPainted(false);
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setPreferredSize(new Dimension(24, 24));
    return button;
}

From source file:org.datavyu.views.DataControllerV.java

/**
 * Helper method for Building a button for the data controller - sets the
 * icon, selected icon, action map and name.
 *
 * @param rMap The resource map that holds the icons for this button.
 * @param aMap The action map holding the action that this button invokes.
 * @param name The prefix to use when looking for actions and buttons.
 * @param modifier The modifier (if any) to apply to the prefix. Maybe null.
 *
 * @return A configured button.//from  ww  w  . j  a v a2 s. co m
 */
private JButton buildButton(final ResourceMap rMap, final ActionMap aMap, final String name,
        final String modifier) {

    JButton result = new JButton();
    result.setAction(aMap.get(name + "Action"));
    if (modifier == null) {
        result.setIcon(rMap.getIcon(name + "Button.icon"));
        result.setPressedIcon(rMap.getIcon(name + "SelectedButton.icon"));
    } else {
        result.setIcon(rMap.getIcon(modifier + name + "Button.icon"));
        result.setPressedIcon(rMap.getIcon(modifier + name + "SelectedButton.icon"));
    }
    result.setFocusPainted(false);
    result.setName(name + "Button");

    return result;
}

From source file:org.eclipse.om2m.ipe.sample.gui.GUI.java

/**
 * Creates the frame.//from w ww.  ja v  a  2  s.c o  m
 */
public GUI() {
    setLocationByPlatform(true);
    setVisible(false);
    setResizable(false);
    setTitle("Sample Simulated IPE");
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570);

    contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPanel);
    contentPanel.setLayout(null);

    // Lamp0 Switcher0
    JPanel panel_Lamp0 = new JPanel();
    panel_Lamp0.setBounds(10, 5, 319, 260);
    contentPanel.add(panel_Lamp0);
    panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp0.setLayout(null);
    LABEL_LAMP_0.setIcon(iconLampOFF);
    LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_0.setBounds(10, 9, 149, 240);
    panel_Lamp0.add(LABEL_LAMP_0);

    // Lamp0 Switch Button
    JButton button_Lamp0 = new JButton();
    button_Lamp0.setOpaque(false);
    button_Lamp0.setPressedIcon(iconButtonON);
    button_Lamp0.setIcon(iconButtonOFF);
    button_Lamp0.setBounds(187, 44, 122, 155);
    panel_Lamp0.add(button_Lamp0);
    button_Lamp0.setMinimumSize(new Dimension(30, 23));
    button_Lamp0.setMaximumSize(new Dimension(30, 23));
    button_Lamp0.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher0 = new JLabel("Switch LAMP_0");
    labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher0.setFocusCycleRoot(true);
    labelSwitcher0.setBorder(null);
    labelSwitcher0.setAutoscrolls(true);
    labelSwitcher0.setBounds(187, 199, 118, 29);
    panel_Lamp0.add(labelSwitcher0);
    // Listener for Lamp0 Switch Button
    button_Lamp0.addActionListener(new java.awt.event.ActionListener() {
        // Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp0 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp0 state
                    SampleMonitor.switchLamp(LAMP_0);
                }
            }.start();
        }
    });

    // Lamp1 Switcher 1
    JPanel panel_Lamp1 = new JPanel();
    panel_Lamp1.setBounds(10, 271, 319, 260);
    contentPanel.add(panel_Lamp1);
    panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp1.setLayout(null);

    LABEL_LAMP_1.setIcon(iconLampOFF);
    LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_1.setBounds(10, 9, 154, 240);
    panel_Lamp1.add(LABEL_LAMP_1);

    // Lamp1 Switch Button
    JButton button_Lamp1 = new JButton();
    button_Lamp1.setOpaque(false);
    button_Lamp1.setPressedIcon(iconButtonON);
    button_Lamp1.setIcon(iconButtonOFF);
    button_Lamp1.setBounds(187, 44, 122, 156);
    panel_Lamp1.add(button_Lamp1);
    button_Lamp1.setMinimumSize(new Dimension(30, 23));
    button_Lamp1.setMaximumSize(new Dimension(30, 23));
    button_Lamp1.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher1 = new JLabel("Switch LAMP_1");
    labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher1.setFocusCycleRoot(true);
    labelSwitcher1.setBorder(null);
    labelSwitcher1.setAutoscrolls(true);
    labelSwitcher1.setBounds(187, 199, 118, 29);
    panel_Lamp1.add(labelSwitcher1);
    // Listener for Lamp1 Switch Button
    button_Lamp1.addActionListener(new java.awt.event.ActionListener() {
        //Switch Button clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp1 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp1 state
                    SampleMonitor.switchLamp(LAMP_1);
                }
            }.start();
        }
    });

    // Switcher All lamps
    JButton buttonAllLamp = new JButton();
    buttonAllLamp.setOpaque(false);
    buttonAllLamp.setPressedIcon(iconButtonON);
    buttonAllLamp.setIcon(iconButtonOFF);
    buttonAllLamp.setBounds(339, 190, 145, 168);
    contentPanel.add(buttonAllLamp);
    buttonAllLamp.setMinimumSize(new Dimension(30, 23));
    buttonAllLamp.setMaximumSize(new Dimension(30, 23));
    buttonAllLamp.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitchAll = new JLabel("Switch All");
    labelSwitchAll.setAutoscrolls(true);
    labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitchAll.setFocusCycleRoot(true);
    labelSwitchAll.setBorder(null);
    labelSwitchAll.setBounds(371, 369, 85, 29);
    contentPanel.add(labelSwitchAll);
    // Listener of Switch all Button
    buttonAllLamp.addActionListener(new java.awt.event.ActionListener() {
        // Switch Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change all lamps states
            new Thread() {
                public void run() {
                    // Send switch all request to create a content with the current State
                    SampleMonitor.switchAll();
                }
            }.start();
        }
    });

    lampObserver = new SampleModel.LampObserver() {

        @Override
        public void onLampStateChange(String lampId, boolean state) {
            setLabel(lampId, state);
        }
    };
    SampleModel.addObserver(lampObserver);
}

From source file:org.eclipse.om2m.ipu.sample.GUI.java

/**
 * Creates the frame./*from   w ww . j  ava 2s  . c  om*/
 */
public GUI() {
    setLocationByPlatform(true);
    setResizable(false);
    setTitle("Sample Simulated IPU");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 500) / 2, (screenSize.height - 570) / 2, 497, 570);

    contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPanel);
    contentPanel.setLayout(null);

    // Lamp0 Switcher0
    JPanel panel_Lamp0 = new JPanel();
    panel_Lamp0.setBounds(10, 5, 319, 260);
    contentPanel.add(panel_Lamp0);
    panel_Lamp0.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp0.setLayout(null);
    LABEL_LAMP_0.setIcon(iconLampOFF);
    LABEL_LAMP_0.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_0.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_0.setBounds(10, 9, 149, 240);
    panel_Lamp0.add(LABEL_LAMP_0);

    // Lamp0 Switch Button
    JButton button_Lamp0 = new JButton();
    button_Lamp0.setOpaque(false);
    button_Lamp0.setPressedIcon(iconButtonON);
    button_Lamp0.setIcon(iconButtonOFF);
    button_Lamp0.setBounds(187, 44, 122, 155);
    panel_Lamp0.add(button_Lamp0);
    button_Lamp0.setMinimumSize(new Dimension(30, 23));
    button_Lamp0.setMaximumSize(new Dimension(30, 23));
    button_Lamp0.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher0 = new JLabel("Switch LAMP_0");
    labelSwitcher0.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher0.setFocusCycleRoot(true);
    labelSwitcher0.setBorder(null);
    labelSwitcher0.setAutoscrolls(true);
    labelSwitcher0.setBounds(187, 199, 118, 29);
    panel_Lamp0.add(labelSwitcher0);
    // Listener for Lamp0 Switch Button
    button_Lamp0.addActionListener(new java.awt.event.ActionListener() {
        // Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp0 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp0 state
                    Switchs.switchLamp(LAMP_0, !SampleMonitor.LAMPS.get(LAMP_0).getState());
                }
            }.start();
        }
    });

    // Lamp1 Switcher 1
    JPanel panel_Lamp1 = new JPanel();
    panel_Lamp1.setBounds(10, 271, 319, 260);
    contentPanel.add(panel_Lamp1);
    panel_Lamp1.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
    panel_Lamp1.setLayout(null);

    LABEL_LAMP_1.setIcon(iconLampOFF);
    LABEL_LAMP_1.setHorizontalTextPosition(SwingConstants.CENTER);
    LABEL_LAMP_1.setHorizontalAlignment(SwingConstants.CENTER);
    LABEL_LAMP_1.setBounds(10, 9, 154, 240);
    panel_Lamp1.add(LABEL_LAMP_1);

    // Lamp1 Switch Button
    JButton button_Lamp1 = new JButton();
    button_Lamp1.setOpaque(false);
    button_Lamp1.setPressedIcon(iconButtonON);
    button_Lamp1.setIcon(iconButtonOFF);
    button_Lamp1.setBounds(187, 44, 122, 156);
    panel_Lamp1.add(button_Lamp1);
    button_Lamp1.setMinimumSize(new Dimension(30, 23));
    button_Lamp1.setMaximumSize(new Dimension(30, 23));
    button_Lamp1.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitcher1 = new JLabel("Switch LAMP_1");
    labelSwitcher1.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitcher1.setFocusCycleRoot(true);
    labelSwitcher1.setBorder(null);
    labelSwitcher1.setAutoscrolls(true);
    labelSwitcher1.setBounds(187, 199, 118, 29);
    panel_Lamp1.add(labelSwitcher1);
    // Listener for Lamp1 Switch Button
    button_Lamp1.addActionListener(new java.awt.event.ActionListener() {
        //Switch Button clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change Lamp1 State
            new Thread() {
                public void run() {
                    // Send switch request to switch lamp1 state
                    Switchs.switchLamp(LAMP_1, !SampleMonitor.LAMPS.get(LAMP_1).getState());
                }
            }.start();
        }
    });

    // Switcher All lamps
    JButton buttonAllLamp = new JButton();
    buttonAllLamp.setOpaque(false);
    buttonAllLamp.setPressedIcon(iconButtonON);
    buttonAllLamp.setIcon(iconButtonOFF);
    buttonAllLamp.setBounds(339, 190, 145, 168);
    contentPanel.add(buttonAllLamp);
    buttonAllLamp.setMinimumSize(new Dimension(30, 23));
    buttonAllLamp.setMaximumSize(new Dimension(30, 23));
    buttonAllLamp.setPreferredSize(new Dimension(30, 23));

    JLabel labelSwitchAll = new JLabel("Switch All");
    labelSwitchAll.setAutoscrolls(true);
    labelSwitchAll.setFont(new Font("Vani", Font.BOLD | Font.ITALIC, 14));
    labelSwitchAll.setFocusCycleRoot(true);
    labelSwitchAll.setBorder(null);
    labelSwitchAll.setBounds(371, 369, 85, 29);
    contentPanel.add(labelSwitchAll);
    // Listener of Switch all Button
    buttonAllLamp.addActionListener(new java.awt.event.ActionListener() {
        // Switch Button Clicked
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            // Change all lamps states
            new Thread() {
                public void run() {
                    // Send switch all request to create a content with the current State
                    Switchs.switchAll(!(SampleMonitor.LAMPS.get(LAMP_0).getState()
                            && SampleMonitor.LAMPS.get(LAMP_1).getState()));
                }
            }.start();
        }
    });
}