Example usage for javax.swing JComboBox getSelectedItem

List of usage examples for javax.swing JComboBox getSelectedItem

Introduction

In this page you can find the example usage for javax.swing JComboBox getSelectedItem.

Prototype

public Object getSelectedItem() 

Source Link

Document

Returns the current selected item.

Usage

From source file:cpsViews.ParamsForm.java

private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed

    JComboBox convertBox = (JComboBox) evt.getSource();
    String convertMethod = (String) convertBox.getSelectedItem();

    if (null != convertMethod)
        switch (convertMethod) {
        case "Probkowanie":
            rodzajKonwersji = 1;/*from  w  w w.  j a  v a2s  .c  o m*/
            signalName.setText("");
            break;
        case "Kwantyzacja":
            rodzajKonwersji = 2;
            signalName.setText("");
            break;
        case "Ekstrapolacja":
            rodzajKonwersji = 3;
            signalName.setText("");
            break;
        case "Interpolacja":
            rodzajKonwersji = 4;
            signalName.setText("");
            break;
        case "Rekonstrukcja_sinc":
            rodzajKonwersji = 5;
            signalName.setText("");
            break;
        }
}

From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java

public static void createLinkDemandGUI(final NetworkElementType networkElementType,
        final IVisualizationCallback callback) {
    final NetPlan netPlan = callback.getDesign();
    final JComboBox originNodeSelector = new WiderJComboBox();
    final JComboBox destinationNodeSelector = new WiderJComboBox();

    for (Node node : netPlan.getNodes()) {
        final String nodeName = node.getName();
        String nodeLabel = "Node " + node.getIndex();
        if (!nodeName.isEmpty())
            nodeLabel += " (" + nodeName + ")";

        originNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel));
        destinationNodeSelector.addItem(StringLabeller.of(node.getId(), nodeLabel));
    }//from w w  w  .  ja v a 2s  .  c  o m

    ItemListener nodeListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject();
            long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem())
                    .getObject();
            callback.putTransientColorInElementTopologyCanvas(
                    Arrays.asList(netPlan.getNodeFromId(originNodeId)), Color.GREEN);
            callback.putTransientColorInElementTopologyCanvas(
                    Arrays.asList(netPlan.getNodeFromId(destinationNodeId)), Color.CYAN);
        }
    };

    originNodeSelector.addItemListener(nodeListener);
    destinationNodeSelector.addItemListener(nodeListener);

    originNodeSelector.setSelectedIndex(0);
    destinationNodeSelector.setSelectedIndex(1);

    JPanel pane = new JPanel();
    pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Origin node: ")
            : new JLabel("Ingress node: "));
    pane.add(originNodeSelector);
    pane.add(Box.createHorizontalStrut(15));
    pane.add(networkElementType == NetworkElementType.LINK ? new JLabel("Destination node: ")
            : new JLabel("Egress node: "));
    pane.add(destinationNodeSelector);

    while (true) {
        int result = JOptionPane.showConfirmDialog(null, pane,
                "Please enter end nodes for the new " + networkElementType, JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (result != JOptionPane.OK_OPTION)
            return;

        try {
            long originNodeId = (long) ((StringLabeller) originNodeSelector.getSelectedItem()).getObject();
            long destinationNodeId = (long) ((StringLabeller) destinationNodeSelector.getSelectedItem())
                    .getObject();
            Node originNode = netPlan.getNodeFromId(originNodeId);
            Node destinationNode = netPlan.getNodeFromId(destinationNodeId);

            if (netPlan.getNodeFromId(originNodeId) == null)
                throw new Net2PlanException("Node of id: " + originNodeId + " does not exist");
            if (netPlan.getNodeFromId(destinationNodeId) == null)
                throw new Net2PlanException("Node of id: " + destinationNodeId + " does not exist");

            if (networkElementType == NetworkElementType.LINK) {
                final Link e = netPlan.addLink(originNode, destinationNode, 0, 0, 200000, null);
                callback.getVisualizationState()
                        .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals();
                callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK));
                callback.getVisualizationState().pickLink(e);
                callback.updateVisualizationAfterPick();
                callback.getUndoRedoNavigationManager().addNetPlanChange();

            } else {
                final Demand d = netPlan.addDemand(originNode, destinationNode, 0, null);
                callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND));
                callback.getVisualizationState().pickDemand(d);
                callback.updateVisualizationAfterPick();
                callback.getUndoRedoNavigationManager().addNetPlanChange();
            }

            break;
        } catch (Throwable ex) {
            ErrorHandling.showErrorDialog(ex.getMessage(), "Error adding " + networkElementType);
        }
    }
}

