List of usage examples for java.awt.event MouseEvent getSource
public Object getSource()
From source file:de.tor.tribes.ui.components.TimePicker.java
private void initSpecialComponents() { for (int i = 0; i < hourLabels.length; i++) { CrossedLabel label = new CrossedLabel(); hourLabels[i] = label;/*from www . j a v a2 s .c o m*/ if (i < 10) { label.setText("0" + Integer.toString(i)); } else { label.setText(Integer.toString(i)); } label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setBorder(javax.swing.BorderFactory.createLineBorder(Constants.DS_BACK)); label.setHorizontalAlignment(SwingConstants.CENTER); label.setOpaque(true); label.setBackground(Constants.DS_BACK_LIGHT); label.setFont(smallFont); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (selectedHour != null) { selectedHour.uncross(); } selectedHour = ((CrossedLabel) e.getSource()); selectedHour.cross(); for (int i = 0; i < hourLabels.length; i++) if (hourLabels[i] == selectedHour) { pHour = i; break; } } @Override public void mouseEntered(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(highlight); } @Override public void mouseExited(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(Constants.DS_BACK_LIGHT); } }); } addHourLabels(); for (int i = 0; i < minuteLabels.length; i++) { CrossedLabel label = new CrossedLabel(); minuteLabels[i] = label; if (i < 10) { label.setText(":0" + Integer.toString(i)); } else { label.setText(":" + Integer.toString(i)); } label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204))); label.setHorizontalAlignment(SwingConstants.CENTER); label.setOpaque(true); label.setBackground(Color.WHITE); label.setFont(smallFont); label.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (selectedMinute != null) { selectedMinute.uncross(); } selectedMinute = ((CrossedLabel) e.getSource()); selectedMinute.cross(); for (int i = 0; i < minuteLabels.length; i++) if (minuteLabels[i] == selectedMinute) { pMinute = i; break; } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(highlight); } @Override public void mouseExited(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(Color.WHITE); } }); } addMinuteLabels(false); }
From source file:org.adempiere.apps.graph.PerformanceIndicator.java
/** * Init Graph Display// ww w .j a v a 2 s . c o m * Kinamo (pelgrim) */ private void init() { chartPanel = new ChartPanel(createChart(), //chart false, //boolean properties false, // boolean save false, //boolean print false, //boolean zoom true //boolean tooltips ); chartPanel.setPreferredSize(indicatordimension); chartPanel.addChartMouseListener(new org.jfree.chart.ChartMouseListener() { public void chartMouseClicked(org.jfree.chart.ChartMouseEvent e) { //plot p = (MeterPlot) e.getSource(); MouseEvent me = e.getTrigger(); if (SwingUtilities.isLeftMouseButton(me) && me.getClickCount() > 1) fireActionPerformed(me); if (SwingUtilities.isRightMouseButton(me)) popupMenu.show((Component) me.getSource(), me.getX(), me.getY()); } public void chartMouseMoved(org.jfree.chart.ChartMouseEvent e) { } }); this.add(chartPanel, BorderLayout.NORTH); this.setMinimumSize(paneldimension); this.setMaximumSize(paneldimension); //--------------------------------------------- invalidate(); }
From source file:labr_client.GUI.forms.EhealthSearch.java
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked // TODO add your handling code here: if (evt.getClickCount() == 2) { JTable target = (JTable) evt.getSource(); String id = (String) target.getValueAt(target.getSelectedRow(), 2); // setInfo(); }/*www.jav a2s . c om*/ }
From source file:views.online.Panel_RejoindrePartieMulti.java
@Override public void mouseClicked(MouseEvent e) { Object src = e.getSource(); if (src == tfFiltre) { if (tfFiltre.getText().equals(FILTRE_DEFAUT)) tfFiltre.setText(""); } else if (src == tfConnexionParIP) { tbServeurs.clearSelection();/*from w w w.j a va2s .c o m*/ } }
From source file:gtu._work.ui.JarFinderUI.java
private void jList1MouseClicked(MouseEvent evt) { if (evt.getClickCount() != 2) { return;//from w ww . jav a 2 s.c o m } try { JList list = (JList) evt.getSource(); StringBuilder sb = new StringBuilder("''jar\r\n'?'\r\n"); String fileName = (String) list.getSelectedValue(); ClipboardUtil.getInstance().setContents(fileName); int linecount = 0; for (String clz : jarfinder.getMap().get(fileName)) { if (linecount == 10) { sb.append("...?"); break; } sb.append(clz + "\r\n"); linecount++; } ComfirmDialogResult result = JOptionPaneUtil.newInstance().iconInformationMessage() .confirmButtonYesNoCancel().showConfirmDialog(sb, fileName); String jdGuiExe = StringUtils.trimToEmpty(jdGuiText.getText()); if (result == ComfirmDialogResult.YES_OK_OPTION) { if (OsInfoUtil.isWindows()) { RuntimeBatPromptModeUtil.newInstance() .command(String.format("cmd /c call \"%s\" \"%s\"", jdGuiExe, fileName)).apply(); } else { RuntimeBatPromptModeUtil.newInstance() .command(String.format("java -jar \"%s\" \"%s\"", jdGuiExe, fileName)).apply(); } } if (result == ComfirmDialogResult.NO_OPTION) { DesktopUtil.openDir(new File(fileName).getParentFile()); } } catch (Exception ex) { ex.printStackTrace(); // JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(ex.getMessage(), // "error"); JCommonUtil.handleException(ex); } }
From source file:es.emergya.ui.gis.ControlPanel.java
public ControlPanel(final CustomMapView view) { super(new FlowLayout(FlowLayout.LEADING, 12, 0)); this.view = view; // Posicion: panel con un label de icono y un textfield JPanel posPanel = new JPanel(); posPanel.setOpaque(true);/*w w w .j a v a 2 s . c om*/ posPanel.setVisible(true); JLabel mouseLocIcon = new JLabel(LogicConstants.getIcon("map_icon_coordenadas")); posPanel.add(mouseLocIcon); final JTextField posField = new JTextField(15); posField.setEditable(false); posField.setBorder(null); posField.setForeground(UIManager.getColor("Label.foreground")); posField.setFont(UIManager.getFont("Label.font")); posPanel.add(posField); view.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(), e.getY()); String position = ""; String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA", "UTM"); if (format.equals(LogicConstants.COORD_UTM)) { UTM u = new UTM(LogicConstants.getInt("ZONA_UTM")); EastNorth en = u.latlon2eastNorth(ll); position = String.format("x: %.1f y: %.1f", en.getX(), en.getY()); } else { position = String.format("Lat: %.4f Lon: %.4f", ll.lat(), ll.lon()); } posField.setText(position); validate(); } @Override public void mouseDragged(MouseEvent e) { } }); posPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(posPanel); // Panel de centrado: label, desplegable y parte cambiante JPanel centerPanel = new JPanel(); centerPanel.add(new JLabel(i18n.getString("map.centerIn"))); centerOptions = new JComboBox(new String[] { i18n.getString("map.street"), i18n.getString("map.resource"), i18n.getString("map.incidence"), i18n.getString("map.location") }); centerPanel.add(centerOptions); centerData = new JPanel(new CardLayout()); centerPanel.add(centerData); JPanel centerStreet = new JPanel(); street = new JTextField(30); street.setName(i18n.getString("map.street")); autocompleteKeyListener = new AutocompleteKeyListener(street); street.addKeyListener(autocompleteKeyListener); street.addActionListener(this); centerStreet.add(street); centerData.add(centerStreet, i18n.getString("map.street")); JPanel centerResource = new JPanel(); resources = new JComboBox(avaliableResources); resources.setName(i18n.getString("map.resource")); resources.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); resources.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { isComboResourcesShowing = true; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { isComboResourcesShowing = false; } @Override public void popupMenuCanceled(PopupMenuEvent e) { // view.repaint(); } }); centerResource.add(resources); centerData.add(centerResource, i18n.getString("map.resource")); centerResource = new JPanel(); incidences = new JComboBox(avaliableIncidences); incidences.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); incidences.setName(i18n.getString("map.incidence")); incidences.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { isComboIncidencesShowing = true; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { isComboIncidencesShowing = false; } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); centerResource.add(incidences); centerData.add(centerResource, i18n.getString("map.incidence")); JPanel centerLocation = new JPanel(); cx = new JTextField(10); cx.setName("x"); cx.addActionListener(this); centerLocation.add(cx); cy = new JTextField(10); cy.setName("y"); cy.addActionListener(this); centerLocation.add(cy); centerData.add(centerLocation, i18n.getString("map.location")); centerOptions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { ((CardLayout) centerData.getLayout()).show(centerData, (String) e.getItem()); } }); JButton centerButton = new JButton(i18n.getString("map.center")); centerButton.addActionListener(this); centerPanel.add(centerButton); add(centerPanel); }
From source file:com.net2plan.gui.utils.topologyPane.jung.JUNGCanvas.java
@Override public GUILink getEdge(MouseEvent e) { final VisualizationViewer<GUINode, GUILink> vv = (VisualizationViewer<GUINode, GUILink>) e.getSource(); GraphElementAccessor<GUINode, GUILink> pickSupport = vv.getPickSupport(); if (pickSupport != null) { final Point p = e.getPoint(); return pickSupport.getEdge(vv.getModel().getGraphLayout(), p.getX(), p.getY()); }/*from ww w. j a v a 2 s. c o m*/ return null; }
From source file:com.net2plan.gui.utils.topologyPane.jung.JUNGCanvas.java
@Override public GUINode getVertex(MouseEvent e) { final VisualizationViewer<GUINode, GUILink> vv = (VisualizationViewer<GUINode, GUILink>) e.getSource(); GraphElementAccessor<GUINode, GUILink> pickSupport = vv.getPickSupport(); if (pickSupport != null) { final Point p = e.getPoint(); final GUINode vertex = pickSupport.getVertex(vv.getModel().getGraphLayout(), p.getX(), p.getY()); if (vertex != null) return vertex; }//from www . j a v a2 s .c om return null; }
From source file:org.esa.nest.dat.views.polarview.PolarView.java
/** * Handle mouse clicked event//from ww w . ja v a 2 s .c o m * * @param e the mouse event */ public void mouseClicked(MouseEvent e) { checkPopup(e); final Object src = e.getSource(); final PolarCanvas polarCanvas = polarPanel.getPolarCanvas(); if (src == polarCanvas) { final Axis axis = polarCanvas.selectAxis(e.getPoint()); if (axis != null && axis == polarCanvas.getColourAxis()) { callColourScaleDlg(); } } }
From source file:net.sf.firemox.Magic.java
public void mouseClicked(MouseEvent e) { Object obj = e.getSource(); if (obj == skipButton) { /**//from w ww . j a v a 2 s .c o m * invoked by a click directly on the "skip/cancel" of the label". * * @param evt * mouse event * @see MEventManager#raiseEvent(int,boolean) * @see MEventManager#getNextStop() * @see MPhase#breakpoint * @see MPhase#skipAll * @see Magic#manuaSkip() */ // only if enabled and left mouse button pressed StackManager.noReplayToken.take(); try { if (ConnectionManager.isConnected() && skipButton.isEnabled() && e.getButton() == MouseEvent.BUTTON1) { manualSkip(); } } catch (Throwable t) { t.printStackTrace(); } finally { StackManager.noReplayToken.release(); } } }