Search in sources :

Example 1 with MouseInputListener

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
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) Point(java.awt.Point) MouseMotionListener(java.awt.event.MouseMotionListener) Point(java.awt.Point) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseListener(java.awt.event.MouseListener) ActionListener(java.awt.event.ActionListener) MouseInputListener(javax.swing.event.MouseInputListener) JList(javax.swing.JList)

Example 2 with MouseInputListener

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;
}
Also used : JXMapViewer(org.jxmapviewer.JXMapViewer) PanMouseInputListener(org.jxmapviewer.input.PanMouseInputListener) DefaultTileFactory(org.jxmapviewer.viewer.DefaultTileFactory) PanMouseInputListener(org.jxmapviewer.input.PanMouseInputListener) MouseInputListener(javax.swing.event.MouseInputListener) OSMTileFactoryInfo(org.jxmapviewer.OSMTileFactoryInfo) TileFactoryInfo(org.jxmapviewer.viewer.TileFactoryInfo) OSMTileFactoryInfo(org.jxmapviewer.OSMTileFactoryInfo)

Example 3 with MouseInputListener

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;
}
Also used : MouseInputListener(javax.swing.event.MouseInputListener)

Example 4 with MouseInputListener

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);
    }
}
Also used : MouseInputListener(javax.swing.event.MouseInputListener) KeyListener(java.awt.event.KeyListener) ViewerPopupManager(maspack.widgets.ViewerPopupManager)

Example 5 with MouseInputListener

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;
    }
}
Also used : MouseInputListener(javax.swing.event.MouseInputListener) KeyListener(java.awt.event.KeyListener)

Aggregations

MouseInputListener (javax.swing.event.MouseInputListener)6 KeyListener (java.awt.event.KeyListener)2 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 MouseMotionAdapter (java.awt.event.MouseMotionAdapter)1 MouseMotionListener (java.awt.event.MouseMotionListener)1 WindowEvent (java.awt.event.WindowEvent)1 JList (javax.swing.JList)1 ViewerPopupManager (maspack.widgets.ViewerPopupManager)1 JXMapViewer (org.jxmapviewer.JXMapViewer)1 OSMTileFactoryInfo (org.jxmapviewer.OSMTileFactoryInfo)1 PanMouseInputListener (org.jxmapviewer.input.PanMouseInputListener)1 DefaultTileFactory (org.jxmapviewer.viewer.DefaultTileFactory)1 TileFactoryInfo (org.jxmapviewer.viewer.TileFactoryInfo)1