Example usage for java.awt ComponentOrientation LEFT_TO_RIGHT

List of usage examples for java.awt ComponentOrientation LEFT_TO_RIGHT

Introduction

In this page you can find the example usage for java.awt ComponentOrientation LEFT_TO_RIGHT.

Prototype

ComponentOrientation LEFT_TO_RIGHT

To view the source code for java.awt ComponentOrientation LEFT_TO_RIGHT.

Click Source Link

Document

Items run left to right and lines flow top to bottom Examples: English, French.

Usage

From source file:com.lottery.gui.MainLotteryForm.java

public void init() {
    initComponents();/*from  w  w  w .j  ava2 s  .  c  o  m*/
    setTitle("Lottery");
    //        ballNumbersPanel.setLayout(new BoxLayout(ballNumbersPanel, BoxLayout.Y_AXIS));
    ballNumbersPanel.setLayout(new GridBagLayout());
    ballNumbersPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    //        c.fill = GridBagConstraints.HORIZONTAL;

    tfBuyerName.setFocusable(true);
    tfBuyerName.requestFocusInWindow();

    WinnerTableModel model = new WinnerTableModel();
    model.setData(winTicketTables);
    tblWinners.setModel(model);

    resetGame();
    //        pnStart.setLayout(new GridBagLayout());
    //        pnStart.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    //        DateFormat format = new SimpleDateFormat("yyyy--MMMM--dd");
    //        GridBagConstraints pnStartConstraint = new GridBagConstraints();
    //        pnStartConstraint.fill = GridBagConstraints.HORIZONTAL;
    //        
    //        lbDrawDate = new JLabel("Date");
    //        pnStartConstraint.gridx = 0;
    //        pnStartConstraint.gridy = 0;
    //        pnStart.add(lbDrawDate, pnStartConstraint);
    //                        
    //        tfDrawDate = new JFormattedTextField(format);

    //        pnStartConstraint.gridx = 1;
    //        pnStartConstraint.gridy = 0;
    //        pnStart.add(tfDrawDate, pnStartConstraint);
}

From source file:com.oracle.tutorial.jdbc.CoffeesFrame.java

