下面列出了javax.swing.JCheckBoxMenuItem#setToolTipText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Overrides {@link XAction#addToMenu(JMenu)} to add a {@link JCheckBoxMenuItem} instead of a {@link JMenuItem}.
*/
@Override
public JMenuItem addToMenu( final JMenu menu ) {
final JCheckBoxMenuItem mi = new JCheckBoxMenuItem();
menu.add( mi );
mi.setAction( this );
mi.setToolTipText( null ); // We don't want tool tip on menu items...
return mi;
}
/**
* Overrides {@link XAction#addToMenu(JPopupMenu)} to add a {@link JCheckBoxMenuItem} instead of a {@link JMenuItem}.
*/
@Override
public JMenuItem addToMenu( final JPopupMenu menu ) {
final JCheckBoxMenuItem mi = new JCheckBoxMenuItem();
menu.add( mi );
mi.setAction( this );
mi.setToolTipText( null ); // We don't want tool tip on menu items...
return mi;
}
JMenu makeStopOptionsMenu()
{
return new JMenu(Strings.get("menu_stopOptions")) {
private static final long serialVersionUID = 1L;
{
setToolTipText(Strings.get("menu_stopOptions.descr"));
final ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e)
{
updateNameOfActionStopBundles();
}
};
itemStopOptionsTransient =
new JCheckBoxMenuItem(Strings.get("stop_option_transient"), false);
itemStopOptionsTransient.setToolTipText(Strings
.get("stop_option_transient.descr"));
itemStopOptionsTransient.addItemListener(itemListener);
add(itemStopOptionsTransient);
updateNameOfActionStopBundles();
}
};
}
JMenu makeStartOptionsMenu()
{
return new JMenu(Strings.get("menu_startOptions")) {
private static final long serialVersionUID = 1L;
{
setToolTipText(Strings.get("menu_startOptions.descr"));
final ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e)
{
updateNameOfActionStartBundles();
}
};
itemStartOptionsTransient =
new JCheckBoxMenuItem(Strings.get("start_option_transient"), false);
itemStartOptionsTransient.setToolTipText(Strings
.get("start_option_transient.descr"));
itemStartOptionsTransient.addItemListener(itemListener);
itemStartOptionsPolicy =
new JCheckBoxMenuItem(Strings.get("start_option_policy"), true);
itemStartOptionsPolicy.setToolTipText(Strings
.get("start_option_policy.descr"));
itemStartOptionsPolicy.addItemListener(itemListener);
add(itemStartOptionsTransient);
add(itemStartOptionsPolicy);
updateNameOfActionStartBundles();
}
};
}
void fill() {
removeAll();
DockableState[] dockables = dockingContext.getDesktopList().get(0).getDockables();
List<DockableState> sorted = new LinkedList<>();
sorted.addAll(Arrays.asList(dockables));
sorted.sort(Comparator.comparing(o -> o.getDockable().getDockKey().getName()));
for (final DockableState state : sorted) {
if (state.getDockable() instanceof DummyDockable) {
continue;
}
DockKey dockKey = state.getDockable().getDockKey();
String keyName = dockKey.getKey();
boolean cont = false;
for (String prefix : HIDE_IN_DOCKABLE_MENU_PREFIX_REGISTRY) {
if (keyName.startsWith(prefix)) {
cont = true;
break;
}
}
if (cont) {
continue;
}
String description = null;
if (dockKey instanceof ResourceDockKey) {
description = ((ResourceDockKey) dockKey).getShortDescription();
}
description = description != null ? description : "";
String text = dockKey.getName();
if (SystemInfoUtilities.getOperatingSystem() != OperatingSystem.OSX) {
// OS X cannot use html in menus so only do it for other OS
text = String.format(DOCKABLE_HTML, dockKey.getName(), description);
}
JCheckBoxMenuItem item = new JCheckBoxMenuItem(text, dockKey.getIcon());
item.setSelected(!state.isClosed());
item.addActionListener(e -> toggleState(state));
// special handling for results overview dockable in Results perspective
// and process view dockable in Design perspective
// these dockables are not allowed to be closed so we disable this item while in respective perspective
String perspectiveName = RapidMinerGUI.getMainFrame().getPerspectiveController().getModel().getSelectedPerspective().getName();
if ((PerspectiveModel.RESULT.equals(perspectiveName) && ResultDisplay.RESULT_DOCK_KEY.equals(keyName))
|| (PerspectiveModel.DESIGN.equals(perspectiveName) && ProcessPanel.PROCESS_PANEL_DOCK_KEY.equals(keyName))) {
item.setEnabled(false);
item.setToolTipText(I18N.getGUIMessage("gui.label.dockable.unclosable.tip"));
}
add(item);
ensurePopupHeight();
}
}