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:playground.sergioo.facilitiesGenerator2012.gui.ClustersPanel.java
@Override public void mouseClicked(MouseEvent e) { double[] p = getWorld(e.getX(), e.getY()); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3) camera.centerCamera(p);//from www . ja va2 s .c o m else { if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1) camera.zoomIn(p[0], p[1]); else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3) camera.zoomOut(p[0], p[1]); } repaint(); }
From source file:org.cds06.speleograph.GraphPanel.java
/** * Callback method when click on a graph location. * * @param event information about the event. */// w ww .j a v a2s . c o m @Override public void chartMouseClicked(ChartMouseEvent event) { if (event.getEntity() instanceof AxisEntity) { AxisEntity entity = (AxisEntity) event.getEntity(); if (event.getTrigger().getButton() == MouseEvent.BUTTON1 && event.getTrigger().getClickCount() == 2) { if (entity.getAxis() instanceof NumberAxis) editNumberAxis((NumberAxis) entity.getAxis()); else if (entity.getAxis() instanceof DateAxis) editDateAxis(); } } }
From source file:org.kalypso.ui.rrm.internal.map.editRelation.EditRelationWidget.java
@Override public void mouseReleased(final MouseEvent e) { if (e.getButton() != MouseEvent.BUTTON1) return;/*from w w w .j a v a 2 s . c om*/ m_performRunner.execute(); }
From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java
/** * event: a mouse event occured on a node in the <code>view</code> * @param selPath the path of the node where the mouse event occured. * @param ev//from w w w . j a v a2s .c o m */ private void mouseEventOnNode(TreePath selPath, MouseEvent ev) { final SearchConditionTreeNode node = (SearchConditionTreeNode) selPath.getLastPathComponent(); final JTree tree = (JTree) ev.getComponent(); // select the node: tree.setSelectionPath(selPath); if (ev.isPopupTrigger()) { // show popup menu: final JPopupMenu popupMenu = this.getPopupMenu(node, tree); if (popupMenu != null) { popupMenu.show(ev.getComponent(), ev.getX(), ev.getY()); } } else if (ev.getID() == MouseEvent.MOUSE_CLICKED) { if (ev.getButton() == MouseEvent.BUTTON1) { if (ev.getClickCount() == 2) { if (this.clctfproviderfactory == null) { throw new IllegalStateException( "No CollectableFieldsProviderFactory was defined for the search editor."); } // perform the node's default action: final Action actDefault = node.getDefaultTreeNodeAction(tree, this.clcteRoot, this.clctfproviderfactory, this.additionalFields); if (actDefault != null) { actDefault.actionPerformed(null); } } } } }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.tooloptions.LayerValueIconList.java
protected void processMouseClick(final HexButton source, final MouseEvent evt) { if ((evt.getModifiersEx() & (MouseEvent.CTRL_DOWN_MASK | MouseEvent.SHIFT_DOWN_MASK)) != 0) { if ((evt.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) { this.selectionModel.addSelectionInterval(source.value.getIndex(), source.value.getIndex()); } else {/*from ww w . j a va 2s. c o m*/ final int selIndex = source.value.getIndex(); final int minindex = Math.min(selIndex, this.selectionModel.getMinSelectionIndex()); final int maxindex = Math.max(selIndex, this.selectionModel.getMaxSelectionIndex()); this.selectionModel.setSelectionInterval(Math.max(0, minindex), Math.max(0, maxindex)); } } else { this.selectionModel.setSelectionInterval(source.value.getIndex(), source.value.getIndex()); } switch (evt.getButton()) { case MouseEvent.BUTTON1: { for (final LayerIconListListener l : this.listeners) { l.onLeftClick(source.getHexValue(), source.getHexIcon()); } } break; case MouseEvent.BUTTON3: { for (final LayerIconListListener l : this.listeners) { l.onRightClick(source.getHexValue(), source.getHexIcon()); } } break; } }
From source file:playground.sergioo.workplaceCapacities2012.gui.ClustersPanel.java
@Override public void mouseClicked(MouseEvent e) { this.requestFocus(); double[] p = getWorld(e.getX(), e.getY()); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3) camera.centerCamera(p);/*from w ww. j a va 2 s . c o m*/ else { if (window.getOption().equals(Option.ZOOM) && e.getButton() == MouseEvent.BUTTON1) camera.zoomIn(p[0], p[1]); else if (window.getOption().equals(Option.ZOOM) && e.getButton() == MouseEvent.BUTTON3) camera.zoomOut(p[0], p[1]); } repaint(); }
From source file:org.nuclos.client.layout.wysiwyg.editor.ui.panels.WYSIWYGMetaInformationPicker.java
/** * /*from w ww . j a v a2s.c o m*/ * @param values * @param parent */ private WYSIWYGMetaInformationPicker(Window owner, List<String> values, TableLayoutPanel parent) { super(owner); this.setIconImage(NuclosIcons.getInstance().getScaledDialogIcon(48).getImage()); Container contentPane = this.getContentPane(); contentPane.setLayout(new TableLayout(layoutDefinition)); originalValues = values; filter = new JTextField(); /** the keybinding*/ filter.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { /** up and down cursor for selecting the next or previous entry */ if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { int selectedItem = itemList.getSelectedIndex(); if (e.getKeyCode() == KeyEvent.VK_UP) selectedItem--; else if (e.getKeyCode() == KeyEvent.VK_DOWN) selectedItem++; if (selectedItem < 0) { selectedItem = listModel.getSize() - 1; } else if (selectedItem == listModel.getSize()) { selectedItem = 0; } itemList.setSelectedIndex(selectedItem); itemList.ensureIndexIsVisible(selectedItem); } else if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_ESCAPE) { /** enter for saving, esc for cancel */ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) selectedEntity = null; dispose(); } else { /** every other key is used for filtering the entries */ filterItems(WYSIWYGMetaInformationPicker.this.filter.getText()); } } @Override public void keyTyped(KeyEvent e) { } }); /** request focus in the filter window */ filter.requestFocusInWindow(); this.add(filter, new TableLayoutConstraints(1, 1, 3, 1)); itemList = new JList(listModel); itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); itemList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (itemList.getSelectedValue() != null) selectedEntity = (String) itemList.getSelectedValue(); } }); freeExpr = new JCheckBox(SpringLocaleDelegate.getInstance() .getMessageFromResource("wysiwg.metainformation.picker.freeexpr")); this.add(freeExpr, new TableLayoutConstraints(1, 2, 3, 2)); freeExpr.setVisible(true); // double click on item to select itemList.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { performSaveAction(); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); filterItems(null); JScrollPane scrollpane = new JScrollPane(itemList); this.add(scrollpane, new TableLayoutConstraints(1, 4, 3, 4)); JButton apply = new JButton(BUTTON_LABELS.LABEL_APPLY); apply.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performSaveAction(); } }); this.add(apply, new TableLayoutConstraints(1, 6)); JButton cancel = new JButton(BUTTON_LABELS.LABEL_CANCEL); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { performCancelAction(); } }); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { performCancelAction(); } }); this.add(cancel, new TableLayoutConstraints(3, 6)); this.setBounds(this.getBounds().x, this.getBounds().y, 300, 400); this.setTitle(TABLELAYOUT_PANEL.SELECT_FIELD_FOR_METAINFORMATION); this.setModal(true); }
From source file:se.trixon.jota.client.ui.editor.JobsPanel.java
private void listMouseClicked(java.awt.event.MouseEvent evt) { if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { editButtonActionPerformed(null); }/*from w w w . j a v a 2s .co m*/ }
From source file:com.bwc.ora.views.LrpDisplayFrame.java
private LrpDisplayFrame() { //set up frame and chart //configure initial display setting for the panel chartPanel = new ChartPanel(null); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); this.setSize(800, 800); add(chartPanel, BorderLayout.CENTER); //make it so this jframe can't gain focus setFocusableWindowState(false);//from www . j av a 2s . c om //add listener to check to see which LRP should be displayed lrps.addListSelectionListener((ListSelectionEvent e) -> { if (!e.getValueIsAdjusting()) { if (lrps.getSelectedIndex() > -1) { setChart(lrps.getSelectedValue().getAllSeriesData()); setVisible(true); } else { setVisible(false); } } }); //add listener to check for updates to lrp selection to change lrp lrpSettings.addPropertyChangeListener(e -> { if (lrps.getSelectedIndex() > -1) { if (e.getPropertyName().equals(LrpSettings.PROP_LRP_WIDTH)) { Lrp newLrp; try { newLrp = new Lrp(Collections.getInstance().getLrpCollection().getSelectedValue().getName(), Collections.getInstance().getLrpCollection().getSelectedValue() .getLrpCenterXPosition(), Collections.getInstance().getLrpCollection().getSelectedValue() .getLrpCenterYPosition(), ModelsCollection.getInstance().getLrpSettings().getLrpWidth(), ModelsCollection.getInstance().getLrpSettings().getLrpHeight(), Collections.getInstance().getLrpCollection().getSelectedValue().getType()); } catch (LRPBoundaryViolationException e1) { JOptionPane.showMessageDialog(null, e1.getMessage() + " Try again.", "LRP generation error", JOptionPane.ERROR_MESSAGE); lrpSettings.setLrpWidth((int) e.getOldValue()); return; } Collections.getInstance().getLrpCollection().setLrp(newLrp, Collections.getInstance().getLrpCollection().getSelectedIndex()); } else { updateSeries(lrps.getSelectedValue().getAllSeriesData()); } } }); //add listener to check for updates to oct settings to change lrp octSettings.addPropertyChangeListener(e -> { if (lrps.getSelectedIndex() > -1) { switch (e.getPropertyName()) { case OctSettings.PROP_APPLY_CONTRAST_ADJUSTMENT: case OctSettings.PROP_APPLY_NOISE_REDUCTION: case OctSettings.PROP_DISPLAY_LOG_OCT: case OctSettings.PROP_SHARPEN_KERNEL_RADIUS: case OctSettings.PROP_SHARPEN_WEIGHT: case OctSettings.PROP_SMOOTHING_FACTOR: updateSeries(lrps.getSelectedValue().getAllSeriesData()); default: break; } } }); //add listener to see if the LRP display needs updating when a selection on oct changes lrps.addListDataChangeListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { } @Override public void intervalRemoved(ListDataEvent e) { } @Override public void contentsChanged(ListDataEvent e) { clearAnnotations(); updateSeries(lrps.getSelectedValue().getAllSeriesData()); } }); //add mouse listener for chart to detect when to display labels for //peaks in the pop-up menu, also specify what to do when label is clicked chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent cme) { ChartEntity entity = cme.getEntity(); if (entity instanceof XYItemEntity && cme.getTrigger().getButton() == MouseEvent.BUTTON1) { XYItemEntity item = (XYItemEntity) entity; LabelPopupMenu labelMenu = new LabelPopupMenu(chartPanel, item, lrps.getSelectedValue()); labelMenu.show(chartPanel, cme.getTrigger().getX(), cme.getTrigger().getY()); } } @Override public void chartMouseMoved(ChartMouseEvent cme) { //do nothing } }); }
From source file:de.tor.tribes.ui.panels.MinimapPanel.java
/** * Creates new form MinimapPanel/*from w w w. j a va 2 s . co m*/ */ MinimapPanel() { initComponents(); setSize(300, 300); mMinimapListeners = new LinkedList<>(); mToolChangeListeners = new LinkedList<>(); setCursor(ImageManager.getCursor(iCurrentCursor)); mScreenshotPanel = new ScreenshotPanel(); minimapButtons.put(ID_MINIMAP, new Rectangle(2, 2, 26, 26)); minimapButtons.put(ID_ALLY_CHART, new Rectangle(30, 2, 26, 26)); minimapButtons.put(ID_TRIBE_CHART, new Rectangle(60, 2, 26, 26)); try { minimapIcons.put(ID_MINIMAP, ImageIO.read(new File("./graphics/icons/minimap.png"))); minimapIcons.put(ID_ALLY_CHART, ImageIO.read(new File("./graphics/icons/ally_chart.png"))); minimapIcons.put(ID_TRIBE_CHART, ImageIO.read(new File("./graphics/icons/tribe_chart.png"))); } catch (Exception ignored) { } jPanel1.add(mScreenshotPanel); rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); zoomed = false; MarkerManager.getSingleton().addManagerListener(this); TagManager.getSingleton().addManagerListener(this); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); if (!GlobalOptions.isMinimal()) { MinimapRepaintThread.getSingleton().start(); } addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (!showControls && e.getButton() != MouseEvent.BUTTON1) { //show controls Point p = e.getPoint(); p.translate(-5, -5); showControls(p); return; } if (!showControls && iCurrentView == ID_MINIMAP) { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.getX(), p.getY()); MapPanel.getSingleton().getMapRenderer().initiateRedraw(MapRenderer.ALL_LAYERS); if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().toFront(); } } else { if (minimapButtons.get(ID_MINIMAP).contains(e.getPoint())) { iCurrentView = ID_MINIMAP; mBuffer = null; showControls = false; MinimapRepaintThread.getSingleton().update(); } else if (minimapButtons.get(ID_ALLY_CHART).contains(e.getPoint())) { iCurrentView = ID_ALLY_CHART; lastHash = 0; showControls = false; updateComplete(); } else if (minimapButtons.get(ID_TRIBE_CHART).contains(e.getPoint())) { iCurrentView = ID_TRIBE_CHART; lastHash = 0; showControls = false; updateComplete(); } } } @Override public void mousePressed(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT || iCurrentCursor == ImageManager.CURSOR_ZOOM) { iXDown = e.getX(); iYDown = e.getY(); } } @Override public void mouseReleased(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } if (rDrag == null) { return; } if (iCurrentCursor == ImageManager.CURSOR_SHOT) { try { BufferedImage i = MinimapRepaintThread.getSingleton().getImage(); double widthFactor = ((double) ServerSettings.getSingleton().getMapDimension().width) / getWidth(); double heightFactor = ((double) ServerSettings.getSingleton().getMapDimension().height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX()); int y = (int) Math.rint(heightFactor * rDrag.getY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); int h = (int) Math.rint(heightFactor * (rDrag.getHeight() - rDrag.getY())); BufferedImage sub = i.getSubimage(x, y, w, h); mScreenshotPanel.setBuffer(sub); jPanel1.setSize(mScreenshotPanel.getSize()); jPanel1.setPreferredSize(mScreenshotPanel.getSize()); jPanel1.setMinimumSize(mScreenshotPanel.getSize()); jPanel1.setMaximumSize(mScreenshotPanel.getSize()); jScreenshotPreview.pack(); jScreenshotControl.pack(); jScreenshotPreview.setVisible(true); jScreenshotControl.setVisible(true); } catch (Exception ie) { logger.error("Failed to initialize mapshot", ie); } } else if (iCurrentCursor == ImageManager.CURSOR_ZOOM) { if (!zoomed) { Rectangle mapDim = ServerSettings.getSingleton().getMapDimension(); double widthFactor = ((double) mapDim.width) / getWidth(); double heightFactor = ((double) mapDim.height) / getHeight(); int x = (int) Math.rint(widthFactor * rDrag.getX() + mapDim.getMinX()); int y = (int) Math.rint(heightFactor * rDrag.getY() + mapDim.getMinY()); int w = (int) Math.rint(widthFactor * (rDrag.getWidth() - rDrag.getX())); if (w >= 10) { rVisiblePart = new Rectangle(x, y, w, w); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = true; } } else { rVisiblePart = new Rectangle(ServerSettings.getSingleton().getMapDimension()); MinimapRepaintThread.getSingleton().setVisiblePart(rVisiblePart); redraw(); zoomed = false; } MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } @Override public void mouseEntered(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { MinimapZoomFrame.getSingleton().setVisible(true); } } } @Override public void mouseExited(MouseEvent e) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } iXDown = 0; iYDown = 0; rDrag = null; } }); addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { if (iCurrentView != ID_MINIMAP) { return; } switch (iCurrentCursor) { case ImageManager.CURSOR_MOVE: { Point p = mousePosToMapPosition(e.getX(), e.getY()); DSWorkbenchMainFrame.getSingleton().centerPosition(p.x, p.y); rDrag = null; break; } case ImageManager.CURSOR_SHOT: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } case ImageManager.CURSOR_ZOOM: { rDrag = new Rectangle2D.Double(iXDown, iYDown, e.getX(), e.getY()); break; } } } @Override public void mouseMoved(MouseEvent e) { if (iCurrentView == ID_MINIMAP) { switch (iCurrentCursor) { case ImageManager.CURSOR_ZOOM: { if (!MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(true); } int mapWidth = (int) ServerSettings.getSingleton().getMapDimension().getWidth(); int mapHeight = (int) ServerSettings.getSingleton().getMapDimension().getHeight(); int x = (int) Math.rint((double) mapWidth / (double) getWidth() * (double) e.getX()); int y = (int) Math.rint((double) mapHeight / (double) getHeight() * (double) e.getY()); MinimapZoomFrame.getSingleton().updatePosition(x, y); break; } default: { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } } } Point location = minimapButtons.get(ID_MINIMAP).getLocation(); location.translate(-2, -2); if (!new Rectangle(location.x, location.y, 88, 30).contains(e.getPoint())) { //hide controls showControls = false; repaint(); } } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (iCurrentView != ID_MINIMAP) { return; } iCurrentCursor += e.getWheelRotation(); if (iCurrentCursor == ImageManager.CURSOR_DEFAULT + e.getWheelRotation()) { if (e.getWheelRotation() < 0) { iCurrentCursor = ImageManager.CURSOR_SHOT; } else { iCurrentCursor = ImageManager.CURSOR_MOVE; } } else if (iCurrentCursor < ImageManager.CURSOR_MOVE) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } else if (iCurrentCursor > ImageManager.CURSOR_SHOT) { iCurrentCursor = ImageManager.CURSOR_DEFAULT; } if (iCurrentCursor != ImageManager.CURSOR_ZOOM) { if (MinimapZoomFrame.getSingleton().isVisible()) { MinimapZoomFrame.getSingleton().setVisible(false); } } else { MinimapZoomFrame.getSingleton().setVisible(true); } setCurrentCursor(iCurrentCursor); } }); }