Example usage for javax.swing JPanel setComponentOrientation

List of usage examples for javax.swing JPanel setComponentOrientation

Introduction

In this page you can find the example usage for javax.swing JPanel setComponentOrientation.

Prototype

public void setComponentOrientation(ComponentOrientation o) 

Source Link

Document

Sets the language-sensitive orientation that is to be used to order the elements or text within this component.

Usage

From source file:Main.java

public static JPanel getPanelFlowLayoutHorizontal(int w, int h, int type) {
    JPanel panel = new JPanel();
    FlowLayout layout = new FlowLayout();
    layout.setAlignment(type);/*from  w w w .j  a  va2  s . c o  m*/
    panel.setLayout(layout);
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    panel.setPreferredSize(getControlDimension(w, h));
    panel.setMinimumSize(getControlDimension(w, h));
    return panel;
}

From source file:Main.java

public static void setFont(JComponent component, Font font, ComponentOrientation componentOrientation) {
    component.setFont(font);/*from  w w w.j  a  v a2 s .c om*/

    if (component instanceof JTextField) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JTextArea) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JTextPane) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JScrollPane) {
        for (Component cmp : component.getComponents()) {
            setFont((JComponent) cmp, font, componentOrientation);
        }
    }

    if (component instanceof JTree) {
        component.setComponentOrientation(componentOrientation);
    }

    if (component instanceof JComboBox) {
        component.setComponentOrientation(componentOrientation);
        JComboBox comboBox = (JComboBox) component;
        ((BasicComboBoxRenderer) comboBox.getRenderer()).setHorizontalAlignment(SwingConstants.RIGHT);
        ((BasicComboBoxRenderer) comboBox.getRenderer()).setAutoscrolls(true);
        comboBox.setMaximumRowCount(20);
    }

    /* if(component instanceof JLabel) {
     ((JLabel)component).setHorizontalTextPosition(SwingConstants.RIGHT);
     }*/

    if (component instanceof JPanel) {
        JPanel panel = (JPanel) component;
        if (panel.getBorder() != null && panel.getBorder() instanceof TitledBorder) {
            ((TitledBorder) panel.getBorder()).setTitleFont(font);
            panel.setComponentOrientation(componentOrientation);
        }
        for (Component cmp : component.getComponents()) {
            setFont((JComponent) cmp, font, componentOrientation);
        }
    }

    if (component instanceof JTabbedPane) {
        JTabbedPane tabbedPane = (JTabbedPane) component;
        int tabCount = tabbedPane.getTabCount();
        for (int i = 0; i < tabCount; i++) {
            setFont((JComponent) tabbedPane.getComponentAt(i), font, componentOrientation);
        }
    }
}

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

/**
 * Helper factory method for creating a horizontal box layout {@link JPanel} that takes into account the locale.
 *
 * @return the created panel// www .  j  a  va 2  s  .  co  m
 */
protected JPanel createHorizontalPanel() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.getOrientation(i18n.getLocale()));
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    return panel;
}

From source file:layout.FlowLayoutDemo.java

public void addComponentsToPane(final Container pane) {
    final JPanel compsToExperiment = new JPanel();
    compsToExperiment.setLayout(experimentLayout);
    experimentLayout.setAlignment(FlowLayout.TRAILING);
    JPanel controls = new JPanel();
    controls.setLayout(new FlowLayout());

    LtoRbutton = new JRadioButton(LtoR);
    LtoRbutton.setActionCommand(LtoR);/*  ww w.  j a  va2s. co  m*/
    LtoRbutton.setSelected(true);
    RtoLbutton = new JRadioButton(RtoL);
    RtoLbutton.setActionCommand(RtoL);

    //Add buttons to the experiment layout
    compsToExperiment.add(new JButton("Button 1"));
    compsToExperiment.add(new JButton("Button 2"));
    compsToExperiment.add(new JButton("Button 3"));
    compsToExperiment.add(new JButton("Long-Named Button 4"));
    compsToExperiment.add(new JButton("5"));
    //Left to right component orientation is selected by default
    compsToExperiment.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    //Add controls to set up the component orientation in the experiment layout
    final ButtonGroup group = new ButtonGroup();
    group.add(LtoRbutton);
    group.add(RtoLbutton);
    controls.add(LtoRbutton);
    controls.add(RtoLbutton);
    controls.add(applyButton);

    //Process the Apply component orientation button press
    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();
            //Check the selection
            if (command.equals("Left to right")) {
                compsToExperiment.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            } else {
                compsToExperiment.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            }
            //update the experiment layout
            compsToExperiment.validate();
            compsToExperiment.repaint();
        }
    });
    pane.add(compsToExperiment, BorderLayout.CENTER);
    pane.add(controls, BorderLayout.SOUTH);
    ;
}

