Example usage for javax.swing.event ChangeListener ChangeListener

List of usage examples for javax.swing.event ChangeListener ChangeListener

Introduction

In this page you can find the example usage for javax.swing.event ChangeListener ChangeListener.

Prototype

ChangeListener

Source Link

Usage

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

public static JPanel createDemoPanel() {
    CategoryDataset categorydataset = createDataset();
    chart = createChart(categorydataset);
    JPanel jpanel = new JPanel(new BorderLayout());
    JPanel jpanel1 = new JPanel(new BorderLayout());
    JPanel jpanel2 = new JPanel();
    invertCheckBox = new JCheckBox("Invert Range Axis?");
    invertCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
            categoryplot.getRangeAxis().setInverted(CategoryLabelPositionsDemo1.invertCheckBox.isSelected());
        }/*from www  . j av a  2  s  .  c  o  m*/

    });
    jpanel2.add(invertCheckBox);
    ButtonGroup buttongroup = new ButtonGroup();
    horizontalRadioButton = new JRadioButton("Horizontal", false);
    horizontalRadioButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            if (CategoryLabelPositionsDemo1.horizontalRadioButton.isSelected()) {
                CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
                categoryplot.setOrientation(PlotOrientation.HORIZONTAL);
            }
        }

    });
    buttongroup.add(horizontalRadioButton);
    verticalRadioButton = new JRadioButton("Vertical", true);
    verticalRadioButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            if (CategoryLabelPositionsDemo1.verticalRadioButton.isSelected()) {
                CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
                categoryplot.setOrientation(PlotOrientation.VERTICAL);
            }
        }

    });
    buttongroup.add(verticalRadioButton);
    jpanel2.add(horizontalRadioButton);
    jpanel2.add(verticalRadioButton);
    jpanel2.setBorder(new TitledBorder("Plot Settings: "));
    JPanel jpanel3 = new JPanel(new BorderLayout());
    slider = new JSlider(0, 90, 45);
    slider.setMajorTickSpacing(10);
    slider.setMinorTickSpacing(5);
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent changeevent) {
            CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
            CategoryAxis categoryaxis = categoryplot.getDomainAxis();
            categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(
                    ((double) CategoryLabelPositionsDemo1.slider.getValue() * 3.1415926535897931D) / 180D));
        }

    });
    jpanel3.add(slider);
    jpanel3.setBorder(new TitledBorder("Axis Label Rotation Angle:"));
    jpanel1.add("North", jpanel2);
    jpanel1.add(jpanel3);
    jpanel.add(new ChartPanel(chart));
    jpanel.add("South", jpanel1);
    return jpanel;
}

From source file:biomine.bmvis2.pipeline.BestPathHiderOperation.java

public JComponent getSettingsComponent(final SettingsChangeCallback settingsChangeCallback,
        final VisualGraph graph) {
    long nodeCount = graph.getAllNodes().size();

    if (oldCount != 0) {
        long newTarget = (target * nodeCount) / oldCount;
        this.target = Math.max(newTarget, target);
    } else/*from w w w .j  av a2 s.c o  m*/
        this.target = nodeCount;

    this.oldCount = nodeCount;

    JPanel ret = new JPanel();

    // if int overflows, we're fucked
    final JSlider sl = new JSlider(0, (int) nodeCount, (int) Math.min(target, nodeCount));
    sl.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if (target == sl.getValue())
                return;
            target = sl.getValue();
            settingsChangeCallback.settingsChanged(false);
        }
    });

    ret.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    //c.gridwidth=2;

    ret.add(sl, c);
    c.gridy++;

    int choices = graph.getNodesOfInterest().size() + 1;

    Object[] items = new Object[choices];
    items[0] = "All PoIs";

    for (int i = 1; i < choices; i++) {
        items[i] = i + " nearest";
    }
    final JComboBox pathTypeBox = new JComboBox(items);
    pathTypeBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int i = pathTypeBox.getSelectedIndex();
            grader.setPathK(i);
            settingsChangeCallback.settingsChanged(false);
        }
    });

    ret.add(new JLabel("hide by best path quality to:"), c);
    c.gridy++;
    ret.add(pathTypeBox, c);
    c.gridy++;

    System.out.println("new confpane nodeCount = " + nodeCount);

    final JCheckBox useMatchingColoring = new JCheckBox();
    ret.add(useMatchingColoring, c);

    useMatchingColoring.setAction(new AbstractAction("Use matching coloring") {
        public void actionPerformed(ActionEvent arg0) {
            matchColoring = useMatchingColoring.isSelected();
            settingsChangeCallback.settingsChanged(false);
        }
    });

    useMatchingColoring.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    c.gridy++;

    final JCheckBox labelsBox = new JCheckBox();
    ret.add(labelsBox, c);

    labelsBox.setAction(new AbstractAction("Show goodness in node labels") {
        public void actionPerformed(ActionEvent arg0) {
            showLabel = labelsBox.isSelected();
            settingsChangeCallback.settingsChanged(false);
        }
    });

    return ret;
}