From source file:cpsViews.ParamsForm.java

private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
    JComboBox cb = (JComboBox) evt.getSource();
    String signalNames = (String) cb.getSelectedItem();

    if (null != signalNames)
        switch (signalNames) {
        case "Sygnal_S1":
            typSygnalu = 1;/*from w  w  w . j  a v a2 s  .c  o m*/
            signalName.setText("SZUM O ROZK?ADZIE JEDNOSTAJNYM");
            break;
        case "Sygnal_S2":
            typSygnalu = 2;
            signalName.setText("SZUM GAUSSOWSKI");
            break;
        case "Sygnal_S3":
            typSygnalu = 3;
            signalName.setText("SYGNA? SINUSOIDALNY");
            break;
        case "Sygnal_S4":
            typSygnalu = 4;
            signalName.setText("SYGNA? SINUSOIDALNY WYPROSTOWANY JEDNOPO?WKOWO");
            break;
        case "Sygnal_S5":
            typSygnalu = 5;
            signalName.setText("SYGNA? SINUSOIDALNY WYPROSTOWANY DWUPO?WKOWO");
            break;
        case "Sygnal_S6":
            typSygnalu = 6;
            signalName.setText("SYGNA? PROSTOKTNY");
            break;
        case "Sygnal_S7":
            typSygnalu = 7;
            signalName.setText("SYGNA? PROSTOKTNY SYMETRYCZNY");
            break;
        case "Sygnal_S8":
            typSygnalu = 8;
            signalName.setText("SYGNA? TRJKTNY (PI?OKSZTA?TNY)");
            break;
        case "Sygnal_S9":
            typSygnalu = 9;
            signalName.setText("SKOK JEDNOSTKOWY");
            break;
        case "Sygnal_S10":
            typSygnalu = 10;
            signalName.setText("IMPULS JEDNOSTKOWY");
            break;
        case "Sygnal_S11":
            typSygnalu = 11;
            signalName.setText("SZUM IMPULSOWY");
            break;
        }
}

From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java

/**
 * Create the UI for the panel//from w  w  w.jav a2s  . c om
 */
