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;
}
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));
}
});
}
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();
}
}
});
}
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);
}
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;
}
Aggregations