use of java.awt.event.MouseListener in project com.revolsys.open by revolsys.
the class ShowMenuMouseListener method addMenuListener.
@SuppressWarnings("rawtypes")
private boolean addMenuListener(final JComponent component) {
if (component != null) {
for (final MouseListener listener : component.getMouseListeners()) {
if (listener instanceof ShowMenuMouseListener) {
this.previousListener = (ShowMenuMouseListener) listener;
component.removeMouseListener(listener);
}
}
component.addMouseListener(this);
if (component instanceof JComboBox) {
final JComboBox comboBox = (JComboBox) component;
final ComboBoxEditor editor = comboBox.getEditor();
final Component editorComponent = editor.getEditorComponent();
addMenuListener((JComponent) editorComponent);
} else if (component instanceof JTextComponent) {
this.textComponent = (JTextComponent) component;
this.textComponent.setDragEnabled(true);
}
}
return true;
}
use of java.awt.event.MouseListener in project com.revolsys.open by revolsys.
the class BaseTreeListener method mouseClicked.
@Override
public void mouseClicked(final MouseEvent e) {
final int x = e.getX();
final int y = e.getY();
final TreePath path = this.tree.getPathForLocation(x, y);
if (path != null) {
final Object node = path.getLastPathComponent();
if (node instanceof MouseListener) {
final MouseListener listener = (MouseListener) node;
Object userObject = null;
if (node instanceof BaseTreeNode) {
final BaseTreeNode treeNode = (BaseTreeNode) node;
userObject = treeNode.getUserObject();
}
if (userObject == null) {
MenuFactory.setMenuSource(userObject);
} else {
MenuFactory.setMenuSource(node);
}
listener.mouseClicked(e);
}
}
}
use of java.awt.event.MouseListener in project lotro-companion by dmorcellet.
the class BuffEditionPanelController method buildBuffController.
private BuffIconController buildBuffController(BuffInstance buff) {
BuffIconController controller = new BuffIconController(buff, _toon);
JLabel label = controller.getLabel();
MouseListener popupListener = buildRightClickListener();
label.addMouseListener(popupListener);
MouseListener listener = buildLeftClickListener();
label.addMouseListener(listener);
return controller;
}
use of java.awt.event.MouseListener in project org.alloytools.alloy by AlloyTools.
the class SwingLogPanel method logLink.
/**
* Write a clickable link into the log window.
*/
public void logLink(final String link, final String linkDestination) {
if (log == null || link.length() == 0)
return;
if (linkDestination == null || linkDestination.length() == 0) {
log(link);
return;
}
clearError();
StyledDocument doc = log.getStyledDocument();
Style linkStyle = doc.addStyle("link", styleRegular);
final JLabel label = OurUtil.make(OurAntiAlias.label(link), new Font(fontName, Font.BOLD, fontSize), linkColor);
label.setAlignmentY(0.8f);
label.setMaximumSize(label.getPreferredSize());
label.addMouseListener(new MouseListener() {
@Override
public final void mousePressed(MouseEvent e) {
if (handler != null)
handler.doVisualize(linkDestination);
}
@Override
public final void mouseClicked(MouseEvent e) {
}
@Override
public final void mouseReleased(MouseEvent e) {
}
@Override
public final void mouseEntered(MouseEvent e) {
label.setForeground(hoverColor);
}
@Override
public final void mouseExited(MouseEvent e) {
label.setForeground(linkColor);
}
});
StyleConstants.setComponent(linkStyle, label);
links.add(label);
// Any character would do; the "." will be
reallyLog(".", linkStyle);
// replaced by the JLabel
log.setCaretPosition(doc.getLength());
lastSize = doc.getLength();
}
use of java.awt.event.MouseListener in project CodenameOne by codenameone.
the class CodenameOneImageRenderer method mouseClicked.
public void mouseClicked(MouseEvent e) {
Timeline t = (Timeline) image;
AnimationObject selection = t.getAnimationAt(e.getX(), e.getY());
// editing
if (selection == null) {
animationObjectList.clearSelection();
} else {
if (e.getClickCount() == 2) {
selectValue(selection);
MouseListener[] ls = animationObjectList.getListeners(MouseListener.class);
for (MouseListener l : ls) {
l.mouseClicked(e);
}
} else {
// selection
selectValue(selection);
}
}
repaint();
}
Aggregations