protected void createUI() {
    createForm("Preferences", "Formatting"); //$NON-NLS-1$ //$NON-NLS-2$

    UIValidator.setIgnoreAllValidation(this, true);

    JLabel fontNamesLabel = form.getLabelFor("fontNames"); //$NON-NLS-1$
    ValComboBox fontNamesVCB = form.getCompById("fontNames"); //$NON-NLS-1$

    JLabel fontSizesLabel = form.getLabelFor("fontSizes"); //$NON-NLS-1$
    ValComboBox fontSizesVCB = form.getCompById("fontSizes"); //$NON-NLS-1$

    JLabel controlSizesLabel = form.getLabelFor("controlSizes"); //$NON-NLS-1$
    ValComboBox controlSizesVCB = form.getCompById("controlSizes"); //$NON-NLS-1$

    formTypesCBX = form.getCompById("formtype"); //$NON-NLS-1$

    fontNames = fontNamesVCB.getComboBox();
    fontSizes = fontSizesVCB.getComboBox();
    controlSizes = controlSizesVCB.getComboBox();

    testField = form.getCompById("fontTest"); //$NON-NLS-1$
    if (testField != null) {
        testField.setText(UIRegistry.getResourceString("FormattingPrefsPanel.THIS_TEST")); //$NON-NLS-1$
    }
    if (UIHelper.isMacOS_10_5_X()) {
        fontNamesLabel.setVisible(false);
        fontNamesVCB.setVisible(false);
        fontSizesLabel.setVisible(false);
        fontSizesVCB.setVisible(false);
        testField.setVisible(false);

        int inx = -1;
        int i = 0;
        Vector<String> controlSizeTitles = new Vector<String>();
        for (UIHelper.CONTROLSIZE cs : UIHelper.CONTROLSIZE.values()) {
            String titleStr = getResourceString(cs.toString());
            controlSizeTitles.add(titleStr);
            controlSizesHash.put(titleStr, cs);
            controlSizes.addItem(titleStr);
            if (cs == UIHelper.getControlSize()) {
                inx = i;
            }
            i++;
        }
        controlSizes.setSelectedIndex(inx);

        Font baseFont = UIRegistry.getBaseFont();
        if (baseFont != null) {
            fontNames.addItem(baseFont.getFamily());
            fontSizes.addItem(Integer.toString(baseFont.getSize()));
            fontNames.setSelectedIndex(0);
            fontSizes.setSelectedIndex(0);
        }

    } else {
        controlSizesLabel.setVisible(false);
        controlSizesVCB.setVisible(false);

        Hashtable<String, Boolean> namesUsed = new Hashtable<String, Boolean>();
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        for (Font font : ge.getAllFonts()) {
            if (namesUsed.get(font.getFamily()) == null) {
                fontNames.addItem(font.getFamily());
                namesUsed.put(font.getFamily(), true); //$NON-NLS-1$
            }
        }
        for (int i = BASE_FONT_SIZE; i < 22; i++) {
            fontSizes.addItem(Integer.toString(i));
        }

        Font baseFont = UIRegistry.getBaseFont();
        if (baseFont != null) {
            fontNames.setSelectedItem(baseFont.getFamily());
            fontSizes.setSelectedItem(Integer.toString(baseFont.getSize()));

            if (testField != null) {
                ActionListener al = new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        testField.setFont(new Font((String) fontNames.getSelectedItem(), Font.PLAIN,
                                fontSizes.getSelectedIndex() + BASE_FONT_SIZE));
                        form.getUIComponent().validate();
                        clearFontSettings = false;
                    }
                };
                fontNames.addActionListener(al);
                fontSizes.addActionListener(al);
            }
        }
    }

    //-----------------------------------
    // Do DisciplineType Icons
    //-----------------------------------

    String iconName = AppPreferences.getRemote().get(getDisciplineImageName(), "CollectionObject"); //$NON-NLS-1$ //$NON-NLS-2$

    List<Pair<String, ImageIcon>> list = IconManager.getListByType("disciplines", IconManager.IconSize.Std16); //$NON-NLS-1$
    Collections.sort(list, new Comparator<Pair<String, ImageIcon>>() {
        public int compare(Pair<String, ImageIcon> o1, Pair<String, ImageIcon> o2) {
            String s1 = UIRegistry.getResourceString(o1.first);
            String s2 = UIRegistry.getResourceString(o2.first);
            return s1.compareTo(s2);
        }
    });

    disciplineCBX = (ValComboBox) form.getCompById("disciplineIconCBX"); //$NON-NLS-1$

    final JLabel dispLabel = form.getCompById("disciplineIcon"); //$NON-NLS-1$
    JComboBox comboBox = disciplineCBX.getComboBox();
    comboBox.setRenderer(new DefaultListCellRenderer() {
        @SuppressWarnings("unchecked") //$NON-NLS-1$
        public Component getListCellRendererComponent(JList listArg, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            Pair<String, ImageIcon> item = (Pair<String, ImageIcon>) value;
            JLabel label = (JLabel) super.getListCellRendererComponent(listArg, value, index, isSelected,
                    cellHasFocus);
            if (item != null) {
                label.setIcon(item.second);
                label.setText(UIRegistry.getResourceString(item.first));
            }
            return label;
        }
    });

    int inx = 0;
    Pair<String, ImageIcon> colObj = new Pair<String, ImageIcon>("colobj_backstop", //$NON-NLS-1$
            IconManager.getIcon("colobj_backstop", IconManager.IconSize.Std16)); //$NON-NLS-1$
    comboBox.addItem(colObj);

    int cnt = 1;
    for (Pair<String, ImageIcon> item : list) {
        if (item.first.equals(iconName)) {
            inx = cnt;
        }
        comboBox.addItem(item);
        cnt++;
    }

    comboBox.addActionListener(new ActionListener() {
        @SuppressWarnings("unchecked") //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            JComboBox cbx = (JComboBox) e.getSource();
            Pair<String, ImageIcon> item = (Pair<String, ImageIcon>) cbx.getSelectedItem();
            if (item != null) {
                dispLabel.setIcon(IconManager.getIcon(item.first));
                form.getUIComponent().validate();
            }
        }
    });

    comboBox.setSelectedIndex(inx);

    //-----------------------------------
    // Date Field
    //-----------------------------------
    dateFieldCBX = form.getCompById("scrdateformat"); //$NON-NLS-1$
    fillDateFormat();

    //-----------------------------------
    // FormType
    //-----------------------------------
    fillFormTypes();

    //-----------------------------------
    // Do App Icon
    //-----------------------------------

    final JButton getIconBtn = form.getCompById("GetIconImage"); //$NON-NLS-1$
    final JButton clearIconBtn = form.getCompById("ClearIconImage"); //$NON-NLS-1$
    final JLabel appLabel = form.getCompById("appIcon"); //$NON-NLS-1$
    final JButton resetDefFontBtn = form.getCompById("ResetDefFontBtn"); //$NON-NLS-1$

    String imgEncoded = AppPreferences.getRemote().get(iconImagePrefName, ""); //$NON-NLS-1$
    ImageIcon innerAppImgIcon = null;
    if (StringUtils.isNotEmpty(imgEncoded)) {
        innerAppImgIcon = GraphicsUtils.uudecodeImage("", imgEncoded); //$NON-NLS-1$
        if (innerAppImgIcon != null && innerAppImgIcon.getIconWidth() != 32
                || innerAppImgIcon.getIconHeight() != 32) {
            innerAppImgIcon = null;
            clearIconBtn.setEnabled(false);
        } else {
            clearIconBtn.setEnabled(true);
        }
    }

    if (innerAppImgIcon == null) {
        innerAppImgIcon = IconManager.getIcon("AppIcon"); //$NON-NLS-1$
        clearIconBtn.setEnabled(false);
    } else {
        clearIconBtn.setEnabled(true);
    }
    appLabel.setIcon(innerAppImgIcon);

    getIconBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chooseToolbarIcon(appLabel, clearIconBtn);
        }
    });

    clearIconBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ImageIcon appIcon = IconManager.getIcon("AppIcon");
            IconEntry entry = IconManager.getIconEntryByName(INNER_APPICON_NAME);
            entry.setIcon(appIcon);
            if (entry.getIcons().get(IconManager.IconSize.Std32) != null) {
                entry.getIcons().get(IconManager.IconSize.Std32).setImageIcon(appIcon);
            }

            appLabel.setIcon(IconManager.getIcon("AppIcon")); //$NON-NLS-1$
            clearIconBtn.setEnabled(false);
            AppPreferences.getRemote().remove(iconImagePrefName);
            form.getValidator().dataChanged(null, null, null);
        }
    });

    resetDefFontBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Font sysDefFont = UIRegistry.getDefaultFont();
            ComboBoxModel model = fontNames.getModel();
            for (int i = 0; i < model.getSize(); i++) {
                //System.out.println("["+model.getElementAt(i).toString()+"]["+sysDefFont.getFamily()+"]");
                if (model.getElementAt(i).toString().equals(sysDefFont.getFamily())) {
                    fontNames.setSelectedIndex(i);
                    clearFontSettings = true;
                    break;
                }
            }

            if (clearFontSettings) {
                fontSizes.setSelectedIndex(sysDefFont.getSize() - BASE_FONT_SIZE);
                clearFontSettings = true; // needs to be redone 
            }

            form.getValidator().dataChanged(null, null, null);
        }
    });

    //-----------------------------------
    // Do Banner Icon Size
    //-----------------------------------

    String fmtStr = "%d x %d pixels";//getResourceString("BNR_ICON_SIZE");
    bnrIconSizeCBX = form.getCompById("bnrIconSizeCBX"); //$NON-NLS-1$

    int size = AppPreferences.getLocalPrefs().getInt(BNR_ICON_SIZE, 20);
    inx = 0;
    cnt = 0;
    for (int pixelSize : pixelSizes) {
        ((DefaultComboBoxModel) bnrIconSizeCBX.getModel())
                .addElement(String.format(fmtStr, pixelSize, pixelSize));
        if (pixelSize == size) {
            inx = cnt;
        }
        cnt++;
    }

    bnrIconSizeCBX.getComboBox().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            form.getUIComponent().validate();
        }
    });

    bnrIconSizeCBX.getComboBox().setSelectedIndex(inx);

    UIValidator.setIgnoreAllValidation(this, false);
    fontNamesVCB.setChanged(false);
    fontSizesVCB.setChanged(false);

    form.getValidator().validateForm();
}

