本文整理了Java中javax.swing.JMenuItem.addMouseListener()
方法的一些代码示例,展示了JMenuItem.addMouseListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.addMouseListener()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:addMouseListener
暂无
代码示例来源:origin: Audiveris/audiveris
private JMenuItem buildTitle (final Sheet sheet,
final Inter inter)
{
JMenuItem title = new JMenuItem("Relations:");
title.setEnabled(false);
title.addMouseListener(new AbstractMouseListener()
{
@Override
public void mouseEntered (MouseEvent e)
{
sheet.getInterIndex().getEntityService().publish(
new EntityListEvent<>(
this,
SelectionHint.ENTITY_INIT,
MouseMovement.PRESSING,
inter));
}
});
return title;
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the context menu if it does not already exists
*
* @return context menu
*/
private JPopupMenu getContextMenu() {
if(contextMenu == null) {
contextMenu = new JPopupMenu();
// add new tag item
JMenuItem newTagContextMenuItem = new JMenuItem(guiTextConfig.getString("AddNewTagMenuItem"));
newTagContextMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
showAddTagDialog();
contextMenu.setVisible(false);
}
});
contextMenu.add(newTagContextMenuItem);
}
return contextMenu;
}
代码示例来源:origin: GoldenGnu/jeveassets
public Component add(final JMenuItem jMenuItem, boolean keepOpen) {
if (keepOpen) {
//jPopupMenu.setLightWeightPopupEnabled(true);
jMenuItem.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
showPopupMenu();
jMenuItem.setArmed(true);
}
@Override
public void mouseEntered(MouseEvent e) {
jMenuItem.setArmed(true);
}
@Override
public void mouseExited(MouseEvent e) {
jMenuItem.setArmed(false);
}
});
}
return add(jMenuItem);
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the file menu item if it does not already exists
*
* @return file menu
*/
private JMenu getFileMenu() {
JMenu fileMenu = new JMenu(guiTextConfig.getString("FileMenuItem"));
// exit
JMenuItem exitMenuItem = new JMenuItem();
exitMenuItem.setText(guiTextConfig.getString("QuitMenuItem"));
exitMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
System.exit(0);
}
});
fileMenu.add(exitMenuItem);
return fileMenu;
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the antenna menu item if it does not already exists
*
* @return antenna menu
*/
private JMenu getAntennaMenu() {
JMenu antennaMenu = new JMenu(guiTextConfig.getString("AntennaMenuItem"));
// new antenna
JMenuItem newAntennaMenuItem = new JMenuItem();
newAntennaMenuItem.setText(guiTextConfig.getString("AddNewAntennaMenuItem"));
newAntennaMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
showAddAntennaDialog();
}
});
antennaMenu.add(newAntennaMenuItem);
return antennaMenu;
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the tag menu item if it does not already exists
*
* @return tag menu
*/
private JMenu getTagMenu() {
JMenu tagMenu = new JMenu(guiTextConfig.getString("TagMenuItem"));
// new tag
JMenuItem newTagMenuItem = new JMenuItem();
newTagMenuItem.setText(guiTextConfig.getString("AddNewTagMenuItem"));
newTagMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
showAddTagDialog();
}
});
tagMenu.add(newTagMenuItem);
return tagMenu;
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the file menu item
*
* @return file menu
*/
private JMenu getFileMenu() {
JMenu fileMenu = new JMenu(guiTextConfig.getString("FileMenuItem"));
// exit
JMenuItem exitMenuItem = new JMenuItem();
exitMenuItem.setText(guiTextConfig.getString("QuitMenuItem"));
exitMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
System.exit(0);
}
});
fileMenu.add(exitMenuItem);
return fileMenu;
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the view menu item
*
* @return view menu
*/
private JMenu getViewMenu() {
JMenu viewMenu = new JMenu(guiTextConfig.getString("ViewMenuItem"));
// exit
JMenuItem refreshMenuItem = new JMenuItem();
refreshMenuItem.setText(guiTextConfig.getString("RefreshMenuItem"));
refreshMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
updateGUI();
}
});
viewMenu.add(refreshMenuItem);
return viewMenu;
}
代码示例来源:origin: org.fosstrak.hal/hal-impl-sim
/**
* creates the tag menu item
*
* @return tag menu
*/
private JMenu getTagMenu() {
JMenu tagMenu = new JMenu(guiTextConfig.getString("TagMenuItem"));
// new tag
JMenuItem newTagMenuItem = new JMenuItem();
newTagMenuItem.setText(guiTextConfig.getString("AddNewTagMenuItem"));
newTagMenuItem.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
showAddTagDialog();
}
});
tagMenu.add(newTagMenuItem);
return tagMenu;
}
代码示例来源:origin: com.github.arnabk/pgslookandfeel
protected void installListeners() {
super.installListeners();
menuItem.addMouseListener(createButtonListener(menuItem));
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
/**
* Constructor.
*
* @param rowCount The number of rows that will be displayed before
* scrolling arrows are drawn.
*/
public ScrollableJPopupMenu(int rowCount) {
enableEvents(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK);
visibleRowCount = rowCount;
children = new ArrayList<>(rowCount);
MenuMouseAdapter adapter = new MenuMouseAdapter();
previousItem = new ArrowMenuItem(upIcon);
previousItem.putClientProperty(PROPERTY_TIMER, previousTimer);
previousItem.addMouseListener(adapter);
nextItem = new ArrowMenuItem(downIcon);
nextItem.putClientProperty(PROPERTY_TIMER, nextTimer);
nextItem.addMouseListener(adapter);
refresh();
}
代码示例来源:origin: net.sf.ingenias/editor
/**
* Constructor.
*
* @param rowCount The number of rows that will be displayed before
* scrolling arrows are drawn.
*/
public ScrollableJPopupMenu(int rowCount) {
enableEvents(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK);
visibleRowCount = rowCount;
children = new ArrayList(rowCount);
MenuMouseAdapter adapter = new MenuMouseAdapter();
previousItem = new ArrowMenuItem(upIcon);
previousItem.putClientProperty(PROPERTY_TIMER, previousTimer);
previousItem.addMouseListener(adapter);
nextItem = new ArrowMenuItem(downIcon);
nextItem.putClientProperty(PROPERTY_TIMER, nextTimer);
nextItem.addMouseListener(adapter);
refresh();
}
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
/**
* Constructor.
*
* @param rowCount The number of rows that will be displayed before
* scrolling arrows are drawn.
*/
public ScrollableJPopupMenu(int rowCount) {
enableEvents(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK);
visibleRowCount = rowCount;
children = new ArrayList(rowCount);
MenuMouseAdapter adapter = new MenuMouseAdapter();
previousItem = new ArrowMenuItem(upIcon);
previousItem.putClientProperty(PROPERTY_TIMER, previousTimer);
previousItem.addMouseListener(adapter);
nextItem = new ArrowMenuItem(downIcon);
nextItem.putClientProperty(PROPERTY_TIMER, nextTimer);
nextItem.addMouseListener(adapter);
refresh();
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
/** Installs listeners for the associated menu item */
protected void installListeners()
{
mouseInputListener= createMouseInputListener(menuItem);
menuDragMouseListener= createMenuDragMouseListener(menuItem);
menuKeyListener= createMenuKeyListener(menuItem);
propertyChangeListener= createPropertyChangeListener(menuItem);
menuItem.addMouseListener(mouseInputListener);
menuItem.addMouseMotionListener(mouseInputListener);
menuItem.addMenuDragMouseListener(menuDragMouseListener);
menuItem.addMenuKeyListener(menuKeyListener);
menuItem.addPropertyChangeListener(propertyChangeListener);
}
代码示例来源:origin: com.jidesoft/jide-oss
protected void installListeners() {
if ((mouseInputListener = createMouseInputListener(menuItem)) != null) {
menuItem.addMouseListener(mouseInputListener);
menuItem.addMouseMotionListener(mouseInputListener);
}
if ((menuDragMouseListener = createMenuDragMouseListener(menuItem)) != null) {
menuItem.addMenuDragMouseListener(menuDragMouseListener);
}
if ((menuKeyListener = createMenuKeyListener(menuItem)) != null) {
menuItem.addMenuKeyListener(menuKeyListener);
}
if ((propertyChangeListener = createPropertyChangeListener(menuItem)) != null) {
menuItem.addPropertyChangeListener(propertyChangeListener);
}
}
代码示例来源:origin: com.jidesoft/jide-oss
protected void installListeners() {
if ((mouseInputListener = createMouseInputListener(menuItem)) != null) {
menuItem.addMouseListener(mouseInputListener);
menuItem.addMouseMotionListener(mouseInputListener);
}
if ((menuDragMouseListener = createMenuDragMouseListener(menuItem)) != null) {
menuItem.addMenuDragMouseListener(menuDragMouseListener);
}
if ((menuKeyListener = createMenuKeyListener(menuItem)) != null) {
menuItem.addMenuKeyListener(menuKeyListener);
}
if ((propertyChangeListener = createPropertyChangeListener(menuItem)) != null) {
menuItem.addPropertyChangeListener(propertyChangeListener);
}
}
代码示例来源:origin: com.jidesoft/jide-oss
protected void installListeners() {
if ((mouseInputListener = createMouseInputListener(menuItem)) != null) {
menuItem.addMouseListener(mouseInputListener);
menuItem.addMouseMotionListener(mouseInputListener);
}
if ((menuDragMouseListener = createMenuDragMouseListener(menuItem)) != null) {
menuItem.addMenuDragMouseListener(menuDragMouseListener);
}
if ((menuKeyListener = createMenuKeyListener(menuItem)) != null) {
menuItem.addMenuKeyListener(menuKeyListener);
}
if ((propertyChangeListener = createPropertyChangeListener(menuItem)) != null) {
menuItem.addPropertyChangeListener(propertyChangeListener);
}
}
代码示例来源:origin: Audiveris/audiveris
@Override
public void updateUserLocation (Rectangle rect)
{
// We rebuild the menu items on each update, since the set of glyphs is brand new.
removeAll();
Collection<Glyph> glyphs = sheet.getGlyphIndex().getSelectedGlyphList();
if ((glyphs != null) && !glyphs.isEmpty()) {
UIUtil.insertTitle(this, "Tribes:");
for (Glyph glyph : glyphs) {
JMenuItem item = new TribeMenu(glyph, sheet);
if (!glyph.getGroups().isEmpty()) {
item.setToolTipText(glyph.getGroups().toString());
}
item.addMouseListener(glyphListener);
add(item);
}
setVisible(true);
} else {
setVisible(false);
}
super.updateUserLocation(rect);
}
代码示例来源:origin: Audiveris/audiveris
@Override
public void updateUserLocation (Rectangle rect)
{
// We rebuild the menu items on each update, since the set of glyphs is brand new.
removeAll();
Collection<Glyph> glyphs = sheet.getGlyphIndex().getSelectedGlyphList();
if ((glyphs != null) && !glyphs.isEmpty()) {
UIUtil.insertTitle(this, "Glyphs:");
for (Glyph glyph : glyphs) {
///JMenuItem item = new SampleMenu(glyph, sheet);
JMenuItem item = new ShapeMenu(glyph, sheet);
if (!glyph.getGroups().isEmpty()) {
item.setToolTipText(glyph.getGroups().toString());
}
item.addMouseListener(glyphListener);
add(item);
}
setVisible(true);
} else {
setVisible(false);
}
super.updateUserLocation(rect);
}
代码示例来源:origin: Audiveris/audiveris
/**
* Creates a new {@code InterMenu} object.
*
* @param inter originating inter
* @param relations (non empty) set of inter relations
*/
public InterMenu (final Inter inter,
final Set<Relation> relations)
{
this.inter = inter;
final Sheet sheet = inter.getSig().getSystem().getSheet();
menu = new SeparableMenu(new InterAction(inter, null));
// Title
menu.add(buildTitle(sheet, inter));
menu.addSeparator();
interController = sheet.getInterController();
for (Relation relation : relations) {
JMenuItem item = new JMenuItem(new RelationAction(inter, relation));
item.addMouseListener(relationListener);
menu.add(item);
}
menu.trimSeparator();
}
内容来源于网络,如有侵权,请联系作者删除!