Search in sources :

Example 91 with ChangeEvent

use of javax.swing.event.ChangeEvent in project android by JetBrains.

the class ColumnTreeBuilder method build.

public JComponent build() {
    // Stash this value since it'll get stomped WideSelectionTreeUI.
    boolean showsRootHandles = myTree.getShowsRootHandles();
    myTree.setUI(new ColumnTreeUI());
    myTree.setShowsRootHandles(showsRootHandles);
    myTree.setCellRenderer(myCellRenderer);
    myTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() {

        @Override
        public void columnAdded(TableColumnModelEvent tableColumnModelEvent) {
        }

        @Override
        public void columnRemoved(TableColumnModelEvent tableColumnModelEvent) {
        }

        @Override
        public void columnMoved(TableColumnModelEvent tableColumnModelEvent) {
        }

        @Override
        public void columnMarginChanged(ChangeEvent changeEvent) {
            myTree.revalidate();
            myTree.repaint();
        }

        @Override
        public void columnSelectionChanged(ListSelectionEvent listSelectionEvent) {
        }
    });
    myTable.setRowSorter(myRowSorter);
    myRowSorter.addRowSorterListener(event -> {
        if (myTreeSorter != null && !myRowSorter.getSortKeys().isEmpty()) {
            RowSorter.SortKey key = myRowSorter.getSortKeys().get(0);
            Comparator<?> comparator = myRowSorter.getComparator(key.getColumn());
            Enumeration<TreePath> expanded = myTree.getExpandedDescendants(new TreePath(myTree.getModel().getRoot()));
            comparator = key.getSortOrder() == SortOrder.ASCENDING ? comparator : Collections.reverseOrder(comparator);
            myTreeSorter.sort(comparator, key.getSortOrder());
            if (expanded != null) {
                while (expanded.hasMoreElements()) {
                    myTree.expandPath(expanded.nextElement());
                }
            }
        }
    });
    myTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    for (ColumnBuilder column : myColumnBuilders) {
        column.create(myTableModel);
    }
    for (int i = 0; i < myColumnBuilders.size(); i++) {
        ColumnBuilder column = myColumnBuilders.get(i);
        column.configure(i, myTable, myRowSorter, myCellRenderer);
    }
    JPanel panel = new TreeWrapperPanel(myTable, myTree);
    if (myBackground != null) {
        panel.setBackground(myBackground);
    }
    JTableHeader header = myTable.getTableHeader();
    header.setReorderingAllowed(false);
    JViewport viewport = new JViewport();
    viewport.setView(header);
    JBScrollPane scrollPane = new JBScrollPane(panel);
    scrollPane.setColumnHeader(viewport);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    return scrollPane;
}
Also used : TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) TableColumnModelListener(javax.swing.event.TableColumnModelListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ChangeEvent(javax.swing.event.ChangeEvent) TreePath(javax.swing.tree.TreePath) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 92 with ChangeEvent

use of javax.swing.event.ChangeEvent in project libresonic by Libresonic.

the class PlayerTest method createGUI.

private void createGUI() {
    JFrame frame = new JFrame();
    JButton startButton = new JButton("Start");
    JButton stopButton = new JButton("Stop");
    JButton resetButton = new JButton("Reset");
    final JSlider gainSlider = new JSlider(0, 1000);
    startButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            createPlayer();
            player.play();
        }
    });
    stopButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            player.pause();
        }
    });
    resetButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            player.close();
            createPlayer();
        }
    });
    gainSlider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            float gain = (float) gainSlider.getValue() / 1000.0F;
            player.setGain(gain);
        }
    });
    frame.setLayout(new FlowLayout());
    frame.add(startButton);
    frame.add(stopButton);
    frame.add(resetButton);
    frame.add(gainSlider);
    frame.pack();
    frame.setVisible(true);
}
Also used : ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ActionEvent(java.awt.event.ActionEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 93 with ChangeEvent

use of javax.swing.event.ChangeEvent in project processdash by dtuma.

the class GroupFilterMenu method setSelectedItem.

public void setSelectedItem(UserFilter selection) {
    if (selection instanceof UserGroup) {
        UserGroup g = (UserGroup) selection;
        setIcon(groupIcon);
        setText(g.toString());
    } else if (selection instanceof UserGroupMember) {
        UserGroupMember m = (UserGroupMember) selection;
        setIcon(personIcon);
        setText(m.toString());
    }
    boolean isChange = !NullSafeObjectUtils.EQ(selectedItem, selection);
    this.selectedItem = selection;
    if (isChange) {
        for (ChangeListener l : listeners.getListeners(ChangeListener.class)) l.stateChanged(new ChangeEvent(this));
    }
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) UserGroupMember(net.sourceforge.processdash.team.group.UserGroupMember) UserGroup(net.sourceforge.processdash.team.group.UserGroup)

Example 94 with ChangeEvent

use of javax.swing.event.ChangeEvent in project n2a by frothga.

the class ParameterSpecGroupPanel method addParam.

public ParameterSpecPanel addParam(ParameterBundle bundle, ParameterSpecification useThisSpec) {
    ParameterSpecification spec;
    GroupType type = (GroupType) cboGroupType.getSelectedItem();
    Object defaultValue = bundle.getParameter().getDefaultValue();
    if (useThisSpec == null) {
        spec = chooseDefaultSpecification(type, defaultValue);
    } else {
        spec = useThisSpec;
    }
    final ParameterSpecPanel pnlSpec = new ParameterSpecPanel(bundle, spec, readOnly);
    pnlSpec.addRemoveListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            pnlParams.remove(specPanels.get(pnlSpec));
            specPanels.remove(pnlSpec);
            pnlParams.updateUI();
            fireChangeNotifier();
        }
    });
    pnlSpec.addEditListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            ParameterSpecification spec = pnlSpec.getSpecification();
            GroupType type = (GroupType) cboGroupType.getSelectedItem();
            switch(type) {
                case LATIN_HYPERCUBE:
                    if (!(spec instanceof EvenSpacingParameterSpecification)) {
                        cboGroupType.setSelectedItem(GroupType.MIXED);
                    }
                    break;
                case MONTE_CARLO:
                    if (!(spec instanceof EvenSpacingParameterSpecification)) {
                        cboGroupType.setSelectedItem(GroupType.MIXED);
                    }
                    break;
            }
            fireChangeNotifier();
        }
    });
    JPanel cont = Lay.p(pnlSpec, "eb=10t,opaque=false");
    specPanels.put(pnlSpec, cont);
    pnlParams.add(cont);
    updateUI();
    fireChangeNotifier();
    return pnlSpec;
}
Also used : JPanel(javax.swing.JPanel) ConstantParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.ConstantParameterSpecification) ParameterSpecification(gov.sandia.n2a.parms.ParameterSpecification) UniformParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.UniformParameterSpecification) EvenSpacingParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification) EvenSpacingParameterSpecification(gov.sandia.umf.platform.ensemble.params.specs.EvenSpacingParameterSpecification) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 95 with ChangeEvent