From source file:DateTimeEditor.java

private void init() {
    setLayout(new BorderLayout());
    m_textField = new JTextField();

    m_textField.setDocument(new DateTimeDocument()); // BUG FIX

    m_spinner = new Spinner();
    m_spinner.getIncrementButton().addActionListener(m_upAction);
    m_spinner.getDecrementButton().addActionListener(m_downAction);
    add(m_textField, "Center");
    add(m_spinner, "East");
    m_caret = m_textField.getCaret();//from www . ja v  a2s.  c o  m
    m_caret.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            setCurField();
        }
    });
    setupKeymap();
    reinit();
}

From source file:projects.hip.exec.HrDiagram.java

/**
 * Main constructor.//from   w w  w  . j a va2  s  .c o m
 */
public HrDiagram() {

    hipStars = HipUtils.loadHipCatalogue();

    method = METHOD.NAIVE;
    fMax = 1.0;

    final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values());
    methodComboBox.setSelectedItem(method);
    methodComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            method = (METHOD) methodComboBox.getSelectedItem();
            updateChart();
        }
    });

    final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f");
    fSlider.setValue((int) Math.rint(100.0 * fMax / 2.0));
    final JLabel fLabel = new JLabel(getFLabel());
    // Create a change listener fot these
    ChangeListener cl = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();

            if (source == fSlider) {
                // Compute fractional parallax error from slider position
                double newF = (2.0 * source.getValue() / 100.0);
                fMax = newF;
                fLabel.setText(getFLabel());
            }
            updateChart();
        }
    };
    fSlider.addChangeListener(cl);
    // Add a bit of padding to space things out
    fSlider.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Present controls below the HR diagram
    JPanel controls = new JPanel(new GridLayout(2, 2));
    controls.add(new JLabel("Distance estimation method:"));
    controls.add(methodComboBox);
    controls.add(fLabel);
    controls.add(fSlider);

    // Initialise the ChartPanel
    updateChart();

    // Build the panel contents
    setLayout(new BorderLayout());
    add(hrDiagPanel, BorderLayout.WEST);
    add(dDistPanel, BorderLayout.EAST);
    add(controls, BorderLayout.SOUTH);
}

From source file:compecon.dashboard.panel.BanksPanel.java

public BanksPanel() {
    this.setLayout(new BorderLayout());

    for (Currency currency : Currency.values()) {
        JPanel panelForCurrency = new BanksPanelForCurrency(currency);
        jTabbedPaneCurrency.addTab(currency.getIso4217Code(), panelForCurrency);
    }//ww w  . jav a 2s . c  o m

    jTabbedPaneCurrency.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (e.getSource() instanceof JTabbedPane) {
                JTabbedPane pane = (JTabbedPane) e.getSource();
                BanksPanelForCurrency selectedComponent = (BanksPanelForCurrency) pane.getSelectedComponent();
                selectedComponent.notifyListener();
            }
        }
    });

    add(jTabbedPaneCurrency, BorderLayout.CENTER);
}

From source file:com.atlassian.theplugin.idea.config.serverconfig.GenericServerConfigForm.java

