List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:com.eviware.soapui.impl.rest.panels.component.RestResourceEditor.java
public RestResourceEditor(final RestResource editingRestResource, MutableBoolean updating) { super(editingRestResource.getFullPath()); this.editingRestResource = editingRestResource; this.updating = updating; setName(REST_RESOURCE_EDITOR_TEXT_FIELD); if (isResourceLonely(editingRestResource)) { getDocument().addDocumentListener(new LonelyDocumentListener()); addFocusListener(new FocusListener() { public void focusLost(FocusEvent e) { scanForTemplateParameters(editingRestResource); removeMatrixParameters(); }/*from w ww . jav a2s . co m*/ /** * Matrix parameters should not be added directly on the rest resource. * The parameter editor should be used. Hence they are removed from the rest resource editor * text field at this time. */ private void removeMatrixParameters() { setText(getText().split(";")[0]); } public void focusGained(FocusEvent e) { } }); } else { Color originalBackground = getBackground(); Border originalBorder = getBorder(); setEditable(false); setBackground(originalBackground); setBorder(originalBorder); setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { final RestResource focusedResource = new RestResourceFinder(editingRestResource) .findResourceAt(lastSelectedPosition); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { openPopup(focusedResource); } }); } }; addMouseListener(mouseListener); addCaretListener(new CaretListener() { @Override public void caretUpdate(final CaretEvent e) { lastSelectedPosition = e.getDot(); } }); } }
From source file:gtu._work.ui.LoadJspCheckTagUI.java
private void initGUI() { try {// w w w. ja v a 2 s .co m BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setTitle("\u8b80\u53d6Jsp\u8cc7\u8a0a"); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("jPanel1", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(475, 328)); { jTree1 = new JTree(); jScrollPane1.setViewportView(jTree1); jTree1.setModel(null); jTree1.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { jTree1MouseClicked(evt); } }); jTree1.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { jTree1ValueChanged(evt); } }); } } } { jPanel2 = new JPanel(); jTabbedPane1.addTab("jPanel2", null, jPanel2, null); { subFileNameText = new JTextField(); jPanel2.add(subFileNameText); subFileNameText.setPreferredSize(new java.awt.Dimension(95, 24)); subFileNameText.setText("xhtml"); } { ComboBoxModel jComboBox1Model = new DefaultComboBoxModel( new String[] { "??", "?" }); modifyFileBox = new JComboBox(); jPanel2.add(modifyFileBox); modifyFileBox.setModel(jComboBox1Model); } { exportReportToogleBtn = new JToggleButton(); jPanel2.add(exportReportToogleBtn); exportReportToogleBtn.setText("\u662f\u5426\u532f\u51fa\u5831\u8868"); exportReportToogleBtn.setPreferredSize(new java.awt.Dimension(120, 24)); exportReportToogleBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JCommonUtil.setJToggleButtonText(exportReportToogleBtn, new String[] { "", "?" }); } }); } { projectSrcPathBtn = new JButton(); jPanel2.add(projectSrcPathBtn); projectSrcPathBtn.setText("\u8a2d\u5b9a\u5c08\u6848\u76ee\u8def\u4e26\u6383\u63cf"); projectSrcPathBtn.setPreferredSize(new java.awt.Dimension(233, 95)); projectSrcPathBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } } } this.setSize(496, 395); } catch (Exception e) { e.printStackTrace(); } }
From source file:gui.InboxPanel.java
public void generate() { Message[] arrMsg = GmailAPI.Inbox.toArray(new Message[GmailAPI.Inbox.size()]); InboxList = new JList(arrMsg); InboxList.setCellRenderer(new DefaultListCellRenderer() { // Setting the DefaultListCellRenderer public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Message message = (Message) value; // Using value we are getting the object in JList Map<String, String> map = null; try { map = GmailAPI.getMessageDetails(message.getId()); } catch (MessagingException ex) { Logger.getLogger(InboxPanel.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(InboxPanel.class.getName()).log(Level.SEVERE, null, ex); }/*from www. j a v a2 s .c o m*/ String sub = map.get("subject"); if (map.get("subject").length() > 22) { sub = map.get("subject").substring(0, 20) + "..."; } setText(sub); // Setting the text //setIcon( shape.getImage() ); // Setting the Image Icon return this; } }); InboxList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); InboxList.setLayoutOrientation(JList.VERTICAL); InboxList.setVisibleRowCount(-1); jScrollPane1.setViewportView(InboxList); InboxList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { JList list = (JList) evt.getSource(); int index = list.locationToIndex(evt.getPoint()); String id = arrMsg[index].getId(); curId = id; Map<String, String> map = GmailAPI.getMessageDetails(id); jTextField1.setText(map.get("from")); jTextField2.setText(map.get("subject")); dateTextField.setText(map.get("senddate")); BodyTextPane.setText(map.get("body")); //BodyTextPane.setContentType("text/html"); //BodyTextArea.setCo } catch (IOException ex) { Logger.getLogger(InboxPanel.class.getName()).log(Level.SEVERE, null, ex); } catch (MessagingException ex) { Logger.getLogger(InboxPanel.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:edu.ku.brc.ui.dnd.SimpleGlassPane.java
/** * @param text/*from www.j a v a 2 s .co m*/ * @param pointSize * @param doBlockMouseEvents * @param dblClickProgBar */ public SimpleGlassPane(final String text, final int pointSize, final boolean doBlockMouseEvents, final boolean dblClickProgBar) { this.text = text; this.pointSize = pointSize; this.dblClickProgBar = dblClickProgBar; setBackground(fillColor); setOpaque(false); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { checkMouseEvent(e); super.mouseClicked(e); } @Override public void mouseDragged(MouseEvent e) { checkMouseEvent(e); super.mouseDragged(e); } @Override public void mouseEntered(MouseEvent e) { checkMouseEvent(e); super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { checkMouseEvent(e); super.mouseExited(e); } @Override public void mouseMoved(MouseEvent e) { checkMouseEvent(e); super.mouseMoved(e); } @Override public void mousePressed(MouseEvent e) { checkMouseEvent(e); super.mousePressed(e); } @Override public void mouseReleased(MouseEvent e) { checkMouseEvent(e); super.mouseReleased(e); } @Override public void mouseWheelMoved(MouseWheelEvent e) { checkMouseEvent(e); } }); /*addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { e.consume(); } @Override public void keyReleased(KeyEvent e) { e.consume(); } @Override public void keyTyped(KeyEvent e) { e.consume(); } });*/ }
From source file:de.tor.tribes.ui.components.DatePicker.java
private void init() { //build Header for (int i = 0; i < 7; i++) { JLabel head = new JLabel(dayNames[i]); head.setBackground(GRAY);/*from w w w .j a va 2 s . com*/ head.setOpaque(true); head.setPreferredSize(new Dimension(20, 20)); head.setMinimumSize(new Dimension(20, 20)); head.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = i; gbc.gridy = 0; gbc.insets = new Insets(2, 2, 6, 2); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; jPanelDaySelection.add(head, gbc); } daysInMonth = new CrossedLabel[WEEKS_TO_SHOW][7]; datesInMonth = new Date[WEEKS_TO_SHOW][7]; for (int i = 0; i < WEEKS_TO_SHOW; i++) { for (int j = 0; j < 7; j++) { daysInMonth[i][j] = new CrossedLabel(); daysInMonth[i][j].setPreferredSize(new Dimension(20, 20)); daysInMonth[i][j].setMinimumSize(new Dimension(20, 20)); daysInMonth[i][j].setHorizontalAlignment(javax.swing.SwingConstants.CENTER); daysInMonth[i][j].addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseevent) { dayClicked(mouseevent); } }); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.PAGE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = j; gbc.gridy = i + 1; gbc.insets = new Insets(2, 2, 2, 2); gbc.ipadx = 0; gbc.ipady = 0; gbc.weightx = 1.0; gbc.weighty = 0.0; jPanelDaySelection.add(daysInMonth[i][j], gbc); } } buildCalendar(); }
From source file:com.nbt.TileCanvas.java
public TileCanvas(final World world) { Validate.notNull(world, "world must not be null"); this.world = world; setFocusable(true);/*from ww w . j a v a 2 s.co m*/ addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { int tileWidth = calculateWidth(); setTileWidth(tileWidth); int tileHeight = calculateHeight(); setTileHeight(tileHeight); save(); } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { TileCanvas.this.keyPressed(e); } }); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Point point = e.getPoint(); int x = pixelsToTile(point.x); int z = pixelsToTile(point.y); int tileX = x + getTileX(); int tileZ = z + getTileZ(); int y = getAltitude(); Block block = world.getBlock(tileX, y, tileZ); blockClicked(block); } }); addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int amount = e.getWheelRotation(); int altitude = getAltitude(); setAltitude(amount + altitude); updateXYZ(); doRepaint(); save(); } }); addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { updateXYZ(); } }); new MouseDragAndDrop(this) { private int tileX, tileZ; @Override public void selected(MouseEvent e) { this.tileX = getTileX(); this.tileZ = getTileZ(); } @Override public void dragged(MouseEvent e) { MouseEvent startEvent = getStartEvent(); Point startPt = startEvent.getPoint(); Point releasePt = e.getPoint(); int x = tileX + (pixelsToTile(startPt.x) - pixelsToTile(releasePt.x)); int z = tileZ + (pixelsToTile(startPt.y) - pixelsToTile(releasePt.y)); setTileX(x); setTileZ(z); updateXYZ(); doRepaint(); } @Override public void dropped(MouseEvent press, MouseEvent release) { // Point startPt = press.getPoint(); // Point releasePt = release.getPoint(); // int x = getTileX() + pixelsToTile(startPt.x - releasePt.x); // int z = getTileZ() + pixelsToTile(startPt.y - releasePt.y); // setTileX(x); // setTileZ(z); // // updateXYZ(); // doRepaint(); save(); } }.install(); setLayout(null); hud = new HUD(); int width = 200, height = 200; hud.setSize(width, height); add(hud); }
From source file:ru.codemine.pos.ui.windows.devices.barcodescanner.BarcodeScannerListWindow.java
@Override public void setupActionListeners() { setNewActionListener(newBarcodeScannerDevice); setEditActionListener(editBarcodeScannerDevice); setDeleteActionListener(deleteBarcodeScannerDevice); setProcessActionListener(setActiveBarcodeScannerDevice); setRefreshActionListener(refreshBarcodeScannerDeviceList); table.addMouseListener(new MouseAdapter() { @Override/*w ww. ja v a 2 s .c o m*/ 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:gtu._work.ui.CheckJavaClassPathUI.java
private void initGUI() { try {//from w w w.j a v a 2 s .c om BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); setTitle("??importjava"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("", null, jPanel1, null); { classPathText = new JTextField(); jPanel1.add(classPathText, BorderLayout.NORTH); classPathText.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (StringUtils.isNotBlank(classPathText.getText())) { String text = classPathText.getText(); DefaultListModel model = (DefaultListModel) classPathList.getModel(); boolean findOk = false; for (int ii = 0; ii < model.size(); ii++) { String val = (String) model.getElementAt(ii); if (StringUtils.equals(val, text)) { findOk = true; } } if (!findOk) { model.addElement(text); } } } }); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(492, 302)); { DefaultListModel classPathListModel = new DefaultListModel(); classPathList = new JList(); Set<String> clzSet = new HashSet<String>(); for (Enumeration<?> enu = configBean.getConfigProp().keys(); enu.hasMoreElements();) { String key = (String) enu.nextElement(); if (key.contains(CLASSNAME_KEY)) { clzSet.add(configBean.getConfigProp().getProperty(key)); } } for (String clzName : clzSet) { classPathListModel.addElement(clzName); } jScrollPane1.setViewportView(classPathList); classPathList.setModel(classPathListModel); classPathList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(classPathList).defaultJListKeyPressed(evt); } }); } } { executeBtn = new JButton(); jPanel1.add(executeBtn, BorderLayout.WEST); executeBtn.setText("\u57f7\u884c"); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { executeBtnActionPerformed(evt); } }); } { srcPathText = new JTextField(); if (configBean.getConfigProp().containsKey(SRCPATHTEXT_KEY)) { srcPathText.setText(configBean.getConfigProp().getProperty(SRCPATHTEXT_KEY)); } jPanel1.add(srcPathText, BorderLayout.SOUTH); JCommonUtil.jTextFieldSetFilePathMouseEvent(srcPathText, true); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("log", null, jPanel2, null); { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(530, 350)); { logArea = new JTextArea(); jScrollPane2.setViewportView(logArea); } } } } pack(); this.setSize(551, 417); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:ScreenCapture.java
public ImageArea() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (image == null) return; startPoint = endPoint = e.getPoint(); repaint();//from w w w .j av a2 s.c o m } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if (image == null) return; endPoint = e.getPoint(); repaint(); } }); }
From source file:hermes.browser.components.ClasspathGroupTable.java
private void init() { final JPopupMenu popupMenu = new JPopupMenu(); final JMenuItem addItem = new JMenuItem("Add Group"); final JMenuItem removeItem = new JMenuItem("Remove Group"); final JMenuItem renameItem = new JMenuItem("Rename"); popupMenu.add(addItem);/* ww w. ja v a 2 s . c o m*/ popupMenu.add(removeItem); popupMenu.add(renameItem); addItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { doAddGroup(); dialog.setDirty(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } } }); removeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (getSelectedRowCount() > 0) { for (int row : getSelectedRows()) { getClasspathGroupTableModel().removeRow(row); } dialog.setDirty(); } } }); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (getSelectedRow() != -1) { doRename(); } } }); mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { removeItem.setEnabled(getClasspathGroupTableModel().getRowCount() != 0); renameItem.setEnabled(getClasspathGroupTableModel().getRowCount() != 0); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }; addMouseListener(mouseAdapter); getTableHeader().addMouseListener(mouseAdapter); if (dialog != null) { addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // // Think this is ok, seems 2 do the job. if (evt.getPropertyName().equals("tableCellEditor")) { dialog.setDirty(); } } }); } }