use of java.awt.event.MouseMotionAdapter in project jdk8u_jdk by JetBrains.
the class ExtraMouseClick method init.
public void init() {
this.setLayout(new BorderLayout());
frame.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
System.out.println("MousePressed");
pressed = true;
}
public void mouseReleased(MouseEvent e) {
System.out.println("MouseReleased");
released = true;
}
public void mouseClicked(MouseEvent e) {
System.out.println("MouseClicked!!!!");
clicked = true;
}
});
frame.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
System.out.println("MouseDragged--" + e);
dragged = true;
}
public void mouseMoved(MouseEvent e) {
}
});
}
use of java.awt.event.MouseMotionAdapter in project intellij-community by JetBrains.
the class ToolWindowContentUi method initMouseListeners.
public static void initMouseListeners(final JComponent c, final ToolWindowContentUi ui) {
if (c.getClientProperty(ui) != null)
return;
final Point[] myLastPoint = new Point[1];
c.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(final MouseEvent e) {
if (myLastPoint[0] == null)
return;
final Window window = SwingUtilities.windowForComponent(c);
if (window instanceof IdeFrame)
return;
final Point windowLocation = window.getLocationOnScreen();
PointerInfo info = MouseInfo.getPointerInfo();
if (info == null)
return;
final Point newPoint = info.getLocation();
Point p = myLastPoint[0];
windowLocation.translate(newPoint.x - p.x, newPoint.y - p.y);
window.setLocation(windowLocation);
myLastPoint[0] = newPoint;
}
});
c.addMouseListener(new MouseAdapter() {
public void mousePressed(final MouseEvent e) {
PointerInfo info = MouseInfo.getPointerInfo();
myLastPoint[0] = info != null ? info.getLocation() : e.getLocationOnScreen();
if (!e.isPopupTrigger()) {
if (!UIUtil.isCloseClick(e)) {
ui.myWindow.fireActivated();
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (!e.isPopupTrigger()) {
if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) {
ui.processHide(e);
}
}
}
});
c.addMouseListener(new PopupHandler() {
public void invokePopup(final Component comp, final int x, final int y) {
final Content content = c instanceof BaseLabel ? ((BaseLabel) c).getContent() : null;
ui.showContextMenu(comp, x, y, ui.myWindow.getPopupGroup(), content);
}
});
c.putClientProperty(ui, Boolean.TRUE);
}
use of java.awt.event.MouseMotionAdapter in project adempiere by adempiere.
the class VSortTab method jbInit.
/**
* Static Layout
* @throws Exception
*/
private void jbInit() throws Exception {
this.setLayout(mainLayout);
//
noLabel.setText("No");
yesLabel.setText("Yes");
for (MouseMotionListener mml : noList.getMouseMotionListeners()) noList.removeMouseMotionListener(mml);
for (MouseMotionListener mml : yesList.getMouseMotionListeners()) yesList.removeMouseMotionListener(mml);
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
if (me.getClickCount() > 1) {
JList list = (JList) me.getComponent();
Point p = me.getPoint();
int index = list.locationToIndex(p);
if (index > -1 && list.getCellBounds(index, index).contains(p))
migrateValueAcrossLists(me);
}
}
};
yesList.addMouseListener(mouseListener);
noList.addMouseListener(mouseListener);
//
yesList.setCellRenderer(listRenderer);
noList.setCellRenderer(listRenderer);
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
migrateValueAcrossLists(ae);
}
};
bAdd.setIcon(Env.getImageIcon("Detail24.gif"));
bAdd.setMargin(new Insets(2, 2, 2, 2));
bAdd.addActionListener(actionListener);
bRemove.setIcon(Env.getImageIcon("Parent24.gif"));
bRemove.setMargin(new Insets(2, 2, 2, 2));
bRemove.addActionListener(actionListener);
MouseInputListener crossListMouseListener = new DragListener();
yesList.addMouseListener(crossListMouseListener);
yesList.addMouseMotionListener(crossListMouseListener);
noList.addMouseListener(crossListMouseListener);
noList.addMouseMotionListener(crossListMouseListener);
actionListener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
migrateValueWithinYesList(ae);
}
};
bUp.setIcon(Env.getImageIcon("Previous24.gif"));
bUp.setMargin(new Insets(2, 2, 2, 2));
bUp.addActionListener(actionListener);
bDown.setIcon(Env.getImageIcon("Next24.gif"));
bDown.setMargin(new Insets(2, 2, 2, 2));
bDown.addActionListener(actionListener);
MouseMotionListener yesListMouseMotionListener = new MouseMotionAdapter() {
public void mouseDragged(MouseEvent me) {
JList list = (JList) me.getComponent();
Point p = me.getPoint();
int index = list.locationToIndex(p);
if (index > -1 && list.getCellBounds(index, index).contains(p))
migrateValueWithinYesList(me);
}
};
yesList.addMouseMotionListener(yesListMouseMotionListener);
// Yamel Senih, 2015-11-13
// Maximize Panel when the window is resized
yesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
noList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this.add(noLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(yesLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.add(bDown, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
this.add(noPane, new GridBagConstraints(0, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
this.add(yesPane, new GridBagConstraints(2, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
this.add(bUp, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
this.add(bAdd, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
this.add(bRemove, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
// End Yamel Senih
}
use of java.awt.event.MouseMotionAdapter in project jabref by JabRef.
the class FieldFormatterCleanupsPanel method buildLayout.
private void buildLayout(List<FieldFormatterCleanup> actionsToDisplay) {
FormBuilder builder = FormBuilder.create().layout(new FormLayout("left:pref, 13dlu, left:pref:grow, 4dlu, pref, 4dlu, pref", "pref, 2dlu, pref, 2dlu, pref, 4dlu, pref, 2dlu, fill:pref:grow, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu"));
builder.add(cleanupEnabled).xyw(1, 1, 7);
actionsList = new JList<>(new CleanupActionsListModel(actionsToDisplay));
actionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
actionsList.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
super.mouseMoved(e);
CleanupActionsListModel m = (CleanupActionsListModel) actionsList.getModel();
int index = actionsList.locationToIndex(e.getPoint());
if (index > -1) {
actionsList.setToolTipText(m.getElementAt(index).getFormatter().getDescription());
}
}
});
actionsList.getModel().addListDataListener(new ListDataListener() {
@Override
public void intervalRemoved(ListDataEvent e) {
//index0 is sufficient, because of SingleSelection
if (e.getIndex0() == 0) {
//when an item gets deleted, the next one becomes the new 0
actionsList.setSelectedIndex(e.getIndex0());
}
if (e.getIndex0() > 0) {
actionsList.setSelectedIndex(e.getIndex0() - 1);
}
}
@Override
public void intervalAdded(ListDataEvent e) {
//empty, not needed
}
@Override
public void contentsChanged(ListDataEvent e) {
//empty, not needed
}
});
builder.add(actionsList).xyw(3, 5, 5);
resetButton = new JButton(Localization.lang("Reset"));
resetButton.addActionListener(e -> ((CleanupActionsListModel) actionsList.getModel()).reset(defaultFormatters));
BibDatabaseContext databaseContext = JabRefGUI.getMainFrame().getCurrentBasePanel().getDatabaseContext();
recommendButton = new JButton(Localization.lang("Recommended for %0", databaseContext.getMode().getFormattedName()));
boolean isBiblatex = databaseContext.isBiblatexMode();
recommendButton.addActionListener(e -> {
if (isBiblatex) {
((CleanupActionsListModel) actionsList.getModel()).reset(Cleanups.RECOMMEND_BIBLATEX_ACTIONS);
} else {
((CleanupActionsListModel) actionsList.getModel()).reset(Cleanups.RECOMMEND_BIBTEX_ACTIONS);
}
});
removeButton = new JButton(Localization.lang("Remove selected"));
removeButton.addActionListener(e -> ((CleanupActionsListModel) actionsList.getModel()).removeAtIndex(actionsList.getSelectedIndex()));
builder.add(removeButton).xy(7, 11);
builder.add(resetButton).xy(3, 11);
builder.add(recommendButton).xy(5, 11);
builder.add(getSelectorPanel()).xyw(3, 15, 5);
makeDescriptionTextAreaLikeJLabel();
builder.add(descriptionAreaText).xyw(3, 17, 5);
this.setLayout(new BorderLayout());
this.add(builder.getPanel(), BorderLayout.WEST);
updateDescription();
// make sure the layout is set according to the checkbox
cleanupEnabled.addActionListener(new EnablementStatusListener(fieldFormatterCleanups.isEnabled()));
cleanupEnabled.setSelected(fieldFormatterCleanups.isEnabled());
}
use of java.awt.event.MouseMotionAdapter in project jdk8u_jdk by JetBrains.
the class bug7154841 method initAndShowUI.
private static void initAndShowUI() {
popupMenu = new JPopupMenu();
for (int i = 0; i < 100; i++) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem(" Test " + i);
item.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
passed = true;
}
});
popupMenu.add(item);
}
frame = new JFrame();
screenBounds.set(getScreenBounds());
frame.setBounds(screenBounds.get());
frame.setVisible(true);
}
Aggregations