Example usage for javax.swing.event ChangeEvent getSource

List of usage examples for javax.swing.event ChangeEvent getSource

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void oceansEmissiveSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_oceansEmissiveSpinnerStateChanged
{//GEN-HEADEREND:event_oceansEmissiveSpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();

    final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

    params.setOceansAndRiversEmissive(((float) ((Integer) source.getValue()).intValue()) / 100.0f);
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void noiseAmplitudeSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_noiseAmplitudeSpinnerStateChanged
{//GEN-HEADEREND:event_noiseAmplitudeSpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();
    final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

    params.setNoiseAmplitude(((float) ((Integer) source.getValue()).intValue()) / 100.0f);

    if (log.isDebugEnabled()) {
        log.debug("Noise amplitude set to: " + params.getNoiseAmplitude());
    }/*from ww  w.  ja v  a  2 s. co m*/
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void noiseFrequencySpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_noiseFrequencySpinnerStateChanged
{//GEN-HEADEREND:event_noiseFrequencySpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();
    final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

    params.setNoiseFrequency(((float) ((Integer) source.getValue()).intValue()) / 100.0f);

    if (log.isDebugEnabled()) {
        log.debug("Noise frequency set to: " + params.getNoiseFrequency());
    }/*from  www.j a va  2s .  c om*/
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void cloudsSubdivisionSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_cloudsSubdivisionSpinnerStateChanged
{//GEN-HEADEREND:event_cloudsSubdivisionSpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();
    final CloudParameters params = this.parent.getParameters().getCloudParameters();

    params.setSubdivisions((Integer) source.getValue());
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void noiseAmplitudeDecaySpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_noiseAmplitudeDecaySpinnerStateChanged
{//GEN-HEADEREND:event_noiseAmplitudeDecaySpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();
    final TerrainParameters params = this.parent.getParameters().getTerrainParameters();

    params.setNoiseAmplitudeDecay(((float) ((Integer) source.getValue()).intValue()) / 100.0f);

    if (log.isDebugEnabled()) {
        log.debug("Noise amplitude decay set to: " + params.getNoiseAmplitudeDecay());
    }/*from w w  w .j a v a 2s . co  m*/
}

From source file:ffx.ui.MainPanel.java

/**
 * {@inheritDoc}/*from ww w  . j  av a2s  .  c om*/
 */
@Override
public void stateChanged(ChangeEvent evt) {
    JTabbedPane jtp = (JTabbedPane) evt.getSource();
    int index = jtp.getSelectedIndex();
    if (index == 0) {
        graphicsCanvas.selected();
    } else if (index == 1) {
        keywordPanel.selected();
    } else if (index == 2) {
        modelingPanel.selected();
    }
}

From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java

/**
 * Creates the UI for the login and hooks up any listeners.
 * @param isDlg  whether the parent is a dialog (false mean JFrame)
 * @param iconName the icon that will be shown in the panel
 * @param engageUPPrefs whether it should load and save the username password into the prefs
 * @param helpContext the help context to use.
 *//*from  w  w  w .java2  s .c o  m*/
protected void createUI(final boolean isDlg, final String iconName, final String helpContext) {
    final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile();
    final AppPreferences localPrefs = AppPreferences.getLocalPrefs();

    //Font cachedFont = UIManager.getFont("JLabel.font");
    SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel");
    if (skinItem != null) {
        skinItem.pushFG("Label.foreground");
    }

    if (isNotEmbedded) {
        SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value
                0, //min
                Integer.MAX_VALUE, //max
                1); //step
        portSpinner = new JSpinner(portModel);
        JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#");
        portSpinner.setEditor(editor);

        portSpinner.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex());
                if (drvInfo != null && isNotEmbedded && portSpinner != null) {
                    drvInfo.setPort((Integer) portSpinner.getValue());
                }
            }
        });
        setControlSize(portSpinner);
    }

    // First create the controls and hook up listeners
    dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$
    svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$

    username = createTextField(15);
    password = createPasswordField(15);

    FocusAdapter focusAdp = new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            super.focusGained(e);

            JTextField tf = (JTextField) e.getSource();
            tf.selectAll();
        }
    };
    username.addFocusListener(focusAdp);
    password.addFocusListener(focusAdp);

    databases = new ValComboBox(dbPickList);
    if (databases.getComboBox() instanceof Java2sAutoComboBox) {
        ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true);
    }
    servers = new ValComboBox(svPickList);

    dbPickList.setComboBox(databases);
    svPickList.setComboBox(servers);

    setControlSize(password);
    setControlSize(databases);
    setControlSize(servers);

    if (masterUsrPwdProvider != null) {
        editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY");
        editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20));
        editKeyInfoBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (masterUsrPwdProvider != null && databases != null) {
                    String itemName = null;
                    if (databases.getComboBox().getSelectedItem() instanceof String) {
                        itemName = (String) databases.getComboBox().getSelectedItem();
                    } else {
                        PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem();
                        if (pli != null && pli.getValue() != null) {
                            itemName = pli.getValue();
                        }
                    }

                    if (itemName != null) {
                        masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false);
                    }
                }
            }
        });
    }

    rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$
    rememberUsernameCBX.setEnabled(engageUPPrefs);

    statusBar = new JStatusBar();
    statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$

    cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$
    loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$
    helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$

    forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$
    downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$
    moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$
    setControlSize(moreBtn);

    // Extra
    dbDrivers = DatabaseDriverInfo.getDriversList();
    dbDriverCBX = createComboBox(dbDrivers);

    dbDriverCBX.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUIControls();

            DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex());
            if (drvInfo != null && isNotEmbedded && portSpinner != null) {
                Integer defPort = drvInfo.getPortAsInt();
                int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort);

                portSpinner.setValue(portFromPref);
                drvInfo.setPort(portFromPref);
            }
        }
    });

    if (dbDrivers.size() > 0) {
        if (dbDrivers.size() == 1) {
            dbDriverCBX.setSelectedIndex(0);
            dbDriverCBX.setEnabled(false);

        } else {
            String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$
            int inx = Collections.binarySearch(dbDrivers,
                    new DatabaseDriverInfo(selectedStr, null, null, false, null));
            dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1);
        }

    } else {
        JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$
                getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$
        System.exit(1);
    }

    addFocusListenerForTextComp(username);
    addFocusListenerForTextComp(password);

    addKeyListenerFor(username, !isDlg);
    addKeyListenerFor(password, !isDlg);

    addKeyListenerFor(databases.getTextField(), !isDlg);
    addKeyListenerFor(servers.getTextField(), !isDlg);

    if (!isDlg) {
        addKeyListenerFor(loginBtn, true);
    }

    rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (dbListener != null) {
                dbListener.cancelled();
            }
        }
    });

    loginBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doLogin();
        }
    });

    HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$

    moreBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (extraPanel.isVisible()) {
                if (dbDriverCBX.getSelectedIndex() != -1) {
                    extraPanel.setVisible(false);
                    moreBtn.setIcon(forwardImgIcon);
                }

            } else {
                extraPanel.setVisible(true);
                moreBtn.setIcon(downImgIcon);
            }
            if (window != null) {
                window.pack();
            }
        }
    });

    // Ask the PropertiesPickListAdapter to set the index from the prefs
    dbPickList.setSelectedIndex();
    svPickList.setSelectedIndex();

    servers.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databases.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databases.getTextField().addFocusListener(new FocusAdapter() {
        String server = null;

        private String getServerStr() {
            String serverStr = null;
            Object serverObj = servers.getValue();
            if (serverObj != null) {
                serverStr = serverObj.toString();
            }
            return serverStr;
        }

        @Override
        public void focusGained(FocusEvent e) {
            server = getServerStr();
        }

        @Override
        public void focusLost(FocusEvent e) {
            if (server != null) {
                String newVal = getServerStr();
                if (newVal != null && !newVal.equals(server)) {
                    setUsrPwdControlsFromPrefs();
                }
            }
        }
    });

    setUsrPwdControlsFromPrefs();

    // Layout the form

    PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$
    CellConstraints cc = new CellConstraints();
    formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$

    addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$
    addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$
    formBuilder.add(moreBtn, cc.xy(3, 7));

    PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ 
            UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$

    extraPanel = extraPanelBlder.getPanel();
    extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2));

    //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$
    int y = 1;
    y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y);
    y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$
    y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$

    y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$
    if (isNotEmbedded) {
        y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$
    }
    if (editKeyInfoBtn != null) {
        PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p"));
        pb.add(editKeyInfoBtn, cc.xy(1, 1));
        y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y);
        pb.getPanel().setOpaque(false);
    }
    extraPanel.setVisible(false);

    formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1));

    PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$
    JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null;

    if (icon != null) {
        icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2));
    }

    formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5));

    if (icon != null) {
        outerPanel.add(icon, cc.xy(1, 1));
    }
    JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn);
    outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1));
    outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1));
    outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1));

    formBuilder.getPanel().setOpaque(false);
    outerPanel.getPanel().setOpaque(false);
    btnPanel.setOpaque(false);

    updateUIControls();

    if (skinItem != null) {
        skinItem.popFG("Label.foreground");
    }

    if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) {
        extraPanel.setVisible(true);
        moreBtn.setIcon(downImgIcon);
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

private JSlider makeSlider(int chip) {
    intervalSlider[chip] = new JSlider(JSlider.HORIZONTAL, 0, 5, prefs.getSleepTick(chip));

    intervalSlider[chip].addChangeListener(new ChangeListener() {
        /**//from w  ww .  j a  va 2s  .  co  m
         * React to slider moves
         * @param e
         */
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            // if (!source.getValueIsAdjusting())
            for (int chip = 0; chip < 2; chip++) {
                if (source == intervalSlider[chip]) {
                    setEmulatorSleepCode(chip, source.getValue());
                    prefs.setSleepTick(chip, source.getValue());
                }
            }
        }
    });

    intervalSlider[chip].putClientProperty("JComponent.sizeVariant", "large");

    //Create the label table
    Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
    labelTable.put(0, getSmallLabel("0"));
    labelTable.put(1, getSmallLabel("1ms"));
    labelTable.put(2, getSmallLabel("10ms"));
    labelTable.put(3, getSmallLabel("0.1s"));
    labelTable.put(4, getSmallLabel("1s"));
    labelTable.put(5, getSmallLabel("10s"));
    intervalSlider[chip].setLabelTable(labelTable);

    //Turn on labels at major tick marks.
    intervalSlider[chip].setMajorTickSpacing(1);
    intervalSlider[chip].setPaintLabels(true);
    intervalSlider[chip].setPaintTicks(true);
    intervalSlider[chip].setSnapToTicks(true);

    intervalSlider[chip].setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    intervalSlider[chip].setMaximumSize(new Dimension(400, 50));

    return intervalSlider[chip];
}