public CoffeesFrame(JDBCTutorialUtilities settingsArg) throws SQLException {

    super("The Coffee Break: COFFEES Table"); // Set window title

    this.settings = settingsArg;
    connection = settings.getConnection();

    // Close connections exit the application when the user
    // closes the window

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {

            try {
                connection.close();/* w w  w  . j  a va  2 s. c  om*/
            } catch (SQLException sqle) {
                JDBCTutorialUtilities.printSQLException(sqle);
            }
            System.exit(0);
        }
    });

    // Initialize and lay out window controls

    CachedRowSet myCachedRowSet = getContentsOfCoffeesTable();
    myCoffeesTableModel = new CoffeesTableModel(myCachedRowSet);
    myCoffeesTableModel.addEventHandlersToRowSet(this);

    table = new JTable(); // Displays the table
    table.setModel(myCoffeesTableModel);

    label_COF_NAME = new JLabel();
    label_SUP_ID = new JLabel();
    label_PRICE = new JLabel();
    label_SALES = new JLabel();
    label_TOTAL = new JLabel();

    textField_COF_NAME = new JTextField(10);
    textField_SUP_ID = new JTextField(10);
    textField_PRICE = new JTextField(10);
    textField_SALES = new JTextField(10);
    textField_TOTAL = new JTextField(10);

    button_ADD_ROW = new JButton();
    button_UPDATE_DATABASE = new JButton();
    button_DISCARD_CHANGES = new JButton();

    label_COF_NAME.setText("Coffee Name:");
    label_SUP_ID.setText("Supplier ID:");
    label_PRICE.setText("Price:");
    label_SALES.setText("Sales:");
    label_TOTAL.setText("Total Sales:");

    textField_COF_NAME.setText("Enter new coffee name");
    textField_SUP_ID.setText("101");
    textField_PRICE.setText("0");
    textField_SALES.setText("0");
    textField_TOTAL.setText("0");

    button_ADD_ROW.setText("Add row to table");
    button_UPDATE_DATABASE.setText("Update database");
    button_DISCARD_CHANGES.setText("Discard changes");

    // Place the components within the container contentPane; use GridBagLayout
    // as the layout.

    Container contentPane = getContentPane();
    contentPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    contentPane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.5;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    contentPane.add(new JScrollPane(table), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(label_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(textField_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.25;
    c.weighty = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(label_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(textField_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(label_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(textField_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(label_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(textField_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(label_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(textField_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_ADD_ROW, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_UPDATE_DATABASE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    contentPane.add(button_DISCARD_CHANGES, c);

    // Add listeners for the buttons in the application

    button_ADD_ROW.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            JOptionPane.showMessageDialog(CoffeesFrame.this, new String[] { "Adding the following row:",
                    "Coffee name: [" + textField_COF_NAME.getText() + "]",
                    "Supplier ID: [" + textField_SUP_ID.getText() + "]",
                    "Price: [" + textField_PRICE.getText() + "]", "Sales: [" + textField_SALES.getText() + "]",
                    "Total: [" + textField_TOTAL.getText() + "]" });

            try {

                myCoffeesTableModel.insertRow(textField_COF_NAME.getText(),
                        Integer.parseInt(textField_SUP_ID.getText().trim()),
                        Float.parseFloat(textField_PRICE.getText().trim()),
                        Integer.parseInt(textField_SALES.getText().trim()),
                        Integer.parseInt(textField_TOTAL.getText().trim()));
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });

    button_UPDATE_DATABASE.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                myCoffeesTableModel.coffeesRowSet.acceptChanges();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
                // Now revert back changes
                try {
                    createNewTableModel();
                } catch (SQLException sqle2) {
                    displaySQLExceptionDialog(sqle2);
                }
            }
        }
    });

    button_DISCARD_CHANGES.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                createNewTableModel();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });
}

From source file:strobe.spectroscopy.StrobeSpectroscopy.java

private void comboBoxSettings() {
    for (int i = 0; i < 1 + ((900 - 300) / 10); i++) {
        cBoxFromWavelength.addItem(300 + 10 * i + " nm");
    }/*from   w  ww .j av a 2  s  . co m*/
    for (int i = 0; i < 1 + ((900 - 300) / 10); i++) {
        cBoxToWavelength.addItem(300 + 10 * i + " nm");
    }
    cBoxToWavelength.setSelectedItem("900 nm");

    for (String value : boxSpeedItems) {
        cBoxSpeed.addItem(value);
    }
    for (String value : boxResolutionItems) {
        cBoxResolution.addItem(value);
    }
    cBoxSpeed.setSelectedIndex(1);
    cBoxResolution.setSelectedIndex(2);
    cBoxFromWavelength.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
}

From source file:net.sf.dvstar.transmission.TransmissionView.java

private void setAdditionalButtons() {
    ResizableIcon ri = new ArrowResizableIcon(9, SwingConstants.SOUTH);
    JCommandButton dropDownButton = new JCommandButton("Text Button", ri);

    ImageIcon imco = globalResourceMap.getImageIcon("btExit.icon");
    Dimension idim = new Dimension(imco.getIconWidth(), imco.getIconHeight());
    idim = new Dimension(40, 40);
    Image im = imco.getImage();/* w ww.  j  a v a 2  s  .c  o  m*/

    ImageWrapperResizableIcon iwri = ImageWrapperResizableIcon.getIcon(im, idim);

    JCommandButton taskbarButtonPaste = new JCommandButton("", iwri);

    taskbarButtonPaste.setHorizontalAlignment(SwingConstants.LEFT);
    taskbarButtonPaste.setCommandButtonKind(CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP);
    //taskbarButtonPaste.setPopupOrientationKind(CommandButtonPopupOrientationKind.DOWNWARD);
    taskbarButtonPaste.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    taskbarButtonPaste.setDisplayState(TILE_36); // !!!!
    //taskbarButtonPaste.setPreferredSize(new Dimension(80, 48));
    System.out.println("Pref " + taskbarButtonPaste.getPreferredSize());
    System.out.println("Maxi " + taskbarButtonPaste.getMaximumSize());
    System.out.println("Mini " + taskbarButtonPaste.getMinimumSize());
    System.out.println("Size " + taskbarButtonPaste.getSize());
    Dimension d = new Dimension(taskbarButtonPaste.getPreferredSize().width, 48);
    taskbarButtonPaste.setMaximumSize(d);

    taskbarButtonPaste.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("Taskbar Paste activated");
        }
    });
    taskbarButtonPaste.setPopupCallback(new PopupPanelCallback() {

        @Override
        public JPopupPanel getPopupPanel(JCommandButton commandButton) {
            return new SamplePopupMenu();
        }
    });

    taskbarButtonPaste.setActionRichTooltip(new RichTooltip("Paste", "Paste the contents of the Clipboard"));
    taskbarButtonPaste.setPopupRichTooltip(new RichTooltip("Paste",
            "Click here for more options such as pasting only the values or formatting"));
    taskbarButtonPaste.setActionKeyTip("1");

    //maiToolBar.add( rb );

    /*
    JRibbonBand rb = new JRibbonBand("", new EmptyResizableIcon(1));
    rb.addCommandButton(dropDownButton, RibbonElementPriority.MEDIUM);
     *
    JButton dropDownButton = DropDownButtonFactory.createDropDownButton(
    resourceMap.getIcon("btConnect.icon"),
    popup);
     */
    //dropDownButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(2,2,2,2));
    //dropDownButton.setBorderPainted( false );

    //btConnect = taskbarButtonPaste;
    maiToolBar.add(taskbarButtonPaste);

}

