List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:ImageSorter.java
/** * @param in/* w w w.j a v a2 s . co m*/ * @param leftOut * @param rightOut */ public ImageSorter(String in, String leftOut, String rightOut) { super("ImageSorter"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); inputs = new File(in).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { String s = name.toLowerCase(); return s.endsWith("jpg"); } }); leftOutput = new File(in, leftOut); rightOutput = new File(in, rightOut); leftOutput.mkdirs(); rightOutput.mkdirs(); assert leftOutput.canWrite(); assert rightOutput.canWrite(); panel.setPreferredSize(new Dimension(640, 480)); getContentPane().setLayout(new BorderLayout()); getContentPane().add(panel, BorderLayout.CENTER); panel.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { inputs[index].renameTo(new File(rightOutput, inputs[index].getName())); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { inputs[index].renameTo(new File(leftOutput, inputs[index].getName())); } nextImage(); } }); panel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mousePressed(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mouseEntered(MouseEvent e) { panel.requestFocusInWindow(); } @Override public void mouseClicked(MouseEvent e) { panel.requestFocusInWindow(); } }); panel.requestFocusInWindow(); nextImage(); pack(); setVisible(true); }
From source file:aurelienribon.gdxsetupui.ui.panels.ConfigUpdatePanel.java
public ConfigUpdatePanel(final MainPanel mainPanel) { initComponents();//from w w w. j av a 2 s . c o m browseBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browse(); } }); advancedSettingsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); advancedSettingsLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (clicToShowSettings && mainPanel.showAdvancedSettings()) { clicToShowSettings = false; advancedSettingsLabel.setText("< Hide advanced settings"); } else if (mainPanel.hideAdvancedSettings()) { clicToShowSettings = true; advancedSettingsLabel.setText("Show advanced settings >"); } } }); Style.registerCssClasses(headerPanel, ".header"); Style.registerCssClasses(numberLabel, ".headerNumber"); Style.registerCssClasses(advancedSettingsLabel, ".linkLabel"); Style.registerCssClasses(statusCoreLabel, ".statusLabel"); Style.registerCssClasses(statusAndroidLabel, ".statusLabel"); Style.registerCssClasses(statusDesktopLabel, ".statusLabel"); Style.registerCssClasses(statusHtmlLabel, ".statusLabel"); Style.registerCssClasses(browseBtn, ".center"); Ctx.listeners.add(new Ctx.Listener() { @Override public void cfgUpdateChanged() { updateClasspaths(); } }); }
From source file:com.litt.core.security.license.gui.ValidatePanel.java
/** * Create the panel./*from www . ja v a2 s .c om*/ */ public ValidatePanel() { GridBagLayout gbl_validatePanel = new GridBagLayout(); gbl_validatePanel.columnWidths = new int[] { 0, 0, 0 }; gbl_validatePanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_validatePanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_validatePanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; this.setLayout(gbl_validatePanel); JLabel label_10 = new JLabel(""); GridBagConstraints gbc_label_10 = new GridBagConstraints(); gbc_label_10.insets = new Insets(0, 0, 5, 5); gbc_label_10.anchor = GridBagConstraints.EAST; gbc_label_10.gridx = 0; gbc_label_10.gridy = 0; this.add(label_10, gbc_label_10); field_pubKeyFilePath = new JTextField(); field_pubKeyFilePath.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JFileChooser fileChooser = new JFileChooser(); //fileChooser.setVisible(true); LicenseFileFilter fileFilter = new LicenseFileFilter(new String[] { "key" }); fileChooser.setFileFilter(fileFilter); fileChooser.addChoosableFileFilter(fileFilter); fileChooser.showOpenDialog(e.getComponent()); File pubKeyFile = fileChooser.getSelectedFile(); field_pubKeyFilePath.setText(pubKeyFile.getAbsolutePath()); } }); GridBagConstraints gbc_field_pubKeyFilePath = new GridBagConstraints(); gbc_field_pubKeyFilePath.insets = new Insets(0, 0, 5, 0); gbc_field_pubKeyFilePath.fill = GridBagConstraints.HORIZONTAL; gbc_field_pubKeyFilePath.gridx = 1; gbc_field_pubKeyFilePath.gridy = 0; this.add(field_pubKeyFilePath, gbc_field_pubKeyFilePath); field_pubKeyFilePath.setColumns(10); JLabel label_19 = new JLabel("?"); GridBagConstraints gbc_label_19 = new GridBagConstraints(); gbc_label_19.anchor = GridBagConstraints.EAST; gbc_label_19.insets = new Insets(0, 0, 5, 5); gbc_label_19.gridx = 0; gbc_label_19.gridy = 1; this.add(label_19, gbc_label_19); field_licenseFilePath = new JTextField(); field_licenseFilePath.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JFileChooser fileChooser = new JFileChooser(); //fileChooser.setVisible(true); LicenseFileFilter fileFilter = new LicenseFileFilter(new String[] { "xml" }); fileChooser.setFileFilter(fileFilter); fileChooser.addChoosableFileFilter(fileFilter); fileChooser.showOpenDialog(e.getComponent()); File licenseFile = fileChooser.getSelectedFile(); field_licenseFilePath.setText(licenseFile.getAbsolutePath()); } }); GridBagConstraints gbc_textField1 = new GridBagConstraints(); gbc_textField1.insets = new Insets(0, 0, 5, 0); gbc_textField1.fill = GridBagConstraints.HORIZONTAL; gbc_textField1.gridx = 1; gbc_textField1.gridy = 1; this.add(field_licenseFilePath, gbc_textField1); field_licenseFilePath.setColumns(10); JLabel lblid = new JLabel("?ID"); lblid.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblid = new GridBagConstraints(); gbc_lblid.insets = new Insets(0, 0, 5, 5); gbc_lblid.gridx = 0; gbc_lblid.gridy = 2; this.add(lblid, gbc_lblid); label_licenseId = new JLabel(""); label_licenseId.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_label_licenseId = new GridBagConstraints(); gbc_label_licenseId.insets = new Insets(0, 0, 5, 0); gbc_label_licenseId.gridx = 1; gbc_label_licenseId.gridy = 2; this.add(label_licenseId, gbc_label_licenseId); JLabel label_12 = new JLabel("?"); GridBagConstraints gbc_label_12 = new GridBagConstraints(); gbc_label_12.insets = new Insets(0, 0, 5, 5); gbc_label_12.gridx = 0; gbc_label_12.gridy = 3; this.add(label_12, gbc_label_12); label_licenseType = new JLabel(""); GridBagConstraints gbc_label_licenseType = new GridBagConstraints(); gbc_label_licenseType.insets = new Insets(0, 0, 5, 0); gbc_label_licenseType.gridx = 1; gbc_label_licenseType.gridy = 3; this.add(label_licenseType, gbc_label_licenseType); JLabel label_13 = new JLabel("???"); GridBagConstraints gbc_label_13 = new GridBagConstraints(); gbc_label_13.insets = new Insets(0, 0, 5, 5); gbc_label_13.gridx = 0; gbc_label_13.gridy = 4; this.add(label_13, gbc_label_13); label_productName = new JLabel(""); GridBagConstraints gbc_label_productName = new GridBagConstraints(); gbc_label_productName.insets = new Insets(0, 0, 5, 0); gbc_label_productName.gridx = 1; gbc_label_productName.gridy = 4; this.add(label_productName, gbc_label_productName); JLabel label_14 = new JLabel("???"); GridBagConstraints gbc_label_14 = new GridBagConstraints(); gbc_label_14.insets = new Insets(0, 0, 5, 5); gbc_label_14.gridx = 0; gbc_label_14.gridy = 5; this.add(label_14, gbc_label_14); label_companyName = new JLabel(""); GridBagConstraints gbc_label_companyName = new GridBagConstraints(); gbc_label_companyName.insets = new Insets(0, 0, 5, 0); gbc_label_companyName.gridx = 1; gbc_label_companyName.gridy = 5; this.add(label_companyName, gbc_label_companyName); JLabel label_15 = new JLabel("??"); GridBagConstraints gbc_label_15 = new GridBagConstraints(); gbc_label_15.insets = new Insets(0, 0, 5, 5); gbc_label_15.gridx = 0; gbc_label_15.gridy = 6; this.add(label_15, gbc_label_15); label_customerName = new JLabel(""); GridBagConstraints gbc_label_customerName = new GridBagConstraints(); gbc_label_customerName.insets = new Insets(0, 0, 5, 0); gbc_label_customerName.gridx = 1; gbc_label_customerName.gridy = 6; this.add(label_customerName, gbc_label_customerName); JLabel label_16 = new JLabel(""); GridBagConstraints gbc_label_16 = new GridBagConstraints(); gbc_label_16.insets = new Insets(0, 0, 5, 5); gbc_label_16.gridx = 0; gbc_label_16.gridy = 7; this.add(label_16, gbc_label_16); label_version = new JLabel(""); GridBagConstraints gbc_label_version = new GridBagConstraints(); gbc_label_version.insets = new Insets(0, 0, 5, 0); gbc_label_version.gridx = 1; gbc_label_version.gridy = 7; this.add(label_version, gbc_label_version); JLabel label_11 = new JLabel(""); GridBagConstraints gbc_label_11 = new GridBagConstraints(); gbc_label_11.insets = new Insets(0, 0, 5, 5); gbc_label_11.gridx = 0; gbc_label_11.gridy = 8; this.add(label_11, gbc_label_11); label_createDate = new JLabel(""); GridBagConstraints gbc_label_createDate = new GridBagConstraints(); gbc_label_createDate.insets = new Insets(0, 0, 5, 0); gbc_label_createDate.gridx = 1; gbc_label_createDate.gridy = 8; this.add(label_createDate, gbc_label_createDate); JLabel label_17 = new JLabel(""); GridBagConstraints gbc_label_17 = new GridBagConstraints(); gbc_label_17.insets = new Insets(0, 0, 5, 5); gbc_label_17.gridx = 0; gbc_label_17.gridy = 9; this.add(label_17, gbc_label_17); label_expiredDate = new JLabel(""); GridBagConstraints gbc_label_expiredDate = new GridBagConstraints(); gbc_label_expiredDate.insets = new Insets(0, 0, 5, 0); gbc_label_expiredDate.gridx = 1; gbc_label_expiredDate.gridy = 9; this.add(label_expiredDate, gbc_label_expiredDate); JButton button_2 = new JButton(""); button_2.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { String licenseFilePath = Utility.trimNull(field_licenseFilePath.getText()); String pubKeyFilePath = Utility.trimNull(field_pubKeyFilePath.getText()); if (Utility.isEmpty(licenseFilePath)) { JOptionPane.showMessageDialog(e.getComponent(), "?!"); return; } if (Utility.isEmpty(pubKeyFilePath)) { JOptionPane.showMessageDialog(e.getComponent(), "!"); return; } File licenseFile = new File(licenseFilePath); try { XMLConfiguration config = new XMLConfiguration(licenseFile); config.setAutoSave(true); label_licenseId.setText(config.getString(("licenseId"))); label_licenseType.setText(config.getString("licenseType")); label_productName.setText(config.getString("productName")); label_companyName.setText(config.getString("companyName")); label_customerName.setText(config.getString("customerName")); label_version.setText(config.getString("version")); label_createDate.setText(config.getString("createDate")); label_expiredDate.setText(config.getString("expiredDate")); } catch (Exception e1) { // TODO Auto-generated catch block JOptionPane.showMessageDialog(e.getComponent(), e1.getMessage()); } try { LicenseManager.validateLicense(licenseFile.getAbsolutePath(), pubKeyFilePath); JOptionPane.showMessageDialog(e.getComponent(), "?"); } catch (LicenseException e1) { // TODO Auto-generated catch block JOptionPane.showMessageDialog(e.getComponent(), e1.getMessage()); } } }); GridBagConstraints gbc_button_2 = new GridBagConstraints(); gbc_button_2.gridx = 1; gbc_button_2.gridy = 10; this.add(button_2, gbc_button_2); }
From source file:fxts.stations.trader.ui.frames.ChildFrame.java
/** * Constructor.//w w w . j a va 2s . c o m * * @param aName name of frame * @param aMainFrame main frame */ public ChildFrame(String aName, IMainFrame aMainFrame) { super(aName, true, //resizable true, //closable true); //maximizable setMainFrame(aMainFrame); //sets reaction on closings setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); //adds listener addInternalFrameListener(new InternalFrameAdapter() { //overriden public void internalFrameClosing(InternalFrameEvent aEvent) { //unselects associated menu item setMenuItemState(false); ChildFrame.this.setVisible(false); //checking for existing of visible frames mMainFrame.checkForVisibleChilds(); } }); //sets name of the frame setName(aName); //adds mouse listener addMouseListener(new MouseAdapter() { /** * Invoked when a mouse button has been pressed on a component. */ public void mousePressed(MouseEvent aEvent) { if (!ChildFrame.this.isSelected()) { try { ChildFrame.this.setSelected(true); } catch (Exception e) { e.printStackTrace(); } } } }); }
From source file:androhashcheck.MainFrame.java
/** * Creates new form MainFrame//from w w w. j a v a 2s. c o m * @param logInFrame */ public MainFrame(JFrame logInFrame) { initComponents(); this.logInFrame = logInFrame; jList5.setModel(listModel); dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); displayApkFolder(); //mouse listner - when clicked on uploaded package to show details jList3.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { JList list = (JList) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); final TaskObject taskObject = taskList.get(index); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new TaskFrame(taskObject).setVisible(true); } }); } } }); shouldCheckTasks = true; startThreadForTaskUpdatesChecking(); }
From source file:ru.codemine.pos.ui.windows.document.cheque.ChequeListWindow.java
@Override public void setupActionListeners() { setEditActionListener(viewCheque);//from w w w.j a va2 s.c o m 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.systray.Java6SystemTray.java
/** * @see de.tbuchloh.kiskis.gui.systray.ISystemTray#show() *//*from www. j ava2 s .c om*/ 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:DigitalClock.java
public DigitalClock() { // Set default values for our properties setFormat(DateFormat.getTimeInstance(DateFormat.MEDIUM, getLocale())); setUpdateFrequency(1000); // Update once a second // Specify a Swing TransferHandler object to do the dirty work of // copy-and-paste and drag-and-drop for us. This one will transfer // the value of the "time" property. Since this property is read-only // it will allow drags but not drops. setTransferHandler(new TransferHandler("time")); // Since JLabel does not normally support drag-and-drop, we need an // event handler to detect a drag and start the transfer. addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { getTransferHandler().exportAsDrag(DigitalClock.this, e, TransferHandler.COPY); }//from w ww . j a va 2 s . com }); // Before we can have a keyboard binding for a Copy command, // the component needs to be able to accept keyboard focus. setFocusable(true); // Request focus when we're clicked on addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { requestFocus(); } }); // Use a LineBorder to indicate when we've got the keyboard focus addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { setBorder(LineBorder.createBlackLineBorder()); } public void focusLost(FocusEvent e) { setBorder(null); } }); // Now bind the Ctrl-C keystroke to a "Copy" command. InputMap im = new InputMap(); im.setParent(getInputMap(WHEN_FOCUSED)); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "Copy"); setInputMap(WHEN_FOCUSED, im); // And bind the "Copy" command to a pre-defined Action that performs // a copy using the TransferHandler we've installed. ActionMap am = new ActionMap(); am.setParent(getActionMap()); am.put("Copy", TransferHandler.getCopyAction()); setActionMap(am); // Create a javax.swing.Timer object that will generate ActionEvents // to tell us when to update the displayed time. Every updateFrequency // milliseconds, this timer will cause the actionPerformed() method // to be invoked. (For non-GUI applications, see java.util.Timer.) timer = new Timer(updateFrequency, new ActionListener() { public void actionPerformed(ActionEvent e) { setText(getTime()); // set label to current time string } }); timer.setInitialDelay(0); // Do the first update immediately timer.start(); // Start timing now! }
From source file:UndoDrawing.java
public UndoableDrawingPanel() { MouseListener mouseListener = new MouseAdapter() { public void mouseReleased(MouseEvent mouseEvent) { undoableEditSupport.postEdit(new UndoableDrawEdit(UndoableDrawingPanel.this)); polygon.addPoint(mouseEvent.getX(), mouseEvent.getY()); repaint();/*from www.j ava 2s .com*/ } }; addMouseListener(mouseListener); }
From source file:painting.SwingPaintDemo3.java
public MyPanel() { setBorder(BorderFactory.createLineBorder(Color.black)); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { moveSquare(e.getX(), e.getY()); }//from www . ja va2s . c o m }); addMouseMotionListener(new MouseAdapter() { public void mouseDragged(MouseEvent e) { moveSquare(e.getX(), e.getY()); } }); }