use of javax.swing.event.MouseInputListener 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 javax.swing.event.MouseInputListener in project bboxdb by jnidzwetzki.
the class OSMView method createMapViewer.
/**
* Get an instance of the map viewer
* @return
*/
protected JXMapViewer createMapViewer() {
mapViewer = new JXMapViewer();
// Create a TileFactoryInfo for OpenStreetMap
final TileFactoryInfo info = new OSMTileFactoryInfo();
final DefaultTileFactory tileFactory = new DefaultTileFactory(info);
mapViewer.setTileFactory(tileFactory);
final MouseInputListener mia = new PanMouseInputListener(mapViewer);
mapViewer.addMouseListener(mia);
mapViewer.addMouseMotionListener(mia);
// Use 8 threads in parallel to load the tiles
tileFactory.setThreadPoolSize(8);
// Set the focus
showHagen();
// The KD Tree painter
final OSMOverlayPainter kdosmPainter = new OSMOverlayPainter(guiModel);
mapViewer.setOverlayPainter(kdosmPainter);
return mapViewer;
}
use of javax.swing.event.MouseInputListener in project java-swing-tips by aterai.
the class TogglePopupHandler method makeStayOpenCheckBoxMenuItem.
private static JMenuItem makeStayOpenCheckBoxMenuItem(String title) {
JMenuItem mi = new JMenuItem(" ");
mi.setLayout(new BorderLayout());
mi.add(new JCheckBox(title) {
private transient MouseInputListener handler;
@Override
public void updateUI() {
removeMouseListener(handler);
removeMouseMotionListener(handler);
super.updateUI();
handler = new DispatchParentHandler();
addMouseListener(handler);
addMouseMotionListener(handler);
setFocusable(false);
setOpaque(false);
}
});
return mi;
}
use of javax.swing.event.MouseInputListener in project artisynth_core by artisynth.
the class ViewerManager method doAddViewer.
private void doAddViewer(GLViewer viewer) {
myViewers.add(viewer);
myPopupManagers.add(new PopupManager(viewer));
viewer.setSelectionEnabled(selectionEnabledP);
viewer.setSelectOnPress(selectOnPressP);
setMouseBindings(viewer, getMouseBindings());
viewer.getMouseHandler().setMouseWheelZoomScale(myMouseWheelZoomScale);
for (MouseInputListener l : myMouseListeners) {
viewer.addMouseInputListener(l);
}
for (KeyListener l : myKeyListeners) {
viewer.addKeyListener(l);
}
}
use of javax.swing.event.MouseInputListener in project artisynth_core by artisynth.
the class ViewerManager method removeViewer.
public boolean removeViewer(GLViewer viewer) {
int idx = myViewers.indexOf(viewer);
if (idx != -1) {
for (MouseInputListener l : myMouseListeners) {
viewer.removeMouseInputListener(l);
}
for (KeyListener l : myKeyListeners) {
viewer.removeKeyListener(l);
}
myViewers.remove(idx);
myPopupManagers.remove(idx);
return true;
} else {
return false;
}
}
Aggregations