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:de.jakop.ngcalsync.application.TrayStarter.java
private MouseAdapter createLogMouseListener(final JFrame logWindow) { return new MouseAdapter() { @Override/*w w w .j a v a 2 s . c om*/ public void mouseClicked(final MouseEvent e) { if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) { logWindow.setVisible(!logWindow.isVisible()); } } }; }
From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java
public void mouseReleased(MouseEvent e) { // Left mouse button only if (e.getButton() != MouseEvent.BUTTON1) return;//w w w . j av a2 s. com if (talkButtonPressed) { eventHandler.talkButtonReleased(Constants.DEVICE_MOUSE); talkButtonPressed = false; } }
From source file:net.sf.eclipsecs.ui.stats.views.GraphStatsView.java
/** * Creates the master view containing the chart. * //from w w w .jav a 2 s .co m * @param parent * the parent composite * @return the chart composite */ public Composite createMasterView(Composite parent) { // create the date set for the chart mPieDataset = new GraphPieDataset(); mPieDataset.setShowAllCategories(mShowAllCategoriesAction.isChecked()); mGraph = createChart(mPieDataset); // creates the chart component // Composite embeddedComposite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND); // embeddedComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); // experimental usage of JFreeChart SWT // the composite to harbor the Swing chart control ChartComposite embeddedComposite = new ChartComposite(parent, SWT.NONE, mGraph, true); embeddedComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); embeddedComposite.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(final ChartMouseEvent event) { MouseEvent trigger = event.getTrigger(); if (trigger.getButton() == MouseEvent.BUTTON1 && event.getEntity() instanceof PieSectionEntity) { // && trigger.getClickCount() == 2 //doubleclick not correctly detected with the SWT composite mMasterComposite.getDisplay().syncExec(new Runnable() { public void run() { mIsDrilledDown = true; mCurrentDetailCategory = (String) ((PieSectionEntity) event.getEntity()) .getSectionKey(); mStackLayout.topControl = mDetailViewer.getTable(); mMainSection.layout(); mDetailViewer.setInput(mDetailViewer.getInput()); updateActions(); updateLabel(); } }); } else { event.getTrigger().consume(); } } public void chartMouseMoved(ChartMouseEvent event) { // NOOP } }); return embeddedComposite; }
From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java
private void formMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMousePressed if (evt.getButton() == MouseEvent.BUTTON1) { oldX = evt.getX();//from w w w. ja va 2 s .c o m oldY = evt.getY(); if (!noObjects) { move = true; this.setCursor(new Cursor(Cursor.MOVE_CURSOR)); } } }
From source file:org.ujmp.jung.JungVisualizationViewer.java
public final void mouseClicked(MouseEvent e) { switch (e.getButton()) { case MouseEvent.BUTTON1: break;//from w w w.j ava 2s.c om case MouseEvent.BUTTON2: break; case MouseEvent.BUTTON3: JPopupMenu popup = null; popup = new JungGraphActions(this); popup.show(e.getComponent(), e.getX(), e.getY()); break; } }
From source file:org.kontalk.view.View.java
final void setTray() { if (!Config.getInstance().getBoolean(Config.MAIN_TRAY)) { this.removeTray(); return;//from ww w. j a v a2s . c o m } if (!SystemTray.isSupported()) { LOGGER.info("tray icon not supported"); return; } if (mTrayIcon != null) // already set return; // load image Image image = getImage("kontalk.png"); //image = image.getScaledInstance(22, 22, Image.SCALE_SMOOTH); // popup menu outside of frame, officially not supported final WebPopupMenu popup = new WebPopupMenu("Kontalk"); WebMenuItem quitItem = new WebMenuItem(Tr.tr("Quit")); quitItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { View.this.callShutDown(); } }); popup.add(quitItem); // workaround: menu does not disappear when focus is lost final WebDialog hiddenDialog = new WebDialog(); hiddenDialog.setUndecorated(true); // create an action listener to listen for default action executed on the tray icon MouseListener listener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { // menu must be shown on mouse release //check(e); } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) mMainFrame.toggleState(); else check(e); } private void check(MouseEvent e) { // if (!e.isPopupTrigger()) // return; hiddenDialog.setVisible(true); // TODO ugly code popup.setLocation(e.getX() - 20, e.getY() - 40); popup.setInvoker(hiddenDialog); popup.setCornerWidth(0); popup.setVisible(true); } }; mTrayIcon = new TrayIcon(image, "Kontalk" /*, popup*/); mTrayIcon.setImageAutoSize(true); mTrayIcon.addMouseListener(listener); SystemTray tray = SystemTray.getSystemTray(); try { tray.add(mTrayIcon); } catch (AWTException ex) { LOGGER.log(Level.WARNING, "can't add tray icon", ex); } }
From source file:org.exist.launcher.Launcher.java
private boolean initSystemTray() { final Dimension iconDim = tray.getTrayIconSize(); BufferedImage image = null;//w w w. jav a 2s . c o m try { image = ImageIO.read(getClass().getResource("icon32.png")); } catch (final IOException e) { showMessageAndExit("Launcher failed", "Failed to read system tray icon.", false); } trayIcon = new TrayIcon(image.getScaledInstance(iconDim.width, iconDim.height, Image.SCALE_SMOOTH), "eXist-db Launcher"); final JDialog hiddenFrame = new JDialog(); hiddenFrame.setUndecorated(true); hiddenFrame.setIconImage(image); final PopupMenu popup = createMenu(); trayIcon.setPopupMenu(popup); trayIcon.addActionListener(actionEvent -> { trayIcon.displayMessage(null, "Right click for menu", TrayIcon.MessageType.INFO); setServiceState(); }); // add listener for left click on system tray icon. doesn't work well on linux though. if (!SystemUtils.IS_OS_LINUX) { trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON1) { setServiceState(); hiddenFrame.add(popup); popup.show(hiddenFrame, mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen()); } } }); } try { hiddenFrame.setResizable(false); hiddenFrame.pack(); hiddenFrame.setVisible(true); tray.add(trayIcon); } catch (final AWTException e) { return false; } return true; }
From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java
private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased if (evt.getButton() == MouseEvent.BUTTON1) { move = false;/* w w w .j a va 2 s .c o m*/ this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } }
From source file:org.omegat.gui.issues.IssuesPanelController.java
@SuppressWarnings("serial") synchronized void init() { if (frame != null) { // Regenerate menu bar to reflect current prefs frame.setJMenuBar(generateMenuBar()); return;/*from w w w.ja v a 2 s . c o m*/ } frame = new JFrame(OStrings.getString("ISSUES_WINDOW_TITLE")); StaticUIUtils.setEscapeClosable(frame); StaticUIUtils.setWindowIcon(frame); if (Platform.isMacOSX()) { OSXIntegration.enableFullScreen(frame); } panel = new IssuesPanel(); frame.add(panel); frame.setJMenuBar(generateMenuBar()); frame.setPreferredSize(new Dimension(600, 400)); frame.pack(); frame.setLocationRelativeTo(parent); panel.innerSplitPane.setDividerLocation(INNER_SPLIT_INITIAL_RATIO); panel.outerSplitPane.setDividerLocation(OUTER_SPLIT_INITIAL_RATIO); StaticUIUtils.persistGeometry(frame, Preferences.ISSUES_WINDOW_GEOMETRY_PREFIX, () -> { Preferences.setPreference(Preferences.ISSUES_WINDOW_DIVIDER_LOCATION_BOTTOM, panel.outerSplitPane.getDividerLocation()); }); try { int bottomDL = Integer .parseInt(Preferences.getPreference(Preferences.ISSUES_WINDOW_DIVIDER_LOCATION_BOTTOM)); panel.outerSplitPane.setDividerLocation(bottomDL); } catch (NumberFormatException e) { // Ignore } frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { reset(); } }); if (Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) { String fontName = Preferences.getPreference(Preferences.TF_SRC_FONT_NAME); int fontSize = Integer.parseInt(Preferences.getPreference(Preferences.TF_SRC_FONT_SIZE)); setFont(new Font(fontName, Font.PLAIN, fontSize)); } panel.table.getSelectionModel().addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { viewSelectedIssueDetail(); selectedEntry = getSelectedIssue().map(IIssue::getSegmentNumber).orElse(-1); } }); panel.table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ACTION_KEY_JUMP_TO_SELECTED_ISSUE); panel.table.getActionMap().put(ACTION_KEY_JUMP_TO_SELECTED_ISSUE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { jumpToSelectedIssue(); } }); // Swap focus between the Types list and Issues table; don't allow // tabbing within the table because it's pointless. Maybe this would be // better accomplished by adjusting the focus traversal policy? panel.table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK), ACTION_KEY_FOCUS_ON_TYPES_LIST); panel.table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), ACTION_KEY_FOCUS_ON_TYPES_LIST); panel.table.getActionMap().put(ACTION_KEY_FOCUS_ON_TYPES_LIST, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (panel.typeList.isVisible()) { panel.typeList.requestFocusInWindow(); } } }); panel.closeButton.addActionListener(e -> StaticUIUtils.closeWindowByEvent(frame)); MouseAdapter adapter = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { jumpToSelectedIssue(); } else if (e.getButton() == MouseEvent.BUTTON1 && mouseoverCol == IssueColumn.ACTION_BUTTON.index) { doPopup(e); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { doPopup(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { doPopup(e); } } @Override public void mouseExited(MouseEvent e) { updateRollover(); } @Override public void mouseMoved(MouseEvent e) { updateRollover(); } private void doPopup(MouseEvent e) { getIssueAt(e.getPoint()).ifPresent(issue -> showPopupMenu(e.getComponent(), e.getPoint(), issue)); } }; panel.table.addMouseListener(adapter); panel.table.addMouseMotionListener(adapter); panel.typeList.addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { updateFilter(); selectedType = getSelectedType().orElse(null); } }); panel.jumpButton.addActionListener(e -> jumpToSelectedIssue()); panel.reloadButton.addActionListener(e -> refreshData(selectedEntry, selectedType)); panel.showAllButton.addActionListener(e -> showAll()); colSizer = TableColumnSizer.autoSize(panel.table, IssueColumn.DESCRIPTION.index, true); CoreEvents.registerProjectChangeListener(e -> { switch (e) { case CLOSE: SwingUtilities.invokeLater(() -> { filePattern = ALL_FILES_PATTERN; instructions = NO_INSTRUCTIONS; reset(); frame.setVisible(false); }); break; case MODIFIED: if (frame.isVisible()) { SwingUtilities.invokeLater(() -> refreshData(selectedEntry, selectedType)); } break; default: } }); CoreEvents.registerFontChangedEventListener(f -> { if (!Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) { f = new JTable().getFont(); } setFont(f); viewSelectedIssueDetail(); }); }
From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java
private void init() { setLayout(new BorderLayout()); contentPanel = new TierDataLayoutPanel(); dateField = createDateField();//from w w w.j a v a 2 s. c o m dateField.getTextField().setColumns(10); dateField.setBackground(Color.white); mediaLocationField = new MediaSelectionField(getEditor().getProject()); mediaLocationField.setEditor(getEditor()); mediaLocationField.getTextField().setColumns(10); mediaLocationField.addPropertyChangeListener(FileSelectionField.FILE_PROP, mediaLocationListener); participantTable = new JXTable(); participantTable.setVisibleRowCount(3); ComponentInputMap participantTableInputMap = new ComponentInputMap(participantTable); ActionMap participantTableActionMap = new ActionMap(); ImageIcon deleteIcon = IconManager.getInstance().getIcon("actions/delete_user", IconSize.SMALL); final PhonUIAction deleteAction = new PhonUIAction(this, "deleteParticipant"); deleteAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Delete selected participant"); deleteAction.putValue(PhonUIAction.SMALL_ICON, deleteIcon); participantTableActionMap.put("DELETE_PARTICIPANT", deleteAction); participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT"); participantTableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT"); removeParticipantButton = new JButton(deleteAction); participantTable.setInputMap(WHEN_FOCUSED, participantTableInputMap); participantTable.setActionMap(participantTableActionMap); addParticipantButton = new JButton(new NewParticipantAction(getEditor(), this)); addParticipantButton.setFocusable(false); ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit_user", IconSize.SMALL); final PhonUIAction editParticipantAct = new PhonUIAction(this, "editParticipant"); editParticipantAct.putValue(PhonUIAction.NAME, "Edit participant..."); editParticipantAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit selected participant..."); editParticipantAct.putValue(PhonUIAction.SMALL_ICON, editIcon); editParticipantButton = new JButton(editParticipantAct); editParticipantButton.setFocusable(false); final CellConstraints cc = new CellConstraints(); FormLayout participantLayout = new FormLayout("fill:pref:grow, pref, pref, pref", "pref, pref, pref:grow"); JPanel participantPanel = new JPanel(participantLayout); participantPanel.setBackground(Color.white); participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 2, 3, 2)); participantPanel.add(addParticipantButton, cc.xy(2, 1)); participantPanel.add(editParticipantButton, cc.xy(3, 1)); participantPanel.add(removeParticipantButton, cc.xy(4, 2)); participantTable.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent arg0) { if (arg0.getClickCount() == 2 && arg0.getButton() == MouseEvent.BUTTON1) { editParticipantAct.actionPerformed(new ActionEvent(arg0.getSource(), arg0.getID(), "edit")); } } }); languageField = new LanguageField(); languageField.getDocument().addDocumentListener(languageFieldListener); int rowIdx = 0; final JLabel dateLbl = new JLabel("Session Date"); dateLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(dateLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(dateField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel mediaLbl = new JLabel("Media"); mediaLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(mediaLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(mediaLocationField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel partLbl = new JLabel("Participants"); partLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(partLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(participantPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); final JLabel langLbl = new JLabel("Language"); langLbl.setHorizontalAlignment(SwingConstants.RIGHT); contentPanel.add(langLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, rowIdx)); contentPanel.add(languageField, new TierDataConstraint(TierDataConstraint.FLAT_TIER_COLUMN, rowIdx++)); add(new JScrollPane(contentPanel), BorderLayout.CENTER); update(); }