From source file:org.biojava.bio.view.MotifAnalyzer.java

/**
 * This method initializes jJMenuBar   /*from   w  w w  .  j a v a 2s .c om*/
 *    
 * @return javax.swing.JMenuBar   
 */
private JMenuBar getJJMenuBar() {
    if (jJMenuBar == null) {
        jJMenuBar = new JMenuBar();
        jJMenuBar.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    }
    /* File Menu */
    JMenu fileMenu = new JMenu("File");
    fileMenu.setFont(menuFont);
    jJMenuBar.add(fileMenu);

    JMenuItem loadItem = new JMenuItem(loadMenuName);
    loadItem.addActionListener(this);
    fileMenu.add(loadItem);

    JMenuItem saveItem = new JMenuItem(saveMenuName);
    saveItem.addActionListener(this);
    fileMenu.add(saveItem);

    JMenuItem openMotifVoterItem = new JMenuItem(convertMotifVoterMenuName);
    openMotifVoterItem.addActionListener(this);
    fileMenu.add(openMotifVoterItem);

    JMenuItem runPatchConverMVItem = new JMenuItem(runPatchConverMVMenuName);
    runPatchConverMVItem.addActionListener(this);
    fileMenu.add(runPatchConverMVItem);

    JMenuItem convertAllItem = new JMenuItem(convertAllMenuName);
    convertAllItem.addActionListener(this);
    fileMenu.add(convertAllItem);

    JMenuItem runPatchConverAllItem = new JMenuItem(runPatchConverAllMenuName);
    runPatchConverAllItem.addActionListener(this);
    fileMenu.add(runPatchConverAllItem);

    JMenuItem compareSetsItem = new JMenuItem(compareSetsName);
    compareSetsItem.addActionListener(this);
    fileMenu.add(compareSetsItem);

    JMenuItem mergeCompareSetsItem = new JMenuItem(mergeCompareSetsName);
    mergeCompareSetsItem.addActionListener(this);
    fileMenu.add(mergeCompareSetsItem);

    JMenuItem copyFilesWithExtensionItem = new JMenuItem(copyCleanInputFilesName);
    copyFilesWithExtensionItem.addActionListener(this);
    fileMenu.add(copyFilesWithExtensionItem);

    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.exit(0);
        }
    });
    fileMenu.add(exitItem);

    /* Tools Menu */
    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setFont(menuFont);
    jJMenuBar.add(toolsMenu);

    JMenuItem gibbsItem = new JMenuItem(gibbsMenuName);
    gibbsItem.addActionListener(this);
    toolsMenu.add(gibbsItem);

    JMenuItem infoContentItem = new JMenuItem(infoContentMenuName);
    infoContentItem.addActionListener(this);
    toolsMenu.add(infoContentItem);

    JMenuItem removeRedundantSitesItem = new JMenuItem(removeRedundantSitesName);
    removeRedundantSitesItem.addActionListener(this);
    toolsMenu.add(removeRedundantSitesItem);

    JMenuItem extractSitesItem = new JMenuItem(extractSitesName);
    extractSitesItem.addActionListener(this);
    toolsMenu.add(extractSitesItem);

    JMenuItem drawKDistanceGraphItem = new JMenuItem(drawKDistanceGraphName);
    drawKDistanceGraphItem.addActionListener(this);
    toolsMenu.add(drawKDistanceGraphItem);

    JMenuItem computeWeightItem = new JMenuItem(computeWeightName);
    computeWeightItem.addActionListener(this);
    toolsMenu.add(computeWeightItem);

    /* Run Methods Menu */
    JMenu methodMenu = new JMenu("Run Method");
    methodMenu.setFont(menuFont);
    jJMenuBar.add(methodMenu);

    /*
    JMenuItem bioProspectorItem = new JMenuItem(runBioProspectorName);
    bioProspectorItem.addActionListener(this);
    methodMenu.add(bioProspectorItem);
            
    JMenuItem KMeansItem = new JMenuItem(runKMeansName);
    KMeansItem.addActionListener(this);
    methodMenu.add(KMeansItem);
            
    JMenuItem DBScanItem = new JMenuItem(runDBScanName);
    DBScanItem.addActionListener(this);
    methodMenu.add(DBScanItem);
            
    JMenuItem OPTICSItem = new JMenuItem(runOPTICSName);
    OPTICSItem.addActionListener(this);
    methodMenu.add(OPTICSItem);
            
    JMenuItem motifVoteItem = new JMenuItem(runMotifVoterName);
    motifVoteItem.addActionListener(this);
    methodMenu.add(motifVoteItem);
            
    JMenuItem runCliqueItem = new JMenuItem(runCliqueName);
    runCliqueItem.addActionListener(this);
    methodMenu.add(runCliqueItem);
    */

    for (int i = 0; i < Method.values().length; i++) {
        JMenuItem item = new JMenuItem(Method.values()[i].name());
        item.addActionListener(this);
        methodMenu.add(item);
    }

    /* Run Analysis for Methods Menu */
    JMenu analysisMenu = new JMenu("Analysis");
    analysisMenu.setFont(menuFont);
    jJMenuBar.add(analysisMenu);

    JMenuItem evaluateTompaMotifEachItem = new JMenuItem(evaluateTompaMotifEachName);
    evaluateTompaMotifEachItem.addActionListener(this);
    analysisMenu.add(evaluateTompaMotifEachItem);

    JMenuItem evaluateTompaMotifItem = new JMenuItem(evaluateTompaMotifAccName);
    evaluateTompaMotifItem.addActionListener(this);
    analysisMenu.add(evaluateTompaMotifItem);

    JMenuItem evaluateTompaMotifTotalItem = new JMenuItem(evaluateTompaMotifTotalName);
    evaluateTompaMotifTotalItem.addActionListener(this);
    analysisMenu.add(evaluateTompaMotifTotalItem);

    JMenuItem evaluateMotifVoterItem = new JMenuItem(evaluateMotifVoterName);
    evaluateMotifVoterItem.addActionListener(this);
    analysisMenu.add(evaluateMotifVoterItem);

    JMenuItem evaluateMotifVoterTotalItem = new JMenuItem(evaluateMotifVoterTotalName);
    evaluateMotifVoterTotalItem.addActionListener(this);
    analysisMenu.add(evaluateMotifVoterTotalItem);

    JMenuItem evaluateMVDirFirstEleItem = new JMenuItem(evaluateMVDirFirstEleName);
    evaluateMVDirFirstEleItem.addActionListener(this);
    analysisMenu.add(evaluateMVDirFirstEleItem);

    JMenuItem evaluateMVDirMergedItem = new JMenuItem(evaluateMVDirMergedName);
    evaluateMVDirMergedItem.addActionListener(this);
    analysisMenu.add(evaluateMVDirMergedItem);

    JMenuItem compareMotifVoterFirstItem = new JMenuItem(compareMotifVoterFirstName);
    compareMotifVoterFirstItem.addActionListener(this);
    analysisMenu.add(compareMotifVoterFirstItem);

    JMenuItem compareMotifVoterAllItem = new JMenuItem(compareMotifVoterAllName);
    compareMotifVoterAllItem.addActionListener(this);
    analysisMenu.add(compareMotifVoterAllItem);

    JMenuItem EvaluateAllResultsItem = new JMenuItem(evaluateAllResultsName);
    EvaluateAllResultsItem.addActionListener(this);
    analysisMenu.add(EvaluateAllResultsItem);

    return jJMenuBar;
}

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);//from  ww  w. jav a  2s.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 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.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 w  w  . ja 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");
    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.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 .  j  av a 2  s . com*/
    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;
}

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   ww w .j a v  a  2 s  . co  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:gui.images.ImageHubExplorer.java