From source file:net.sf.jabref.gui.groups.GroupSelector.java

/**
 * The first element for each group defines which field to use for the quicksearch. The next two define the name and
 * regexp for the group./*w  ww  .  j  a  v  a2  s  .  co m*/
 */
public GroupSelector(JabRefFrame frame, SidePaneManager manager) {
    super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups"));

    this.frame = frame;
    hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"),
            !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"),
            Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS));
    ButtonGroup nonHits = new ButtonGroup();
    nonHits.add(hideNonHits);
    nonHits.add(grayOut);
    floatCb.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected()));
    andCb.addChangeListener(event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS,
            andCb.isSelected()));
    invCb.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected()));
    showOverlappingGroups.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING,
                    showOverlappingGroups.isSelected());
            if (!showOverlappingGroups.isSelected()) {
                groupsTree.setOverlappingGroups(Collections.emptyList());
            }
        }
    });

    grayOut.addChangeListener(
            event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected()));

    JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) {

        floatCb.setSelected(true);
        highlCb.setSelected(false);
    } else {
        highlCb.setSelected(true);
        floatCb.setSelected(false);
    }
    JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false);
    if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) {
        andCb.setSelected(true);
        orCb.setSelected(false);
    } else {
        orCb.setSelected(true);
        andCb.setSelected(false);
    }

    showNumberOfElements.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS,
                    showNumberOfElements.isSelected());
            if (groupsTree != null) {
                groupsTree.invalidate();
                groupsTree.repaint();
            }
        }
    });

    autoAssignGroup.addChangeListener(event -> Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP,
            autoAssignGroup.isSelected()));

    invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS));
    showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING));
    editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE);
    editModeCb.setSelected(editModeIndicator);
    showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
    autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));

    JButton openSettings = new JButton(IconTheme.JabRefIcon.PREFERENCES.getSmallIcon());
    settings.add(andCb);
    settings.add(orCb);
    settings.addSeparator();
    settings.add(invCb);
    settings.addSeparator();
    settings.add(editModeCb);
    settings.addSeparator();
    settings.add(grayOut);
    settings.add(hideNonHits);
    settings.addSeparator();
    settings.add(showOverlappingGroups);
    settings.addSeparator();
    settings.add(showNumberOfElements);
    settings.add(autoAssignGroup);
    openSettings.addActionListener(e -> {
        if (!settings.isVisible()) {
            JButton src = (JButton) e.getSource();
            showNumberOfElements
                    .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS));
            autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP));
            settings.show(src, 0, openSettings.getHeight());
        }
    });

    editModeCb.addActionListener(e -> setEditMode(editModeCb.getState()));

    JButton newButton = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon());
    int butSize = newButton.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);

    newButton.setPreferredSize(butDim);
    newButton.setMinimumSize(butDim);
    JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFile.GROUP).getHelpButton();
    helpButton.setPreferredSize(butDim);
    helpButton.setMinimumSize(butDim);
    JButton autoGroup = new JButton(IconTheme.JabRefIcon.AUTO_GROUP.getSmallIcon());
    autoGroup.setPreferredSize(butDim);
    autoGroup.setMinimumSize(butDim);
    openSettings.setPreferredSize(butDim);
    openSettings.setMinimumSize(butDim);
    Insets butIns = new Insets(0, 0, 0, 0);
    helpButton.setMargin(butIns);
    openSettings.setMargin(butIns);
    newButton.addActionListener(e -> {
        GroupDialog gd = new GroupDialog(frame, panel, null);
        gd.setVisible(true);
        if (gd.okPressed()) {
            AbstractGroup newGroup = gd.getResultingGroup();
            groupsRoot.addNewGroup(newGroup, panel.getUndoManager());
            panel.markBaseChanged();
            frame.output(Localization.lang("Created group \"%0\".", newGroup.getName()));
        }
    });
    andCb.addActionListener(e -> valueChanged(null));
    orCb.addActionListener(e -> valueChanged(null));
    invCb.addActionListener(e -> valueChanged(null));
    showOverlappingGroups.addActionListener(e -> valueChanged(null));
    autoGroup.addActionListener(e -> {
        AutoGroupDialog gd = new AutoGroupDialog(frame, panel, groupsRoot,
                Globals.prefs.get(JabRefPreferences.GROUPS_DEFAULT_FIELD), " .,",
                Globals.prefs.get(JabRefPreferences.KEYWORD_SEPARATOR));
        gd.setVisible(true);
        // gd does the operation itself
    });
    floatCb.addActionListener(e -> valueChanged(null));
    highlCb.addActionListener(e -> valueChanged(null));
    hideNonHits.addActionListener(e -> valueChanged(null));
    grayOut.addActionListener(e -> valueChanged(null));
    newButton.setToolTipText(Localization.lang("New group"));
    andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups."));
    orCb.setToolTipText(
            Localization.lang("Display all entries belonging to one or more of the selected groups."));
    autoGroup.setToolTipText(Localization.lang("Automatically create groups for database."));
    openSettings.setToolTipText(Localization.lang("Settings"));
    invCb.setToolTipText(
            "<html>" + Localization.lang("Show entries <b>not</b> in group selection") + "</html>");
    showOverlappingGroups.setToolTipText(Localization
            .lang("Highlight groups that contain entries contained in any currently selected group"));
    floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top"));
    highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection"));
    editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries"));
    ButtonGroup bgr = new ButtonGroup();
    bgr.add(andCb);
    bgr.add(orCb);
    ButtonGroup visMode = new ButtonGroup();
    visMode.add(floatCb);
    visMode.add(highlCb);

    JPanel rootPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    rootPanel.setLayout(gbl);

    GridBagConstraints con = new GridBagConstraints();
    con.fill = GridBagConstraints.BOTH;
    con.weightx = 1;
    con.gridwidth = 1;
    con.gridy = 0;

    con.gridx = 0;
    gbl.setConstraints(newButton, con);
    rootPanel.add(newButton);

    con.gridx = 1;
    gbl.setConstraints(autoGroup, con);
    rootPanel.add(autoGroup);

    con.gridx = 2;
    gbl.setConstraints(openSettings, con);
    rootPanel.add(openSettings);

    con.gridx = 3;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(helpButton, con);
    rootPanel.add(helpButton);

    groupsTree = new GroupsTree(this);
    groupsTree.addTreeSelectionListener(this);

    JScrollPane groupsTreePane = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    groupsTreePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weighty = 1;
    con.gridx = 0;
    con.gridwidth = 4;
    con.gridy = 1;
    gbl.setConstraints(groupsTreePane, con);
    rootPanel.add(groupsTreePane);

    add(rootPanel, BorderLayout.CENTER);
    setEditMode(editModeIndicator);
    definePopup();
    NodeAction moveNodeUpAction = new MoveNodeUpAction();
    moveNodeUpAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK));
    NodeAction moveNodeDownAction = new MoveNodeDownAction();
    moveNodeDownAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK));
    NodeAction moveNodeLeftAction = new MoveNodeLeftAction();
    moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK));
    NodeAction moveNodeRightAction = new MoveNodeRightAction();
    moveNodeRightAction.putValue(Action.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK));

    setGroups(GroupTreeNode.fromGroup(new AllEntriesGroup()));
}

From source file:SplineInterpolatorTest.java

public void stateChanged(ChangeEvent e) {
    if (e.getSource() instanceof JSlider) {
        m_AlphaValue = ((JSlider) e.getSource()).getValue() / 100.0f;
        m_bAuto = false;/*from w w  w  . j av a  2 s  .  com*/
    } else {
        m_bAuto = true;
    }
}