public GenericServerConfigForm(final Project project, final UserCfg defaultUser, final Connector tester) {
    this.project = project;
    $$$setupUI$$$();/*from  ww  w .  ja  v  a 2  s .com*/
    testConnection.addActionListener(
            new TestConnectionListener(project, tester, new TestConnectionListener.ServerDataProvider() {
                public ServerData getServer() {
                    synchronized (GenericServerConfigForm.this) {
                        saveData();
                        ServerData.Builder builder = new ServerData.Builder(serverCfg);
                        builder.defaultUser(defaultUser);
                        return builder.build();
                    }
                }
            }, this));
    serverUrl.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            adjustUrl();
        }
    });

    listener = new DocumentListener() {

        public void insertUpdate(DocumentEvent e) {
            setServerState();
        }

        public void removeUpdate(DocumentEvent e) {
            setServerState();
        }

        public void changedUpdate(DocumentEvent e) {
            setServerState();
        }
    };

    useDefault.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            enableDisableUserPassword();
        }
    });

    cbEnabled.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent changeEvent) {

        }
    });

    urlDocumentListener = new DocumentAdapter() {
        protected void textChanged(DocumentEvent documentEvent) {
            enableDisableSever(false);
        }
    };

    serverName.addFocusListener(new FocusAdapter() {
        public void focusLost(final FocusEvent e) {
            if (StringUtils.stripToEmpty(serverName.getText()).length() == 0) {
                serverName.setText(originalServerName);
            }
        }
    });

    enableDisableSever(true);
    enableDisableUserPassword();
}

From source file:lu.lippmann.cdb.datasetview.tabs.WeightedMapOfDecisionTreesTabView.java

/**
 * {@inheritDoc}/*  ww w  .j a  v  a  2  s. c o  m*/
 */
@Override
public void update0(final Instances dataSet) throws Exception {
    if (this.mp != null)
        this.panel.remove(this.mp);

    if (this.cl != null)
        this.slider.removeChangeListener(cl);
    //if (this.cl!=null) this.slider.removeChangeListener(cl);

    this.cl = new ChangeListener() {
        @Override
        public void stateChanged(final ChangeEvent e) {
            if (!slider.getValueIsAdjusting()) {
                dtFactory = new J48DecisionTreeFactory(slider.getValue() / 100d, false);
                update(dataSet);
            }
        }
    };
    this.slider.addChangeListener(cl);

    final double frameWidth = this.panel.getSize().getWidth() * 0.95d;
    final double frameHeight = this.panel.getSize().getHeight() * 0.95d;

    final ListOrderedMap<JComponent, Integer> mapPanels = new ListOrderedMap<JComponent, Integer>();

    final String oldSelected;
    if (this.attrSelectionCombo.getSelectedItem() == null) {
        oldSelected = dataSet.classAttribute().name();
    } else {
        final Attribute oldAttr = dataSet.attribute(this.attrSelectionCombo.getSelectedItem().toString());
        if (oldAttr != null) {
            oldSelected = oldAttr.name();
        } else {
            oldSelected = dataSet.classAttribute().name();
        }
    }
    final int idx = dataSet.attribute(oldSelected).index();
    final Set<Object> presentValues = WekaDataStatsUtil.getNominalRepartition(dataSet, idx).keySet();
    for (final Object o : presentValues) {
        final Instances part = WekaDataProcessingUtil.filterDataSetOnNominalValue(dataSet, idx, o.toString());
        final DecisionTree dti = dtFactory.buildDecisionTree(part);

        final int ratio = 100 * part.numInstances() / dataSet.numInstances();
        final GraphView myGraph = DecisionTreeToGraphViewHelper.buildGraphView(dti, eventPublisher,
                commandDispatcher);
        myGraph.hideSharedLabel();
        myGraph.addMetaInfo("size=" + dti.getSize(), "");
        myGraph.addMetaInfo("depth=" + dti.getDepth(), "");
        myGraph.addMetaInfo("err=" + FormatterUtil.DECIMAL_FORMAT.format(100d * dti.getErrorRate()) + "%", "");

        final JButton openInEditorButton = new JButton("Edit");
        openInEditorButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                GraphUtil.importDecisionTreeInEditor(dtFactory, part, applicationContext, eventPublisher,
                        commandDispatcher);
            }
        });
        myGraph.addMetaInfoComponent(openInEditorButton);

        myGraph.fitGraphToSubPanel(frameWidth - 10 * presentValues.size(), frameHeight - 10, ratio);
        mapPanels.put((JComponent) myGraph, ratio);

    }
    this.mp = new MultiPanel(mapPanels, (int) frameWidth, (int) frameHeight,
            this.withWeightCheckBox.isSelected());

    this.panel.add(this.mp, BorderLayout.CENTER);

    if (this.attrSelectionCombo.getActionListeners().length > 0) {
        this.attrSelectionCombo.removeActionListener(attrSelectionComboListener);
    }
    if (this.withWeightCheckBox.getActionListeners().length > 0) {
        this.withWeightCheckBox.removeActionListener(attrSelectionComboListener);
    }

    this.attrSelectionCombo.removeAllItems();
    for (final Attribute attr : WekaDataStatsUtil.getNominalAttributesList(dataSet)) {
        this.attrSelectionCombo.addItem(attr.name());
    }
    this.attrSelectionCombo.setSelectedItem(oldSelected);

    this.attrSelectionComboListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            update(dataSet);
        }
    };
    this.attrSelectionCombo.addActionListener(attrSelectionComboListener);
    this.withWeightCheckBox.addActionListener(attrSelectionComboListener);

}