From source file:com.entertailion.java.fling.FlingFrame.java

/**
 * Event handler for device dropdown list selection
 * //w w w .j a v  a2 s.  co m
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
public void actionPerformed(ActionEvent e) {
    JComboBox cb = (JComboBox) e.getSource();
    int pos = cb.getSelectedIndex();
    // when device is selected, attempt to connect
    if (servers != null && pos > 0) {
        selectedDialServer = (DialServer) cb.getSelectedItem();
    }
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public String getComponentValue(String label) {
    JComponent component = getComponent(label);
    if (component == null) {
        return (String) (hiddenValues == null ? null : hiddenValues.get(label));
    }// w w w.  ja va  2 s. com

    if (component instanceof JTextComponent) {
        return ((JTextComponent) component).getText();
    }

    if (component instanceof JComboBox) {
        JComboBox comboBox = ((JComboBox) component);
        int selectedIndex = comboBox.getSelectedIndex();
        if (selectedIndex != -1) {
            if (comboBoxMaps.containsKey(component)) {
                Object[] keys = (Object[]) comboBoxMaps.get(comboBox);
                Object value = keys[selectedIndex];
                return (String) value == null ? null : value.toString();
            } else {
                Object value = comboBox.getSelectedItem();
                return (String) value == null ? null : value.toString();
            }
        }
    }

    if (component instanceof JList) {
        return (String) ((JList) component).getSelectedValue();
    }

    if (component instanceof JCheckBox) {
        return String.valueOf(((JCheckBox) component).isSelected());
    } else if (component instanceof JFormComponent) {
        return ((JFormComponent) component).getValue();
    }

    return null;
}

From source file:org.jfree.chart.demo.RightPanel.java

public RightPanel(int x, int y, int width, int height, String baude[], String name[]) {

    setBackground(new Color(176, 199, 246));

    this.width = width;
    this.height = height;

    Data[0] = "8";
    Data[1] = "9";

    Name = name;//from  w ww. j a va2 s .c  o m
    Baude = baude;

    setLayout(new GridLayout(8, 1, 0, 0));

    lblName = new JLabel("Name");
    lblName.setHorizontalAlignment(SwingConstants.CENTER);
    lblName.setFont(new Font("Arial", 15, 16));
    add(lblName);

    comboBox = new JComboBox(Name);
    comboBox.setFont(new Font("Arial", 15, 16));
    add(comboBox);

    JLabel lblBaude = new JLabel("Baude");
    lblBaude.setFont(new Font("Arial", 15, 16));
    lblBaude.setHorizontalAlignment(SwingConstants.CENTER);
    add(lblBaude);

    final JComboBox comboBox_1 = new JComboBox(Baude);
    comboBox_1.setFont(new Font("Arial", 15, 16));
    add(comboBox_1);

    JLabel lblDataSize = new JLabel("Data size");
    lblDataSize.setHorizontalAlignment(SwingConstants.CENTER);
    lblDataSize.setFont(new Font("Arial", 15, 16));
    add(lblDataSize);

    final JComboBox comboBox_2 = new JComboBox(Data);
    comboBox_2.setFont(new Font("Arial", 15, 16));
    add(comboBox_2);

    JSeparator separator = new JSeparator();
    add(separator);

    btnOpen = new JButton("Open");
    btnOpen.setFont(new Font("Arial", 15, 16));
    btnOpen.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (btnOpen.getText() == "Open") {
                btnOpen.setText("Close");
                open = true;
                int baude = 9600, data = 8;
                try {
                    baude = Integer.parseInt((String) comboBox_1.getSelectedItem());
                    data = Integer.parseInt((String) comboBox_2.getSelectedItem());
                } catch (Exception e) {
                    errors += "Enter correct Bauderate\n";
                    error_flag = true;

                }
                comport = new Comport((String) comboBox.getSelectedItem(), baude, data);
                comport.start();

            } else {
                comport.flag = false;
                btnOpen.setText("Open");
                open = false;

                comport.close();
                //   comport.stop();

                System.out.println("Comport = " + comport.isAlive());
                System.out.println("Comport life  = " + comport.get_life());

            }
        }
    });
    add(btnOpen);
    setBounds(x + 50, y, width - 40, height - 20);
    err.setBounds(x + 50, y, 50, 50);
    //add(err);

}

From source file:ConfigFiles.java

public ConfigFiles(Dimension screensize) {
    //         initializeFileBrowser();
    paths = new JPanel();
    paths.setBackground(Color.WHITE);
    //paths.setBorder(BorderFactory.createTitledBorder("Paths"));
    paths.setLayout(null);//w ww .  ja  v  a2 s . c om
    paths.setPreferredSize(new Dimension(930, 1144));
    paths.setSize(new Dimension(930, 1144));
    paths.setMinimumSize(new Dimension(930, 1144));
    paths.setMaximumSize(new Dimension(930, 1144));
    //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    setLayout(null);
    ttcpath = new JTextField();
    addPanel("TestCase Source Path",
            "Master directory with the test cases that can" + " be run by the framework", ttcpath,
            RunnerRepository.TESTSUITEPATH, 10, true, null);
    tMasterXML = new JTextField();
    tUsers = new JTextField();

    addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY,
            83, true, null);

    tSuites = new JTextField();
    addPanel("Predefined Suites Path", "Location of predefined suites", tSuites,
            RunnerRepository.PREDEFINEDSUITES, 156, true, null);

    testconfigpath = new JTextField();
    addPanel("Test Configuration Path", "Test Configuration path", testconfigpath,
            RunnerRepository.TESTCONFIGPATH, 303, true, null);

    tepid = new JTextField();
    addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid,
            RunnerRepository.REMOTEEPIDDIR, 595, true, null);
    tlog = new JTextField();
    addPanel("Logs Path", "Location of the directory that stores the most recent log files."
            + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null);
    tsecondarylog = new JTextField();

    JPanel p = addPanel("Secondary Logs Path",
            "Location of the directory that archives copies of the most recent log files, with"
                    + " original file names appended with <.epoch time>",
            tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null);
    logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED));
    logsenabled.setBackground(Color.WHITE);
    p.add(logsenabled);

    JPanel p7 = new JPanel();
    p7.setBackground(Color.WHITE);
    TitledBorder border7 = BorderFactory.createTitledBorder("Log Files");
    border7.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p7.setBorder(border7);
    p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS));
    p7.setBounds(80, 740, 800, 190);
    paths.add(p7);
    JTextArea log2 = new JTextArea("All the log files that will be monitored");
    log2.setWrapStyleWord(true);
    log2.setLineWrap(true);
    log2.setEditable(false);
    log2.setCursor(null);
    log2.setOpaque(false);
    log2.setFocusable(false);
    log2.setBorder(null);
    log2.setFont(new Font("Arial", Font.PLAIN, 12));
    log2.setBackground(getBackground());
    log2.setMaximumSize(new Dimension(170, 25));
    log2.setPreferredSize(new Dimension(170, 25));
    JPanel p71 = new JPanel();
    p71.setBackground(Color.WHITE);
    p71.setLayout(new GridLayout());
    p71.setMaximumSize(new Dimension(700, 13));
    p71.setPreferredSize(new Dimension(700, 13));
    p71.add(log2);
    JPanel p72 = new JPanel();
    p72.setBackground(Color.WHITE);
    p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS));
    trunning = new JTextField();
    p72.add(addField(trunning, "Running: ", 0));
    tdebug = new JTextField();
    p72.add(addField(tdebug, "Debug: ", 1));
    tsummary = new JTextField();
    p72.add(addField(tsummary, "Summary: ", 2));
    tinfo = new JTextField();
    p72.add(addField(tinfo, "Info: ", 3));
    tcli = new JTextField();
    p72.add(addField(tcli, "Cli: ", 4));
    p7.add(p71);
    p7.add(p72);
    libpath = new JTextField();

    addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true,
            null);

    JPanel p8 = new JPanel();
    p8.setBackground(Color.WHITE);
    TitledBorder border8 = BorderFactory.createTitledBorder("File");
    border8.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p8.setBorder(border8);
    p8.setLayout(null);
    p8.setBounds(80, 1076, 800, 50);
    if (PermissionValidator.canChangeFWM()) {
        paths.add(p8);
    }
    JButton save = new JButton("Save");
    save.setToolTipText("Save and automatically load config");
    save.setBounds(490, 20, 70, 20);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            saveXML(false, "fwmconfig");
            loadConfig("fwmconfig.xml");
        }
    });
    p8.add(save);
    //         if(!PermissionValidator.canChangeFWM()){
    //             save.setEnabled(false);
    //         }
    JButton saveas = new JButton("Save as");
    saveas.setBounds(570, 20, 90, 20);
    saveas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name");
            if (!filename.equals("NULL")) {
                saveXML(false, filename);
            }
        }
    });
    p8.add(saveas);

    final JButton loadXML = new JButton("Load Config");
    loadXML.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                String[] configs = RunnerRepository
                        .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/");
                JComboBox combo = new JComboBox(configs);
                int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null);
                final String config;
                if (resp == JOptionPane.OK_OPTION)
                    config = combo.getSelectedItem().toString();
                else
                    config = null;
                if (config != null) {
                    new Thread() {
                        public void run() {
                            setEnabledTabs(false);
                            JFrame progress = new JFrame();
                            progress.setAlwaysOnTop(true);
                            progress.setLocation((int) loadXML.getLocationOnScreen().getX(),
                                    (int) loadXML.getLocationOnScreen().getY());
                            progress.setUndecorated(true);
                            JProgressBar bar = new JProgressBar();
                            bar.setIndeterminate(true);
                            progress.add(bar);
                            progress.pack();
                            progress.setVisible(true);
                            loadConfig(config);
                            progress.dispose();
                            setEnabledTabs(true);
                        }
                    }.start();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    loadXML.setBounds(670, 20, 120, 20);
    p8.add(loadXML);
    //         if(!PermissionValidator.canChangeFWM()){
    //             loadXML.setEnabled(false);
    //         }

    tdbfile = new JTextField();
    addPanel("Database XML path", "File location for database configuration", tdbfile,
            RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true,
            null);
    temailfile = new JTextField();
    //         emailpanel = (JPanel)
    addPanel("Email XML path", "File location for email configuration", temailfile,
            RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null)
                    .getParent();
    //paths.remove(emailpanel);

    //         emailpanel.setBounds(360,440,350,100);
    //         RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel);

    tglobalsfile = new JTextField();
    addPanel("Globals XML file", "File location for globals parameters", tglobalsfile,
            RunnerRepository.GLOBALSREMOTEFILE, 521, true, null);

    tceport = new JTextField();
    addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(),
            1003, false, null);
    //         traPort = new JTextField();
    //         addPanel("Resource Allocator Port","Resource Allocator Port",
    //                 traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null);                
    //         thttpPort = new JTextField();
    //         addPanel("HTTP Server Port","HTTP Server Port",thttpPort,
    //                 RunnerRepository.getHTTPServerPort(),740,false,null);

    //paths.add(loadXML);

    if (!PermissionValidator.canChangeFWM()) {
        ttcpath.setEnabled(false);
        tMasterXML.setEnabled(false);
        tUsers.setEnabled(false);
        tepid.setEnabled(false);
        tSuites.setEnabled(false);
        tlog.setEnabled(false);
        trunning.setEnabled(false);
        tdebug.setEnabled(false);
        tsummary.setEnabled(false);
        tinfo.setEnabled(false);
        tcli.setEnabled(false);
        tdbfile.setEnabled(false);
        temailfile.setEnabled(false);
        tceport.setEnabled(false);
        libpath.setEnabled(false);
        tsecondarylog.setEnabled(false);
        testconfigpath.setEnabled(false);
        tglobalsfile.setEnabled(false);
        logsenabled.setEnabled(false);
    }

}

From source file:com.diversityarrays.kdxplore.heatmap.HeatMapPanel.java

private JComponent createCurationControls() {

    rejectSamplesAction.setEnabled(false);
    acceptSamplesAction.setEnabled(false);

    deActivatePlotsAction.setEnabled(false);
    reActivatePlotsAction.setEnabled(false);

    //                      | deactivate
    //   accept  suppress   | reactivate

    JPanel panel = new JPanel();
    GBH gbh = new GBH(panel, 2, 2, 2, 2);

    gbh.add(0, 0, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(acceptSamplesAction));
    gbh.add(1, 0, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(rejectSamplesAction));
    //        if (! askAboutValueForUnscored) {
    //            // TODO i18n
    //            gbh.add(0,1, 2,1, GBH.HORZ, 1,1, GBH.CENTER, "Unscored samples ignored");
    //        }//www .  j av  a2  s .co  m

    if (xValueRetriever.isPlotColumn() && yValueRetriever.isPlotRow()) {
        gbh.add(2, 0, 1, 2, GBH.VERT, 1, 1, GBH.CENTER, new JSeparator(JSeparator.VERTICAL));
        gbh.add(3, 0, 1, 1, GBH.NONE, 1, 1, GBH.EAST, new JButton(deActivatePlotsAction));
        gbh.add(3, 1, 1, 1, GBH.NONE, 1, 1, GBH.EAST, new JButton(reActivatePlotsAction));
    }

    if (markInfo != null) {
        JComboBox<String> combo = new JComboBox<>();
        combo.addItem(NO_MARK);
        for (String s : markInfo.plotPointsByMark.keySet()) {
            combo.addItem(s);
        }
        combo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                List<Point> points = null;
                Object item = combo.getSelectedItem();
                if (item != null && !NO_MARK.equals(item)) {
                    points = markInfo.plotPointsByMark.get(item);
                    markName = item.toString();
                }

                if (Check.isEmpty(points)) {
                    heatMap.removeDecoratedPoints(markInfoRenderer);
                } else {
                    heatMap.setDecoratedPoints(markInfoRenderer, points.toArray(new Point[points.size()]));
                }
            }
        });

        Box newBox = Box.createHorizontalBox();
        newBox.add(new JLabel(markInfo.label));
        newBox.add(combo);

        gbh.add(0, 2, 4, 1, GBH.HORZ, 1, 1, GBH.CENTER, newBox);
    }

    return panel;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * @param p//ww w .j a v a 2  s.  c o m
 * @param wbRow
 */