From source file:com.xilinx.kintex7.MainScreen.java

private JPanel testPanelItems1() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-1:"));
    t2_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t2_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t2_o1.setSelected(true);//from w ww  .jav  a 2 s. c  o  m
    t2_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t2_o1.setSelected(true);
                return;
            }
            if (t2_o1.isSelected()) {
                // disable others
                test2_option = DriverInfo.ENABLE_LOOPBACK;
                t2_o2.setSelected(false);
                t2_o3.setSelected(false);
            } else {
                if (!t2_o2.isSelected() && !t2_o3.isSelected()) {
                    test2_option = DriverInfo.CHECKER;
                    t2_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t2_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t2_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o2.isSelected()) {
                // disable others
                test2_option = DriverInfo.CHECKER;
                t2_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.GENERATOR;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t2_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t2_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o3.isSelected()) {
                // disable others
                test2_option = DriverInfo.GENERATOR;
                t2_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t2_o1);
    ip.add(t2_o2);
    ip.add(t2_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t2_psize = new JTextField("32768", 5);
    panel.add(t2_psize);
    stest = new JButton("Start");
    stest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {

            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_ON && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            if (stest.getText().equals("Start")) {
                int psize = 0;
                dataMismatch2 = errcnt1 = false;
                try {
                    psize = Integer.parseInt(t2_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(1, test2_option, psize);
                t2_o1.setEnabled(false);
                t2_o2.setEnabled(false);
                t2_o3.setEnabled(false);
                t2_psize.setEnabled(false);
                stest.setText("Stop");
                testStarted1 = true;
                updateLog("[Test Started for Data Path-1]", logStatus);

            } else if (stest.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                stest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest2();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(stest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t2_o1.setSelected(false);
        t2_o2.setSelected(false);
        t2_o3.setSelected(false);
        t2_o1.setEnabled(false);
        t2_o2.setEnabled(false);
        t2_o3.setEnabled(false);
        t2_psize.setEnabled(false);
        t2_psize.setText("");
        stest.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.kintex7.MainScreen.java

private JPanel testPanelItems() {
    JPanel panel1 = new JPanel();

    JPanel panel = new JPanel();

    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    panel.add(new JLabel("Data Path-0:"));
    t1_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t1_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t1_o1.setSelected(true);//w  w  w  .j a  va 2  s .c  om
    t1_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t1_o1.setSelected(true);
                return;
            }
            if (t1_o1.isSelected()) {
                // disable others
                test1_option = DriverInfo.ENABLE_LOOPBACK;
                t1_o2.setSelected(false);
                t1_o3.setSelected(false);
            } else {
                if (!t1_o2.isSelected() && !t1_o3.isSelected()) {
                    test1_option = DriverInfo.CHECKER;
                    t1_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t1_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t1_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o2.isSelected()) {
                // disable others
                test1_option = DriverInfo.CHECKER;
                t1_o1.setSelected(false);
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.GENERATOR;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }

            }
        }
    });
    t1_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t1_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o3.isSelected()) {
                // disable others
                test1_option = DriverInfo.GENERATOR;
                t1_o1.setSelected(false);
                //t1_o2.setSelected(false);
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t1_o1);
    ip.add(t1_o2);
    ip.add(t1_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t1_psize = new JTextField("32768", 5);

    panel.add(t1_psize);
    startTest = new JButton("Start");
    startTest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {

            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_OFF && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib == LED_ON && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (startTest.getText().equals("Start")) {
                int psize = 0;
                dataMismatch0 = errcnt0 = false;
                try {
                    psize = Integer.parseInt(t1_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt0 || psize > maxpkt0) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt0 + " to " + maxpkt0 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(0, test1_option, psize);
                // disable components
                t1_o1.setEnabled(false);
                t1_o2.setEnabled(false);
                t1_o3.setEnabled(false);
                t1_psize.setEnabled(false);
                startTest.setText("Stop");
                testStarted = true;
                updateLog("[Test Started for Data Path-0]", logStatus);
            } else if (startTest.getText().equals("Stop")) {
                startTest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest1();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(startTest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t1_o1.setSelected(false);
        t1_o2.setSelected(false);
        t1_o3.setSelected(false);
        t1_o1.setEnabled(false);
        t1_o2.setEnabled(false);
        t1_o3.setEnabled(false);
        t1_psize.setEnabled(false);
        t1_psize.setText("");
        startTest.setEnabled(false);
    }
    panel1.add(panel);
    return panel1;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems2() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-2:"));
    t3_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t3_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t3_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t3_o1.setSelected(true);/*from  w ww  .ja  v  a 2  s  .c om*/
    t3_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t3_o1.setSelected(true);
                return;
            }
            if (t3_o1.isSelected()) {
                // disable others
                test3_option = DriverInfo.ENABLE_LOOPBACK;
                t3_o2.setSelected(false);
                t3_o3.setSelected(false);
            } else {
                if (!t3_o2.isSelected() && !t3_o3.isSelected()) {
                    test3_option = DriverInfo.CHECKER;
                    t3_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t3_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t3_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t3_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t3_o2.isSelected()) {
                // disable others
                test3_option = DriverInfo.CHECKER;
                t3_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t3_o3.isSelected())
                    test3_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t3_o3.isSelected())
                    test3_option = DriverInfo.GENERATOR;
                else {
                    test3_option = DriverInfo.ENABLE_LOOPBACK;
                    t3_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t3_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t3_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t3_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t3_o3.isSelected()) {
                // disable others
                test3_option = DriverInfo.GENERATOR;
                t3_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t3_o2.isSelected())
                    test3_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t3_o2.isSelected())
                    test3_option = DriverInfo.CHECKER;
                else {
                    test3_option = DriverInfo.ENABLE_LOOPBACK;
                    t3_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t3_o1);
    ip.add(t3_o2);
    ip.add(t3_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t3_psize = new JTextField("32768", 5);
    panel.add(t3_psize);
    s3test = new JButton("Start");
    //s3test.setEnabled(false);
    s3test.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_ON && lstats.phy3 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (s3test.getText().equals("Start")) {
                int psize = 0;
                dataMismatch4 = errcnt2 = false;
                try {
                    psize = Integer.parseInt(t3_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(2, test3_option, psize);
                t3_o1.setEnabled(false);
                t3_o2.setEnabled(false);
                t3_o3.setEnabled(false);
                t3_psize.setEnabled(false);
                s3test.setText("Stop");
                testStarted2 = true;
                updateLog("[Test Started for Data Path-2]", logStatus);

            } else if (s3test.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                s3test.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest3();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(s3test);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t3_o1.setSelected(false);
        t3_o2.setSelected(false);
        t3_o3.setSelected(false);
        t3_o1.setEnabled(false);
        t3_o2.setEnabled(false);
        t3_o3.setEnabled(false);
        t3_psize.setEnabled(false);
        t3_psize.setText("");
        s3test.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems1() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-1:"));
    t2_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t2_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t2_o1.setSelected(true);/*from  w ww . j a v  a  2s  . c o  m*/
    t2_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t2_o1.setSelected(true);
                return;
            }
            if (t2_o1.isSelected()) {
                // disable others
                test2_option = DriverInfo.ENABLE_LOOPBACK;
                t2_o2.setSelected(false);
                t2_o3.setSelected(false);
            } else {
                if (!t2_o2.isSelected() && !t2_o3.isSelected()) {
                    test2_option = DriverInfo.CHECKER;
                    t2_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t2_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t2_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o2.isSelected()) {
                // disable others
                test2_option = DriverInfo.CHECKER;
                t2_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o3.isSelected())
                    test2_option = DriverInfo.GENERATOR;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t2_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t2_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t2_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t2_o3.isSelected()) {
                // disable others
                test2_option = DriverInfo.GENERATOR;
                t2_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t2_o2.isSelected())
                    test2_option = DriverInfo.CHECKER;
                else {
                    test2_option = DriverInfo.ENABLE_LOOPBACK;
                    t2_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t2_o1);
    ip.add(t2_o2);
    ip.add(t2_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t2_psize = new JTextField("32768", 5);
    panel.add(t2_psize);
    stest = new JButton("Start");
    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {

    } else
        stest.setEnabled(false);
    stest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (stest.getText().equals("Start")) {
                int psize = 0;
                dataMismatch2 = errcnt1 = false;
                try {
                    psize = Integer.parseInt(t2_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(1, test2_option, psize);
                t2_o1.setEnabled(false);
                t2_o2.setEnabled(false);
                t2_o3.setEnabled(false);
                t2_psize.setEnabled(false);
                stest.setText("Stop");
                testStarted1 = true;
                updateLog("[Test Started for Data Path-1]", logStatus);

            } else if (stest.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                stest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest2();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(stest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t2_o1.setSelected(false);
        t2_o2.setSelected(false);
        t2_o3.setSelected(false);
        t2_o1.setEnabled(false);
        t2_o2.setEnabled(false);
        t2_o3.setEnabled(false);
        t2_psize.setEnabled(false);
        t2_psize.setText("");
        stest.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems3() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    /*panel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Test Parameters-1"),
                BorderFactory.createEmptyBorder()));*/
    float w = (float) ((float) width * 0.4);
    //panel.setPreferredSize(new Dimension((int)w, 100));
    panel.add(new JLabel("Data Path-3:"));
    t4_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t4_o1.setToolTipText("This loops back software generated traffic at DMA user interface");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t4_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t4_o1.setSelected(true);/*from w ww.  j  a v a 2  s . c  o m*/
    t4_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t4_o1.setSelected(true);
                return;
            }
            if (t4_o1.isSelected()) {
                // disable others
                test4_option = DriverInfo.ENABLE_LOOPBACK;
                t4_o2.setSelected(false);
                t4_o3.setSelected(false);
            } else {
                if (!t4_o2.isSelected() && !t4_o3.isSelected()) {
                    test4_option = DriverInfo.CHECKER;
                    t4_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t4_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t4_o2.setToolTipText(
                "This enables Checker in hardware at DMA user interface verifying traffic generated by software");
    t4_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t4_o2.isSelected()) {
                // disable others
                test4_option = DriverInfo.CHECKER;
                t4_o1.setSelected(false);
                //t2_o3.setSelected(false);
                if (t4_o3.isSelected())
                    test4_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t4_o3.isSelected())
                    test4_option = DriverInfo.GENERATOR;
                else {
                    test4_option = DriverInfo.ENABLE_LOOPBACK;
                    t4_o1.setSelected(true);
                }
            }
        }
    });
    //b2.setEnabled(false);
    t4_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t4_o3.setToolTipText("This enables traffic generator in hardware at the DMA user interface");
    t4_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t4_o3.isSelected()) {
                // disable others
                test4_option = DriverInfo.GENERATOR;
                t4_o1.setSelected(false);
                //t2_o2.setSelected(false);
                if (t4_o2.isSelected())
                    test4_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t4_o2.isSelected())
                    test4_option = DriverInfo.CHECKER;
                else {
                    test4_option = DriverInfo.ENABLE_LOOPBACK;
                    t4_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t4_o1);
    ip.add(t4_o2);
    ip.add(t4_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t4_psize = new JTextField("32768", 5);
    panel.add(t4_psize);
    s4test = new JButton("Start");
    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {

    } else
        stest.setEnabled(false);
    s4test.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_ON && lstats.phy3 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy2 == LED_OFF || lstats.phy3 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (s4test.getText().equals("Start")) {
                int psize = 0;
                dataMismatch6 = errcnt3 = false;
                try {
                    psize = Integer.parseInt(t4_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt1 || psize > maxpkt1) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt1 + " to " + maxpkt1 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(3, test4_option, psize);
                t4_o1.setEnabled(false);
                t4_o2.setEnabled(false);
                t4_o3.setEnabled(false);
                t4_o2.setEnabled(false);
                t4_psize.setEnabled(false);
                s4test.setText("Stop");
                testStarted3 = true;
                updateLog("[Test Started for Data Path-3]", logStatus);

            } else if (s4test.getText().equals("Stop")) {
                // Disable button to avoid multiple clicks
                s4test.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest4();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(s4test);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t4_o1.setSelected(false);
        t4_o2.setSelected(false);
        t4_o3.setSelected(false);
        t4_o1.setEnabled(false);
        t4_o2.setEnabled(false);
        t4_o3.setEnabled(false);
        t4_psize.setEnabled(false);
        t4_psize.setText("");
        s4test.setEnabled(false);
    }
    return panel;
}

From source file:com.xilinx.virtex7.MainScreen.java

private JPanel testPanelItems() {
    //JPanel panel1 = new JPanel();

    JPanel panel = new JPanel();

    panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    panel.add(new JLabel("Data Path-0:"));
    t1_o1 = new JCheckBox("Loopback");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o1.setToolTipText("This loops back software generated traffic in hardware");
    else if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV)
        t1_o1.setToolTipText("This loops back software generated raw Ethernet frames at 10G PHY");

    t1_o1.setSelected(true);//from w ww.  jav a  2 s .  c  o  m
    t1_o1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                t1_o1.setSelected(true);
                return;
            }
            if (t1_o1.isSelected()) {
                // disable others
                test1_option = DriverInfo.ENABLE_LOOPBACK;
                t1_o2.setSelected(false);
                t1_o3.setSelected(false);
            } else {
                if (!t1_o2.isSelected() && !t1_o3.isSelected()) {
                    test1_option = DriverInfo.CHECKER;
                    t1_o2.setSelected(true);
                }
            }
        }
    });
    //b1.setSelected(true);
    t1_o2 = new JCheckBox("HW Checker");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o2.setToolTipText("This enables Checker in hardware verifying traffic generated by software");
    t1_o2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o2.isSelected()) {
                // disable others
                test1_option = DriverInfo.CHECKER;
                t1_o1.setSelected(false);
                //t1_o3.setSelected(false);
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o3.isSelected())
                    test1_option = DriverInfo.GENERATOR;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }

            }
        }
    });
    //b2.setEnabled(false);
    t1_o3 = new JCheckBox("HW Generator");
    if (mode == LandingPage.PERFORMANCE_MODE_GENCHK || mode == LandingPage.PERFORMANCE_MODE_GENCHK_DV)
        t1_o3.setToolTipText("This enables traffic generator in hardware");
    t1_o3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (t1_o3.isSelected()) {
                // disable others
                test1_option = DriverInfo.GENERATOR;
                t1_o1.setSelected(false);
                //t1_o2.setSelected(false);
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER_GEN;
            } else {
                if (t1_o2.isSelected())
                    test1_option = DriverInfo.CHECKER;
                else {
                    test1_option = DriverInfo.ENABLE_LOOPBACK;
                    t1_o1.setSelected(true);
                }
            }
        }
    });
    //b3.setEnabled(false);
    JPanel ip = new JPanel();
    ip.setLayout(new BoxLayout(ip, BoxLayout.PAGE_AXIS));
    ip.add(t1_o1);
    ip.add(t1_o2);
    ip.add(t1_o3);
    panel.add(ip);
    panel.add(new JLabel("Packet Size (bytes):"));
    t1_psize = new JTextField("32768", 5);

    panel.add(t1_psize);
    startTest = new JButton("Start");
    startTest.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            //Check for led status and start the test
            if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
                if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_ON && lstats.phy1 == LED_ON)) {
                    JOptionPane.showMessageDialog(null, "DDR3 is not calibrated. Test cannot be started",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_OFF && lstats.ddrCalib2 == LED_OFF
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 is not calibrated and 10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON
                        && (lstats.phy0 == LED_OFF || lstats.phy1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null, "10G-PHY link is down. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }

            if (startTest.getText().equals("Start")) {
                // checking condition for DDR3 SODIMM
                if (t1_o1.isSelected() && !(lstats.ddrCalib1 == LED_ON && lstats.ddrCalib2 == LED_ON)) {
                    if (lstats.ddrCalib1 == LED_OFF || lstats.ddrCalib2 == LED_OFF) {
                        JOptionPane.showMessageDialog(null,
                                "DDR3 SODIMM is not calibrated. Test cannot be started", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    return;
                } else if (t1_o2.isSelected() && (lstats.ddrCalib1 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 SODIMM-A is not calibrated. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                } else if (t1_o3.isSelected() && (lstats.ddrCalib2 == LED_OFF)) {
                    JOptionPane.showMessageDialog(null,
                            "DDR3 SODIMM-B is not calibrated. Test cannot be started", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                int psize = 0;
                dataMismatch0 = errcnt0 = false;
                try {
                    psize = Integer.parseInt(t1_psize.getText());
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Only Natural numbers are allowed", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (psize < minpkt0 || psize > maxpkt0) {
                    JOptionPane.showMessageDialog(null,
                            "Packet size must be within " + minpkt0 + " to " + maxpkt0 + " bytes", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
                di.startTest(0, test1_option, psize);
                // disable components
                t1_o1.setEnabled(false);
                t1_o2.setEnabled(false);
                t1_o3.setEnabled(false);
                t1_psize.setEnabled(false);
                startTest.setText("Stop");
                testStarted = true;
                updateLog("[Test Started for Data Path-0]", logStatus);
            } else if (startTest.getText().equals("Stop")) {
                startTest.setEnabled(false);
                SwingWorker worker = new SwingWorker<Void, Void>() {

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            stopTest1();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                };
                worker.execute();
            }
        }
    });
    panel.add(startTest);
    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        t1_o1.setSelected(false);
        t1_o2.setSelected(false);
        t1_o3.setSelected(false);
        t1_o1.setEnabled(false);
        t1_o2.setEnabled(false);
        t1_o3.setEnabled(false);
        t1_psize.setEnabled(false);
        t1_psize.setText("");
        startTest.setEnabled(false);
    }
    //panel1.add(panel);
    return panel;
}