javax.swing.event.MouseInputListener Java Examples
The following examples show how to use
javax.swing.event.MouseInputListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapViewerFactory.java From bboxdb with Apache License 2.0 | 6 votes |
public static JXMapViewer createMapViewer() { final JXMapViewer mapViewer = new JXMapViewer(); // Create a TileFactoryInfo for OpenStreetMap final TileFactoryInfo info = new OSMTileFactoryInfo(); final DefaultTileFactory tileFactory = new DefaultTileFactory(info); tileFactory.setLocalCache(new FileBasedLocalCache(cacheDir.toFile(), false)); mapViewer.setTileFactory(tileFactory); final MouseInputListener mia = new PanMouseInputListener(mapViewer); mapViewer.addMouseListener(mia); mapViewer.addMouseMotionListener(mia); mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mapViewer)); mapViewer.addKeyListener(new PanKeyListener(mapViewer)); // Use 8 threads in parallel to load the tiles tileFactory.setThreadPoolSize(8); // Show start point showHagen(mapViewer); return mapViewer; }
Example #2
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private MainPanel() { super(new BorderLayout()); DefaultListModel<String> model = new DefaultListModel<>(); model.addElement("11\n1"); model.addElement("222222222222222\n222222222222222"); model.addElement("3333333333333333333\n33333333333333333333\n33333333333333333"); model.addElement("444"); add(new JScrollPane(new JList<String>(model) { private transient MouseInputListener handler; @Override public void updateUI() { removeMouseListener(handler); removeMouseMotionListener(handler); super.updateUI(); setFixedCellHeight(-1); handler = new CellButtonsMouseListener<>(this); addMouseListener(handler); addMouseMotionListener(handler); setCellRenderer(new ButtonsRenderer<>(model)); } })); setPreferredSize(new Dimension(320, 240)); }
Example #3
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private static <E> JList<E> makeList(ListModel<E> model) { return new JList<E>(model) { private transient MouseInputListener listener; @Override public void updateUI() { removeMouseListener(listener); removeMouseMotionListener(listener); setForeground(null); setBackground(null); setSelectionForeground(null); setSelectionBackground(null); super.updateUI(); listener = new ClearSelectionListener(); addMouseListener(listener); addMouseMotionListener(listener); } }; // list.putClientProperty("List.isFileList", Boolean.TRUE); // list.setLayoutOrientation(JList.HORIZONTAL_WRAP); // list.setFixedCellWidth(64); // list.setFixedCellHeight(64); // list.setVisibleRowCount(0); // return list; }
Example #4
Source File: JGridHeader.java From nextreports-designer with Apache License 2.0 | 6 votes |
@Override public void updateUI() { // register(or not) listener for selection if (allowSelection) { setUI(new BasicGridHeaderUI()); } else { setUI(new BasicGridHeaderUI() { @Override protected MouseInputListener createMouseInputListener() { return null; } }); } // register listener for cell resize if (resize) { setUI(new BasicGridHeaderUI() { protected MouseInputListener createMouseInputListener() { return new HeaderResizeMouseInputListener(); } }); } repaintManager.resizeAndRepaint(); }
Example #5
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
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; }
Example #6
Source File: LuckRootPaneUI.java From littleluck with Apache License 2.0 | 6 votes |
/** * <p>创建窗体鼠标监听器, 处理窗体的移动和拖拽事件</p> * * <p>Create Window mouse listener, handle window move and drag event.</p> * * @param root <code>JRootPane</code> * @return <code>MouseInputListener</code> window move and drag event listener. */ protected MouseInputListener installWindowListeners(JRootPane root) { Window window = SwingUtilities.getWindowAncestor(root); if (window != null) { if (mouseInputListener == null) { mouseInputListener = new WindowMouseHandler(root); } window.addMouseListener(mouseInputListener); window.addMouseMotionListener(mouseInputListener); } return mouseInputListener; }
Example #7
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private MainPanel() { super(new GridLayout(1, 2, 5, 5)); Box box1 = makeTestBox(); box1.setBorder(BorderFactory.createTitledBorder("DragScrollListener")); MouseInputListener l = new DragScrollListener(); box1.addMouseListener(l); box1.addMouseMotionListener(l); add(new JScrollPane(box1)); Box box2 = makeTestBox(); box2.setBorder(BorderFactory.createTitledBorder("DragScrollLayerUI")); add(new JLayer<>(new JScrollPane(box2), new DragScrollLayerUI())); setPreferredSize(new Dimension(320, 240)); }
Example #8
Source File: FrameDemo.java From littleluck with Apache License 2.0 | 5 votes |
/** * 自定义拖拽区域 */ protected MouseInputListener installWindowListeners(JRootPane root) { MouseInputListener listener = super.installWindowListeners(root); if(listener instanceof WindowMouseHandler) { ((WindowMouseHandler) listener).setDragArea(new LuckRectangle(root)); } return listener; }
Example #9
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private MainPanel() { super(new BorderLayout()); IntStream.range(0, 100) .mapToObj(i -> i % 19 == 0 || i % 17 == 0 ? PATTERN : "Java") .map(s -> new Object[] {s, ""}) .forEach(model::addRow); scroll.setVerticalScrollBar(scrollbar); scrollbar.getModel().addChangeListener(e -> label.repaint()); label.setIcon(new HighlightIcon()); Border in = BorderFactory.createLineBorder(Color.BLACK); Border out = BorderFactory.createEmptyBorder(5, 5, 5, 5); label.setBorder(BorderFactory.createCompoundBorder(out, in)); MouseInputListener handler = new HighlightBarHandler(); label.addMouseListener(handler); label.addMouseMotionListener(handler); JToggleButton button = new JToggleButton("highlight"); button.addActionListener(e -> { emphasisIndices.clear(); if (((JToggleButton) e.getSource()).isSelected()) { updateHighlighter(); } label.getRootPane().repaint(); }); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); box.add(button); add(scroll); add(label, BorderLayout.EAST); add(box, BorderLayout.SOUTH); setPreferredSize(new Dimension(320, 240)); }
Example #10
Source File: DarculaRootPaneUI.java From Darcula with Apache License 2.0 | 4 votes |
private MouseInputListener createWindowMouseInputListener(JRootPane root) { return new MouseInputHandler(); }
Example #11
Source File: AquaListUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Creates a delegate that implements MouseInputListener. */ protected MouseInputListener createMouseInputListener() { return new AquaListUI.MouseInputHandler(); }
Example #12
Source File: AquaTableUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Creates the mouse listener for the JTable. */ protected MouseInputListener createMouseInputListener() { return new AquaTableUI.MouseInputHandler(); }
Example #13
Source File: EditableHeaderUI.java From chipster with MIT License | 4 votes |
protected MouseInputListener createMouseInputListener() { return new MouseInputHandler((EditableHeader)header); }
Example #14
Source File: BegMenuItemUI.java From consulo with Apache License 2.0 | 4 votes |
@Override protected MouseInputListener createMouseInputListener(JComponent c) { return new MyMouseInputHandler(); }
Example #15
Source File: EditableHeaderUI.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected MouseInputListener createMouseInputListener() { return new MouseInputHandler( (EditableHeader) header ); }
Example #16
Source File: BasicGridUI.java From nextreports-designer with Apache License 2.0 | 4 votes |
/** * Creates the mouse listener for the JGrid. */ protected MouseInputListener createMouseInputListener() { return new MouseInputHandler(); }
Example #17
Source File: BegListUI.java From consulo with Apache License 2.0 | 4 votes |
protected MouseInputListener createMouseInputListener() { return new PatchedInputHandler(this.list); }
Example #18
Source File: ModernMenuItemUI.java From consulo with Apache License 2.0 | 4 votes |
@Override protected MouseInputListener createMouseInputListener(JComponent c) { return new MyMouseInputHandler(); }
Example #19
Source File: AnySelectionTableUI.java From wandora with GNU General Public License v3.0 | 4 votes |
@Override protected MouseInputListener createMouseInputListener() { return new AnySelectionMouseInputHandler(); }
Example #20
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override protected MouseInputListener createMouseInputListener(JComponent c) { return new BasicMenuItemUI.MouseInputHandler() { @Override public void mousePressed(MouseEvent e) { JMenu menu = (JMenu) menuItem; if (!menu.isEnabled() || SwingUtilities.isRightMouseButton(e)) { return; } super.mousePressed(e); // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // if (menu.isTopLevelMenu()) { // if (menu.isSelected() && menu.getPopupMenu().isShowing()) { // manager.clearSelectedPath(); // } else { // Container cnt = menu.getParent(); // if (cnt instanceof JMenuBar) { // MenuElement[] me = new MenuElement[2]; // me[0] = (MenuElement) cnt; // me[1] = menu; // manager.setSelectedPath(me); // } // } // } // MenuElement[] selectedPath = manager.getSelectedPath(); // if (selectedPath.length > 0 && selectedPath[selectedPath.length - 1] != menu.getPopupMenu()) { // if (menu.isTopLevelMenu() || menu.getDelay() == 0) { // MenuElement[] newPath = new MenuElement[selectedPath.length + 1]; // System.arraycopy(selectedPath, 0, newPath, 0, selectedPath.length); // newPath[selectedPath.length] = menu.getPopupMenu(); // MenuSelectionManager.defaultManager().setSelectedPath(newPath); // } else { // setupPostTimer(menu); // } // } } // @Override public void mouseReleased(MouseEvent e) { // JMenu menu = (JMenu) menuItem; // if (!menu.isEnabled()) { // return; // } // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // manager.processMouseEvent(e); // if (!e.isConsumed()) { // manager.clearSelectedPath(); // } // } // @Override public void mouseEntered(MouseEvent e) { // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // int modifiers = e.getModifiersEx(); // if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } else { // manager.setSelectedPath(getPath()); // } // } // @Override public void mouseExited(MouseEvent e) { // MenuSelectionManager manager = MenuSelectionManager.defaultManager(); // int modifiers = e.getModifiersEx(); // if ((modifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } else { // MenuElement[] path = manager.getSelectedPath(); // if (path.length > 1 && path[path.length - 1] == menuItem) { // MenuElement[] newPath = new MenuElement[path.length - 1]; // System.arraycopy(path, 0, newPath, 0, path.length - 1); // manager.setSelectedPath(newPath); // } // } // } // @Override public void mouseDragged(MouseEvent e) { // MenuSelectionManager.defaultManager().processMouseEvent(e); // } }; }
Example #21
Source File: WindowsMenuUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
protected MouseInputListener createMouseInputListener(JComponent c) { return new WindowsMouseInputHandler(); }
Example #22
Source File: BEMenuUI.java From beautyeye with Apache License 2.0 | 4 votes |
protected MouseInputListener createMouseInputListener(JComponent c) { return new BEMouseInputHandler(); }
Example #23
Source File: EditableTableHeaderUI.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override protected MouseInputListener createMouseInputListener() { return new MouseInputHandler((EditableTableHeader) header); }
Example #24
Source File: ToolBarUI.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override protected MouseInputListener createDockingListener() { return new RapidLookDockingListener(this.toolBar); }
Example #25
Source File: AquaTableUI.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Creates the mouse listener for the JTable. */ protected MouseInputListener createMouseInputListener() { return new AquaTableUI.MouseInputHandler(); }
Example #26
Source File: AquaListUI.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Creates a delegate that implements MouseInputListener. */ protected MouseInputListener createMouseInputListener() { return new AquaListUI.MouseInputHandler(); }
Example #27
Source File: WindowsMenuUI.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
protected MouseInputListener createMouseInputListener(JComponent c) { return new WindowsMouseInputHandler(); }
Example #28
Source File: DecoratedListUI.java From pumpernickel with MIT License | 4 votes |
@Override protected MouseInputListener createMouseInputListener() { return new DecorationMouseListener(super.createMouseInputListener()); }
Example #29
Source File: DecoratedListUI.java From pumpernickel with MIT License | 4 votes |
DecorationMouseListener(MouseInputListener l) { mouseListener = l; }
Example #30
Source File: AquaTableUI.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Creates the mouse listener for the JTable. */ protected MouseInputListener createMouseInputListener() { return new AquaTableUI.MouseInputHandler(); }