Search in sources :

Example 41 with ItemEvent

use of java.awt.event.ItemEvent in project frostwire by frostwire.

the class SearchEnginesPaneItem method createToggleAllCheckbox.

private Component createToggleAllCheckbox() {
    JPanel panel = new JPanel();
    panel.setMinimumSize(new Dimension(300, 60));
    panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
    BoxLayout layout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
    panel.setLayout(layout);
    panel.add(Box.createHorizontalGlue());
    panel.add(new JSeparator());
    panel.add(Box.createRigidArea(new Dimension(0, 10)));
    allCheckbox = new JCheckBox(I18n.tr("Check/Uncheck all"));
    panel.add(allCheckbox);
    allCheckbox.setSelected(areAll(true));
    allCheckbox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            JCheckBox cBox = (JCheckBox) e.getItemSelectable();
            checkAll(cBox.isSelected());
        }
    });
    return panel;
}
Also used : ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener)

Example 42 with ItemEvent

use of java.awt.event.ItemEvent in project jdk8u_jdk by JetBrains.

the class WCheckboxMenuItemPeer method handleAction.

// native callbacks
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem) this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {

        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), (state) ? ItemEvent.SELECTED : ItemEvent.DESELECTED));
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) CheckboxMenuItem(java.awt.CheckboxMenuItem)

Example 43 with ItemEvent

use of java.awt.event.ItemEvent in project intellij-plugins by JetBrains.

the class MarkdownPreviewSettingsForm method createUIComponents.

private void createUIComponents() {
    //noinspection unchecked
    final List<MarkdownHtmlPanelProvider.ProviderInfo> providerInfos = ContainerUtil.mapNotNull(MarkdownHtmlPanelProvider.getProviders(), provider -> {
        if (provider.isAvailable() == MarkdownHtmlPanelProvider.AvailabilityInfo.UNAVAILABLE) {
            return null;
        }
        return provider.getProviderInfo();
    });
    myPreviewPanelModel = new CollectionComboBoxModel<>(providerInfos, providerInfos.get(0));
    myPreviewProvider = new ComboBox(myPreviewPanelModel);
    mySplitLayoutModel = new EnumComboBoxModel<>(SplitFileEditor.SplitEditorLayout.class);
    myDefaultSplitLayout = new ComboBox(mySplitLayoutModel);
    myLastItem = myPreviewProvider.getSelectedItem();
    myPreviewProvider.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            final Object item = e.getItem();
            if (e.getStateChange() != ItemEvent.SELECTED || !(item instanceof MarkdownHtmlPanelProvider.ProviderInfo)) {
                return;
            }
            final MarkdownHtmlPanelProvider provider = MarkdownHtmlPanelProvider.createFromInfo((MarkdownHtmlPanelProvider.ProviderInfo) item);
            final MarkdownHtmlPanelProvider.AvailabilityInfo availability = provider.isAvailable();
            if (!availability.checkAvailability(myMainPanel)) {
                myPreviewProvider.setSelectedItem(myLastItem);
            } else {
                myLastItem = item;
                updateUseGrayscaleEnabled();
            }
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ComboBox(com.intellij.openapi.ui.ComboBox) ItemListener(java.awt.event.ItemListener) MarkdownHtmlPanelProvider(org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider)

Example 44 with ItemEvent

use of java.awt.event.ItemEvent in project jdk8u_jdk by JetBrains.

the class CCheckboxMenuItem method handleAction.

public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem) getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {

        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
Also used : ItemEvent(java.awt.event.ItemEvent) CheckboxMenuItem(java.awt.CheckboxMenuItem)

Example 45 with ItemEvent

use of java.awt.event.ItemEvent in project JMRI by JMRI.

the class RosterGroupsPanel method getButtons.

private JToolBar getButtons() {
    JToolBar controls = new JToolBar();
    controls.setLayout(new GridLayout(1, 0, 0, 0));
    controls.setFloatable(false);
    final JToggleButton addGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Add.png")), false);
    final JToggleButton actGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Action.png")), false);
    addGroupBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new CreateRosterGroupAction("", scrollPane.getTopLevelAncestor()).actionPerformed(e);
            addGroupBtn.setSelected(false);
        }
    });
    actGroupBtn.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() == ItemEvent.SELECTED) {
                TreePath g = new TreePath(_model.getPathToRoot(_groups));
                if (_tree.getSelectionPath() != null) {
                    if (_tree.getSelectionPath().getLastPathComponent().toString().equals(Roster.ALLENTRIES)) {
                        allEntriesMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - allEntriesMenu.getPreferredSize().height);
                    } else if (g.isDescendant(_tree.getSelectionPath()) && !_tree.getSelectionPath().isDescendant(g)) {
                        groupsMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - groupsMenu.getPreferredSize().height);
                    }
                }
            }
        }
    });
    PopupMenuListener PML = new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
        // do nothing
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
            actGroupBtn.setSelected(false);
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent pme) {
            actGroupBtn.setSelected(false);
        }
    };
    allEntriesMenu.addPopupMenuListener(PML);
    groupsMenu.addPopupMenuListener(PML);
    controls.add(addGroupBtn);
    controls.add(actGroupBtn);
    return controls;
}
Also used : ImageIcon(javax.swing.ImageIcon) ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) PopupMenuListener(javax.swing.event.PopupMenuListener) JComponent(javax.swing.JComponent) JToolBar(javax.swing.JToolBar) PopupMenuEvent(javax.swing.event.PopupMenuEvent) GridLayout(java.awt.GridLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) TreePath(javax.swing.tree.TreePath) ItemListener(java.awt.event.ItemListener)

Aggregations

ItemEvent (java.awt.event.ItemEvent)346 ItemListener (java.awt.event.ItemListener)320 ActionEvent (java.awt.event.ActionEvent)124 ActionListener (java.awt.event.ActionListener)114 JPanel (javax.swing.JPanel)106 JLabel (javax.swing.JLabel)84 JCheckBox (javax.swing.JCheckBox)74 JComboBox (javax.swing.JComboBox)65 Dimension (java.awt.Dimension)59 JButton (javax.swing.JButton)53 BorderLayout (java.awt.BorderLayout)48 JTextField (javax.swing.JTextField)46 ButtonGroup (javax.swing.ButtonGroup)35 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)33 ChangeEvent (javax.swing.event.ChangeEvent)32 ChangeListener (javax.swing.event.ChangeListener)31 GridLayout (java.awt.GridLayout)30 GridBagConstraints (java.awt.GridBagConstraints)29 JMenu (javax.swing.JMenu)29 GridBagLayout (java.awt.GridBagLayout)28