/**
 * Initialization.//from  w  w  w. j av  a 2s .c  o m
 */
private void additionalInit() {
    // Initialize kNN and reverse neighbor panels.
    nnPanel.setLayout(new FlowLayout());
    rnnPanel.setLayout(new FlowLayout());
    nnPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    rnnPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    rnnPanel.setMaximumSize(new Dimension(60000, 400));
    // Initialize the neighborhood size selection slider.
    kSelectionSlider.setMajorTickSpacing(5);
    kSelectionSlider.setMinorTickSpacing(1);
    kSelectionSlider.setPaintLabels(true);
    kSelectionSlider.setPaintTicks(true);
    kSelectionSlider.addChangeListener(new SliderChanger());
    // Initialize various chart panels.
    classColorAndNamesPanel.setLayout(new VerticalFlowLayout());
    occProfileChartHolder.setLayout(new FlowLayout());
    classDistributionHolder.setLayout(new FlowLayout());
    chartHoldingPanelOccDistribution.setLayout(new FlowLayout());
    chartHoldingPanelOccDistribution.setPreferredSize(new Dimension(497, 191));
    queryNNPanel.setLayout(new VerticalFlowLayout());
    classifierPredictionsPanel.setLayout(new VerticalFlowLayout());
    // Initialize the scroll panes.
    prClassScrollPane.setPreferredSize(new Dimension(237, 432));
    prClassScrollPane.setMinimumSize(new Dimension(237, 432));
    prClassScrollPane.setMaximumSize(new Dimension(237, 432));
    queryNNScrollPane.setPreferredSize(new Dimension(207, 455));
    queryNNScrollPane.setMinimumSize(new Dimension(207, 455));
    queryNNScrollPane.setMaximumSize(new Dimension(207, 455));
    classesScrollPanel.setLayout(new VerticalFlowLayout());
    classesScrollPanel.setPreferredSize(new Dimension(760, 1168));
    classesScrollPanel.setMaximumSize(new Dimension(760, 1168));
    classesScrollPanel.setMinimumSize(new Dimension(760, 1168));
    classesScrollPane.setPreferredSize(new Dimension(760, 308));
    classesScrollPane.setMaximumSize(new Dimension(760, 308));
    classesScrollPane.setMinimumSize(new Dimension(760, 308));
    // Initialize the MDS component.
    mdsCollectionPanel.setPreferredSize(new Dimension(1500, 1500));
    mdsCollectionPanel.setMaximumSize(new Dimension(1500, 1500));
    mdsCollectionPanel.setMinimumSize(new Dimension(1500, 1500));
    // Initialize the kNN graph visualization component.
    neighborGraphScrollPane.setPreferredSize(new Dimension(550, 550));
    neighborGraphScrollPane.setMinimumSize(new Dimension(550, 550));
    neighborGraphScrollPane.setMaximumSize(new Dimension(550, 550));
    neighborGraphScrollPane.setVisible(true);
    selectedImagePathLabelClassNeighborMain.setPreferredSize(new Dimension(30, 16));
    selectedImagePathLabelClassNeighborMain.setMaximumSize(new Dimension(30, 16));
    selectedImagePathLabelClassNeighborMain.setMinimumSize(new Dimension(30, 16));
    jScrollPane1.setPreferredSize(new Dimension(30, 16));
    jScrollPane1.setMinimumSize(new Dimension(30, 16));
    jScrollPane1.setMaximumSize(new Dimension(30, 16));
}