protected void copyDataFromForm(final InputPanel p, final WorkbenchRow wbRow) {
    short col = p.getWbtmi().getViewOrder();
    WorkbenchDataItem result = null;

    if (p.getComp() instanceof JTextComponent) {
        String data = ((JTextComponent) p.getComp()).getText();
        String cellData = wbRow.getData(col);
        if (StringUtils.isNotEmpty(cellData) || data != null) {
            result = wbRow.setData(data == null ? "" : data, col, true);
        }

    } else if (p.getComp() instanceof GetSetValueIFace) {
        Object data = ((GetSetValueIFace) p.getComp()).getValue();
        String cellData = wbRow.getData(col);
        if (StringUtils.isNotEmpty(cellData) || data != null) {
            result = wbRow.setData(data == null ? "" : data.toString(), col, true);
        }

    } else if (p.getComp() instanceof JScrollPane) {
        JScrollPane sc = (JScrollPane) p.getComp();
        Component comp = sc.getViewport().getView();
        if (comp instanceof JTextArea) {
            result = wbRow.setData(((JTextArea) comp).getText(), col, true);
        }
    } else if (p.getComp() instanceof JComboBox) {
        JComboBox cb = (JComboBox) p.getComp();
        result = wbRow.setData(cb.getSelectedItem().toString(), col, true);
    } else {
        log.error("Can't get data from control[" + p.getLabelText() + "]");
    }

    if (result != null && workbenchPane.getTask() instanceof SGRTask) {
        wbRow.setSgrStatus((byte) 1);
    }
}