use of javax.swing.event.ChangeEvent in project cayenne by apache.

the class ObjEntityTabbedView method initController.

private void initController() {
    projectController.addObjEntityDisplayListener(this);
    projectController.addObjAttributeDisplayListener(this);
    projectController.addObjRelationshipDisplayListener(this);
    addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            resetRemoveButtons();
            projectController.setEntityTabSelection(getSelectedIndex());
            Component selected = getSelectedComponent();
            while (selected instanceof JScrollPane) {
                selected = ((JScrollPane) selected).getViewport().getView();
            }
            if (selected instanceof ExistingSelectionProcessor) {
                ((ExistingSelectionProcessor) selected).processExistingSelection(e);
            }
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) Component(java.awt.Component)

Aggregations

ChangeEvent (javax.swing.event.ChangeEvent)245 ChangeListener (javax.swing.event.ChangeListener)206 JPanel (javax.swing.JPanel)60 ActionEvent (java.awt.event.ActionEvent)52 ActionListener (java.awt.event.ActionListener)47 JLabel (javax.swing.JLabel)40 Dimension (java.awt.Dimension)30 GridBagConstraints (java.awt.GridBagConstraints)27 GridBagLayout (java.awt.GridBagLayout)24 JCheckBox (javax.swing.JCheckBox)24 Insets (java.awt.Insets)22 JButton (javax.swing.JButton)21 JSlider (javax.swing.JSlider)21 PropertyChangeEvent (java.beans.PropertyChangeEvent)20 JSpinner (javax.swing.JSpinner)19 SpinnerNumberModel (javax.swing.SpinnerNumberModel)19 BorderLayout (java.awt.BorderLayout)18 PropertyChangeListener (java.beans.PropertyChangeListener)17 IOException (java.io.IOException)16 BoxLayout (javax.swing.BoxLayout)16