Example usage for javax.swing JLabel setFocusCycleRoot

List of usage examples for javax.swing JLabel setFocusCycleRoot

Introduction

In this page you can find the example usage for javax.swing JLabel setFocusCycleRoot.

Prototype

public void setFocusCycleRoot(boolean focusCycleRoot) 

Source Link

Document

Sets whether this Container is the root of a focus traversal cycle.

Usage

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

/**
 * Creates the frame.//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.//w  ww. j a v  a 2s  . c  o  m
 */
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();
        }
    });
}