List of usage examples for java.awt.event MouseEvent BUTTON1
int BUTTON1
To view the source code for java.awt.event MouseEvent BUTTON1.
Click Source Link
From source file:org.kalypso.ogc.gml.widgets.base.PanToWidget.java
public PanToWidget() { super("pan to", ""); //$NON-NLS-1$ //$NON-NLS-2$ m_mouseButtons = new int[] { MouseEvent.BUTTON1, MouseEvent.BUTTON2 }; }
From source file:SWTUtils.java
/** * Creates an AWT <code>MouseEvent</code> from a swt event. * This method helps passing SWT mouse event to awt components. * @param event The swt event.// w w w.j a v a 2 s. c o m * @return A AWT mouse event based on the given SWT event. */ public static MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event) { int button = MouseEvent.NOBUTTON; switch (event.button) { case 1: button = MouseEvent.BUTTON1; break; case 2: button = MouseEvent.BUTTON2; break; case 3: button = MouseEvent.BUTTON3; break; } int modifiers = 0; if ((event.stateMask & SWT.CTRL) != 0) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if ((event.stateMask & SWT.SHIFT) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } if ((event.stateMask & SWT.ALT) != 0) { modifiers |= InputEvent.ALT_DOWN_MASK; } MouseEvent awtMouseEvent = new MouseEvent(DUMMY_PANEL, event.hashCode(), event.time, modifiers, event.x, event.y, 1, false, button); return awtMouseEvent; }
From source file:org.jcurl.demo.editor.SpeedController.java
public void mouseClicked(MouseEvent e) { log.info("" + hot.idx); if (e.getButton() == MouseEvent.BUTTON1) { int mask = 1 << hot.idx; if (e.isShiftDown()) { int old = panel.getSelectedMask(); if ((mask & old) == 0) mask |= old;//from w ww . ja va2 s . co m else mask = ~mask & old; } panel.setSelectedMask(mask); } }
From source file:de.tbuchloh.kiskis.gui.systray.Java6SystemTray.java
/** * @see de.tbuchloh.kiskis.gui.systray.ISystemTray#show() */// www . j a v a 2s . c o m public void show() { if (!SystemTray.isSupported()) { LOG.error("System tray is not supported!"); return; } final SystemTray tray = SystemTray.getSystemTray(); final Image image = Toolkit.getDefaultToolkit().getImage(_main.getTrayIconURL()); final MouseListener mouseListener = new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() >= 2) { _main.setVisible(!_main.isVisible()); } } }; final PopupMenu popup = _main.getPopupMenu(); _trayIcon = new TrayIcon(image, BuildProperties.getFullTitle(), popup); _trayIcon.setImageAutoSize(true); _trayIcon.addMouseListener(mouseListener); try { tray.add(_trayIcon); } catch (final AWTException e) { e.printStackTrace(); } }
From source file:ru.codemine.pos.ui.windows.document.cheque.ChequeListWindow.java
@Override public void setupActionListeners() { setEditActionListener(viewCheque);/*from w w w . j a v a 2 s.c om*/ table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Point p = e.getPoint(); int row = table.rowAtPoint(p); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { menuItemEdit.doClick(); } } }); actionListenersInit = true; }
From source file:de.tbuchloh.kiskis.gui.widgets.BasicTextField.java
private void init() { _copyAction = M.createAction(this, "onCopyToClipboard"); _specialActionsMenu = new JPopupMenu(); for (final Object element : getContextMenuActions()) { final Action act = (Action) element; _specialActionsMenu.add(act);// w w w.j a v a2 s . co m } addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { return; } final int x = 0; // _pwdField.getWidth() // - _specialActionsMenu.getWidth(); final int y = getHeight(); LOG.debug("Show context menu x=" + x + ", y=" + y); _specialActionsMenu.show(BasicTextField.this, x, y); } }); }
From source file:ru.codemine.pos.ui.windows.users.UsersListWindow.java
@Override public void setupActionListeners() { setNewActionListener(newUser);/*from w w w .jav a2 s .co m*/ setEditActionListener(editUser); setDeleteActionListener(deleteUser); setRefreshActionListener(refreshUsersList); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Point p = e.getPoint(); int row = table.rowAtPoint(p); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { menuItemEdit.doClick(); } } }); actionListenersInit = true; }
From source file:ru.codemine.pos.ui.windows.stores.StoresListWindow.java
@Override public void setupActionListeners() { setNewActionListener(newStore);/*from w w w . j a v a2 s .c o m*/ setEditActionListener(editStore); setDeleteActionListener(deleteStore); setRefreshActionListener(refreshStoreList); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Point p = e.getPoint(); int row = table.rowAtPoint(p); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { menuItemEdit.doClick(); } } }); actionListenersInit = true; }
From source file:org.optaplanner.examples.tsp.swingui.TspWorldPanel.java
public TspWorldPanel(TspPanel tspPanel) { this.tspPanel = tspPanel; addComponentListener(new ComponentAdapter() { @Override//w w w. j a v a2 s. co m public void componentResized(ComponentEvent e) { // TODO Not thread-safe during solving TravelingSalesmanTour travelingSalesmanTour = TspWorldPanel.this.tspPanel .getTravelingSalesmanTour(); if (travelingSalesmanTour != null) { resetPanel(travelingSalesmanTour); } } }); MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (translator != null) { double longitude = translator.translateXToLongitude(e.getX()); double latitude = translator.translateYToLatitude(e.getY()); if (e.getButton() == MouseEvent.BUTTON1) { dragSourceStandstill = TspWorldPanel.this.tspPanel .findNearestStandstill(new AirLocation(-1L, latitude, longitude)); TravelingSalesmanTour tour = TspWorldPanel.this.tspPanel.getTravelingSalesmanTour(); dragTargetStandstill = tour.getDomicile(); resetPanel(tour); } else if (e.getButton() == MouseEvent.BUTTON2 || e.getButton() == MouseEvent.BUTTON3) { TspWorldPanel.this.tspPanel.insertLocationAndVisit(longitude, latitude); } } } @Override public void mouseDragged(MouseEvent e) { if (translator != null) { if (dragSourceStandstill != null) { double longitude = translator.translateXToLongitude(e.getX()); double latitude = translator.translateYToLatitude(e.getY()); dragTargetStandstill = TspWorldPanel.this.tspPanel .findNearestStandstill(new AirLocation(-1L, latitude, longitude)); TravelingSalesmanTour tour = TspWorldPanel.this.tspPanel.getTravelingSalesmanTour(); if (dragSourceStandstill == dragTargetStandstill) { dragTargetStandstill = tour.getDomicile(); } resetPanel(tour); } } } @Override public void mouseReleased(MouseEvent e) { if (translator != null) { if (e.getButton() == MouseEvent.BUTTON1) { double longitude = translator.translateXToLongitude(e.getX()); double latitude = translator.translateYToLatitude(e.getY()); dragTargetStandstill = TspWorldPanel.this.tspPanel .findNearestStandstill(new AirLocation(-1L, latitude, longitude)); TravelingSalesmanTour tour = TspWorldPanel.this.tspPanel.getTravelingSalesmanTour(); if (dragSourceStandstill == dragTargetStandstill) { dragTargetStandstill = tour.getDomicile(); } Standstill sourceStandstill = TspWorldPanel.this.dragSourceStandstill; Standstill targetStandstill = TspWorldPanel.this.dragTargetStandstill; TspWorldPanel.this.dragSourceStandstill = null; TspWorldPanel.this.dragTargetStandstill = null; // connectStandstills() will call resetPanel() TspWorldPanel.this.tspPanel.connectStandstills(sourceStandstill, targetStandstill); } } } }; addMouseListener(mouseAdapter); addMouseMotionListener(mouseAdapter); europaBackground = new ImageIcon(getClass().getResource("europaBackground.png")); }
From source file:org.kootox.episodesmanager.ui.systray.EpisodesTrayIcon.java
public void create() { //Check the SystemTray support if (!SystemTray.isSupported()) { if (log.isInfoEnabled()) { log.info("SystemTray is not supported"); }/* w w w. j a va2s.c om*/ return; } if (loaded) { return; } final PopupMenu popup = new PopupMenu(); final TrayIcon trayIcon = new TrayIcon(createImage("systray.png", "tray icon")); final SystemTray tray = SystemTray.getSystemTray(); // Create a popup menu components MenuItem display = new MenuItem("Display"); MenuItem exit = new MenuItem("Exit"); //Add components to popup menu popup.add(display); popup.addSeparator(); popup.add(exit); trayIcon.setPopupMenu(popup); try { tray.add(trayIcon); } catch (AWTException e) { if (log.isDebugEnabled()) { log.debug("TrayIcon could not be added."); } return; } trayIcon.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON1) { showHide(); } } @Override public void mousePressed(MouseEvent mouseEvent) { //Do nothing } @Override public void mouseReleased(MouseEvent mouseEvent) { //Do nothing } @Override public void mouseEntered(MouseEvent mouseEvent) { //Do nothing } @Override public void mouseExited(MouseEvent mouseEvent) { //Do nothing } }); display.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showHide(); } }); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { EpisodesManagerMainUI mainUI = EpisodesManagerContext.MAIN_UI_ENTRY_DEF.getContextValue(context); mainUI.close(); } }); loaded = true; if (log.isDebugEnabled()) { log.debug("Systray loaded"); } }