From source file:gtu._work.ui.RegexReplacer.java

private void initGUI() {
    try {//  w w w  .j  ava 2  s  .c  o  m
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    try {
                        if (configHandler != null
                                && jTabbedPane1.getSelectedIndex() == TabIndex.TEMPLATE.ordinal()) {
                            System.out.println("-------ChangeEvent[" + jTabbedPane1.getSelectedIndex() + "]");
                            configHandler.reloadTemplateList();
                        }
                    } catch (Exception ex) {
                        JCommonUtil.handleException(ex);
                    }
                }
            });
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("source", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        replaceArea = new JTextArea();
                        jScrollPane1.setViewportView(replaceArea);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("param", null, jPanel2, null);
                {
                    exeucte = new JButton();
                    jPanel2.add(exeucte, BorderLayout.SOUTH);
                    exeucte.setText("exeucte");
                    exeucte.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exeucteActionPerformed(evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    jPanel2.add(JCommonUtil.createScrollComponent(jPanel3), BorderLayout.CENTER);
                    jPanel3.setLayout(new FormLayout(
                            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
                            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    RowSpec.decode("default:grow"), }));
                    {
                        lblNewLabel = new JLabel("key");
                        jPanel3.add(lblNewLabel, "2, 2, right, default");
                    }
                    {
                        configKeyText = new JTextField();
                        jPanel3.add(configKeyText, "4, 2, fill, default");
                        configKeyText.setColumns(10);
                    }
                    {
                        lblNewLabel_1 = new JLabel("from");
                        jPanel3.add(lblNewLabel_1, "2, 4, right, default");
                    }
                    {
                        repFromText = new JTextArea();
                        repFromText.setRows(3);
                        jPanel3.add(JCommonUtil.createScrollComponent(repFromText), "4, 4, fill, default");
                        repFromText.setColumns(10);
                    }
                    {
                        lblNewLabel_2 = new JLabel("to");
                        jPanel3.add(lblNewLabel_2, "2, 6, right, default");
                    }
                    {
                        repToText = new JTextArea();
                        repToText.setRows(3);
                        // repToText.setPreferredSize(new Dimension(0, 50));
                        jPanel3.add(JCommonUtil.createScrollComponent(repToText), "4, 6, fill, default");
                    }
                }
                {
                    addToTemplate = new JButton();
                    jPanel2.add(addToTemplate, BorderLayout.NORTH);
                    addToTemplate.setText("add to template");
                    addToTemplate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            configHandler.put(configKeyText.getText(), repFromText.getText(),
                                    repToText.getText(), tradeOffArea.getText());
                            configHandler.reloadTemplateList();
                        }
                    });
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                jTabbedPane1.addTab("template", null, jPanel5, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        templateList = new JList();
                        jScrollPane3.setViewportView(templateList);
                    }
                    templateList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            if (templateList.getLeadSelectionIndex() == -1) {
                                return;
                            }
                            PropConfigHandler.Config config = (PropConfigHandler.Config) JListUtil
                                    .getLeadSelectionObject(templateList);
                            configKeyText.setText(config.configKeyText);
                            repFromText.setText(config.fromVal);
                            repToText.setText(config.toVal);
                            tradeOffArea.setText(config.tradeOff);

                            templateList.setToolTipText(config.fromVal + " <----> " + config.toVal);

                            if (JMouseEventUtil.buttonLeftClick(2, evt)) {
                                String replaceText = StringUtils.defaultString(replaceArea.getText());
                                replaceText = replacer(config.fromVal, config.toVal, replaceText);
                                resultArea.setText(replaceText);
                                jTabbedPane1.setSelectedIndex(TabIndex.RESULT.ordinal());
                                // 
                                pasteTextToClipboard();
                            }
                        }
                    });
                    templateList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(templateList).defaultJListKeyPressed(evt);
                        }
                    });

                    // ? 
                    JListUtil.newInstance(templateList).setItemColorTextProcess(new ItemColorTextHandler() {
                        public Pair<String, Color> setColorAndText(Object value) {
                            PropConfigHandler.Config config = (PropConfigHandler.Config) value;
                            if (config.tradeOffScore != 0) {
                                return Pair.of(null, Color.GREEN);
                            }
                            return null;
                        }
                    });
                    // ? 
                }
                {
                    scheduleExecute = new JButton();
                    jPanel5.add(scheduleExecute, BorderLayout.SOUTH);
                    scheduleExecute.setText("schedule execute");
                    scheduleExecute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            scheduleExecuteActionPerformed(evt);
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("result", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        resultArea = new JTextArea();
                        jScrollPane2.setViewportView(resultArea);
                    }
                }
            }
        }

        {
            configHandler = new PropConfigHandler(prop, propFile, templateList, replaceArea);
            JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList);
            {
                tradeOffArea = new JTextArea();
                tradeOffArea.setRows(3);
                // tradeOffArea.setPreferredSize(new Dimension(0, 50));
                tradeOffArea.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        try {
                            if (JMouseEventUtil.buttonLeftClick(2, e)) {
                                String tradeOff = StringUtils.trimToEmpty(tradeOffArea.getText());
                                JSONObject json = null;
                                if (StringUtils.isBlank(tradeOff)) {
                                    json = new JSONObject();
                                    json.put(CONTAIN_ARRY_KEY, new JSONArray());
                                    json.put(NOT_CONTAIN_ARRY_KEY, new JSONArray());
                                    tradeOff = json.toString();
                                } else {
                                    json = JSONObject.fromObject(tradeOff);
                                }

                                // 
                                String selectItem = (String) JCommonUtil._JOptionPane_showInputDialog(
                                        "?!", "?",
                                        new Object[] { "NA", "equal", "not_equal", "ftl" }, "NA");
                                if ("NA".equals(selectItem)) {
                                    return;
                                }

                                String string = StringUtils.trimToEmpty(
                                        JCommonUtil._jOptionPane_showInputDialog(":"));
                                string = StringUtils.trimToEmpty(string);

                                if (StringUtils.isBlank(string)) {
                                    tradeOffArea.setText(json.toString());
                                    return;
                                }

                                String arryKey = "";
                                String boolKey = "";
                                String strKey = "";
                                String intKey = "";

                                if (selectItem.equals("equal")) {
                                    arryKey = CONTAIN_ARRY_KEY;
                                } else if (selectItem.equals("not_equal")) {
                                    arryKey = NOT_CONTAIN_ARRY_KEY;
                                } else if (selectItem.equals("ftl")) {
                                    strKey = FREEMARKER_KEY;
                                } else {
                                    throw new RuntimeException(" : " + selectItem);
                                }

                                if (StringUtils.isNotBlank(arryKey)) {
                                    if (!json.containsKey(arryKey)) {
                                        json.put(arryKey, new JSONArray());
                                    }
                                    JSONArray arry = (JSONArray) json.get(arryKey);
                                    boolean findOk = false;
                                    for (int ii = 0; ii < arry.size(); ii++) {
                                        if (StringUtils.equalsIgnoreCase(arry.getString(ii), string)) {
                                            findOk = true;
                                            break;
                                        }
                                    }
                                    if (!findOk) {
                                        arry.add(string);
                                    }
                                } else if (StringUtils.isNotBlank(strKey)) {
                                    json.put(strKey, string);
                                } else if (StringUtils.isNotBlank(intKey)) {
                                    json.put(intKey, Integer.parseInt(string));
                                } else if (StringUtils.isNotBlank(boolKey)) {
                                    json.put(boolKey, Boolean.valueOf(string));
                                }

                                tradeOffArea.setText(json.toString());

                                JCommonUtil._jOptionPane_showMessageDialog_info("?!");
                            }
                        } catch (Exception ex) {
                            JCommonUtil.handleException(ex);
                        }
                    }
                });
                {
                    panel = new JPanel();
                    jPanel3.add(panel, "4, 8, fill, fill");
                    {
                        multiLineCheckBox = new JCheckBox("");
                        panel.add(multiLineCheckBox);
                    }
                    {
                        autoPasteToClipboardCheckbox = new JCheckBox("");
                        panel.add(autoPasteToClipboardCheckbox);
                    }
                }
                {
                    lblNewLabel_3 = new JLabel("? ");
                    jPanel3.add(lblNewLabel_3, "2, 10");
                }
                jPanel3.add(JCommonUtil.createScrollComponent(tradeOffArea), "4, 10, fill, fill");
            }
            configHandler.reloadTemplateList();
        }

        this.setSize(512, 350);
        JCommonUtil.setJFrameCenter(this);
        JCommonUtil.defaultToolTipDelay();

        JCommonUtil.frameCloseDo(this, new WindowAdapter() {
            public void windowClosing(WindowEvent paramWindowEvent) {
                try {
                    prop.store(new FileOutputStream(propFile), "regexText");
                } catch (Exception e) {
                    JCommonUtil.handleException("properties store error!", e);
                }
                setVisible(false);
                dispose();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:au.org.ala.delta.editor.ui.ItemEditor.java

/**
 * Adds the event handlers to the UI components.
 *//*from w w  w . ja  va2 s .  co  m*/
private void addEventHandlers(ActionMap map) {
    spinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            if (_editsDisabled) {
                return;
            }

            updateItemSelection((Integer) spinner.getValue());
        }
    });

    rtfEditor.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            itemEditPerformed();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            itemEditPerformed();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            itemEditPerformed();
        }
    });
    rtfEditor.addKeyListener(new SelectionNavigationKeyListener() {

        @Override
        protected void advanceSelection() {
            _validator.verify(rtfEditor);
        }

    });
    taxonSelectionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    taxonSelectionList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (_editsDisabled) {
                return;
            }
            _selectedItem = _dataSet.getItem(taxonSelectionList.getSelectedIndex() + 1);
            updateDisplay();
        }
    });

    btnDone.setAction(map.get("itemEditDone"));
    chckbxTreatAsVariant.setAction(map.get("itemVarianceChanged"));
    btnSelect.setAction(map.get("selectItemByName"));
    taxonSelectionList.setSelectionAction(map.get("taxonSelected"));
    _validator = new TextComponentValidator(new ItemValidator(), this);

    // Give the item description text area focus.
    addInternalFrameListener(new InternalFrameAdapter() {
        @Override
        public void internalFrameActivated(InternalFrameEvent e) {
            rtfEditor.requestFocusInWindow();
        }
    });
}

From source file:com.rapidminer.gui.graphs.SimilarityGraphCreator.java

@Override
public JComponent getOptionComponent(final GraphViewer viewer, int index) {
    if (index == 0) {
        return new JLabel("Number of Edges:");
    } else if (index == 1) {
        this.distanceSlider.addChangeListener(new ChangeListener() {

            @Override/*from  ww  w .  j  a  v  a 2s  .  c  om*/
            public void stateChanged(ChangeEvent e) {
                if (!distanceSlider.getValueIsAdjusting()) {
                    addEdges();
                    viewer.updateLayout();
                }
            }
        });
        return distanceSlider;
    } else {
        return null;
    }
}