@Override public JToolTip createToolTip() { JToolTip t = toolTip; toolTip = null; if (t != null) { t.addMouseMotionListener(new MouseMotionAdapter() { // #233642 boolean initialized = false; @Override public void mouseMoved(MouseEvent e) { if (!initialized) { initialized = true; // ignore the first event } else { // hide the tooltip if mouse moves over it ToolTipManager.sharedInstance().mousePressed(e); } } }); return t; } else { return super.createToolTip(); } }
public PaintPanel() { // handle frame mouse motion event addMouseMotionListener( new MouseMotionAdapter() // anonymous inner class { // store drag coordinates and repaint @Override public void mouseDragged(MouseEvent event) { points.add(event.getPoint()); repaint(); // repaint JFrame } } ); }
private static void initAndShowUI() { popupMenu = new JPopupMenu(); for (int i = 0; i < 100; i++) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(" Test " + i); item.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { passed = true; } }); popupMenu.add(item); } frame = new JFrame(); screenBounds.set(getScreenBounds()); frame.setBounds(screenBounds.get()); frame.setVisible(true); }
public CustomTreeRenderer() { setOpaque(true); //setBackgroundNonSelectionColor(tree.getBackground()); tree.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent me) { TreePath treePath = tree.getPathForLocation(me.getX(), me.getY()); Object obj; if (treePath != null) { obj = treePath.getLastPathComponent(); } else { obj = null; } if (obj != lastNode) { lastNode = obj; tree.repaint(); } } }); }
/** Install listeners during construction that are unique for the AutocompleteTextField. */ private void setup() { suggestionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); popup.add(scrollPane); suggestionList.setFixedCellHeight(20); suggestionList.setFocusable(false); scrollPane.setFocusable(false); popup.setFocusable(false); suggestionList.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int i = suggestionList.getUI().locationToIndex(suggestionList, e.getPoint()); getModel().setSuggestions(model.suggestions, model.selectedIndex, i); } }); getDocument().addDocumentListener(docListener); addKeyListener(keyListener); model.addChangeListener(modelListener); suggestionList.addListSelectionListener(listListener); }
public JSlider getSlider(int min, int max, int value) { JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value); slider.setMajorTickSpacing(10); slider.setMinorTickSpacing(1); // slider.setPaintLabels(true); // slider.setUI(new WindowsSliderUI(slider)); slider.setForeground(AppThemeColor.TEXT_DEFAULT); slider.setFont(REGULAR_FONT.deriveFont(15f)); slider.setRequestFocusEnabled(false); slider.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { slider.getParent().repaint(); } }); slider.setBackground(AppThemeColor.FRAME); return slider; }
/** * Create the Window for the given alignment and * * @param comp * father component * @param alignment * algenment * @param point * location point * @return the created window */ protected Window createWindow(Component comp, int alignment, Point point) { JToolBar bar = getToolBar(alignment); if (bar == null) { return null; } final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(comp)); dialog.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent e) { if (!dialog.hasFocus()) dialog.requestFocusInWindow(); } }); dialog.setUndecorated(true); dialog.setLayout(new BorderLayout()); dialog.add(bar); dialog.pack(); Point loc = adujstPoint(point); SwingUtilities.convertPointToScreen(loc, comp); dialog.setLocation(loc); return dialog; }
public void setOnClickAction(Runnable action){ super.setOnClickAction(action); list.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(java.awt.event.MouseEvent e) { JList l = (JList)e.getSource(); ListModel m = l.getModel(); int index = l.locationToIndex(e.getPoint()); if (index > -1) { Requirement req = ((Presenter_Requirement) m.getElementAt(index)).getRequirement(); String tooltip = (req != null) ? req.getTitle() + "<br>" + req.getDescription() : ""; l.setToolTipText("<html><p>" + tooltip + "</p></html>"); } } }); }
/** * Creates a new SequenceFragmentationPanel. * * @param aSequence String with the Modified Sequence of a peptide * identification. * @param profiles ArrayList with the modification profiles. * @param boolModifiedSequence boolean describing the sequence. This * constructor can be used to enter a ModifiedSequence or a normal sequence. * @param score1Name the name of the score above of the sequence * @param score2Name the name of the score under the sequence * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless() * returns true. * @see java.awt.GraphicsEnvironment#isHeadless * @see javax.swing.JComponent#getDefaultLocale */ public SequenceModificationPanel(String aSequence, ArrayList<ModificationProfile> profiles, boolean boolModifiedSequence, String score1Name, String score2Name) throws HeadlessException { super(); this.score1Name = score1Name; this.score2Name = score2Name; isModifiedSequence = boolModifiedSequence; iSequenceComponents = parseSequenceIntoComponents(aSequence); this.profiles = profiles; this.setPreferredSize(new Dimension(estimateWidth(), estimateHeight())); this.setMaximumSize(new Dimension(estimateWidth(), estimateHeight())); fragmentIonRectangles = new HashMap<String, Rectangle>(); addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent me) { mouseMovedHandler(me); } }); }
public MapView(SLMap map) { this.map = map; generateImage(); addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { mouseChanged(); } }); setLayout(new BorderLayout()); this.imagePanel = new ImagePanel(mapImage); this.coordsLabel = new JLabel("Map Coordinates: "); add(imagePanel, BorderLayout.NORTH); add(coordsLabel, BorderLayout.SOUTH); }
/** Creates a new instance of ProgressGlassPane */ public ProgressGlassPane() { // blocks all user input addMouseListener(new MouseAdapter() { }); addMouseMotionListener(new MouseMotionAdapter() { }); addKeyListener(new KeyAdapter() { }); setFocusTraversalKeysEnabled(false); addComponentListener(new ComponentAdapter() { public void componentShown(ComponentEvent evt) { requestFocusInWindow(); } }); setBackground(Color.WHITE); setFont(new Font("Default", Font.BOLD, 16)); }
/** * Create the Window for the given alignment and * * @param comp * father component * @param alignment * algenment * @param point * location point * @return the created window */ protected Window createWindow(Component comp, int alignment, Point point) { JToolBar tlb = getToolBar(alignment); if (tlb == null) { return null; } final JDialog dlg = new JDialog(JOptionPane.getFrameForComponent(comp)); dlg.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent e) { if (!dlg.hasFocus()) dlg.requestFocusInWindow(); } }); dlg.setUndecorated(true); dlg.setLayout(new BorderLayout()); dlg.add(tlb); dlg.pack(); Point loc = adujstPoint(point); SwingUtilities.convertPointToScreen(loc, comp); dlg.setLocation(loc); return dlg; }
GaragePanel(UI p) { super("src/hu/elte/txtuml/examples/garage/images/garage.jpg"); parent = p; try { doorImg = ImageIO.read(new File("src/hu/elte/txtuml/examples/garage/images/door.jpg")); sirenImg1 = ImageIO.read(new File("src/hu/elte/txtuml/examples/garage/images/siren1.jpg")); sirenImg2 = ImageIO.read(new File("src/hu/elte/txtuml/examples/garage/images/siren2.jpg")); } catch (IOException e) { System.out.println("Error: Cannot load some image."); } addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent me) { Rectangle doorRect = new Rectangle(doorX, doorY, doorImg.getWidth(), doorImg.getHeight()); if (doorRect.contains(me.getPoint())) { parent.control.motionSensorActivated(); parent.control.alarmSensorActivated(); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } else { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); }
public PaintPanel() { // handle frame mouse motion event addMouseMotionListener( new MouseMotionAdapter() // anonymous inner class { // store drag coordinates and repaint public void mouseDragged( MouseEvent event ) { if ( pointCount < points.length ) { points[ pointCount ] = event.getPoint(); // find point pointCount++; // increment number of points in array repaint(); // repaint JFrame } // end if } // end method mouseDragged } // end anonymous inner class ); // end call to addMouseMotionListener }
private void setMouseMotionListener() { addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(final MouseEvent event) { final int cardIndex = getPermanentInfoIndexAt(event.getX(), event.getY()); final boolean isCardChanged = (currentCardIndex != cardIndex); if (cardIndex >= 0) { if (isCardChanged) { if (!CONFIG.isMouseWheelPopup() || viewer.getController().isPopupVisible()) { showCardPopup(cardIndex); } } } else { viewer.getController().hideInfo(); } currentCardIndex = cardIndex; if (linkedScreenRectangles.size() > 1) { redrawCachedImage(); } } }); }
private JComponent createInfoPanel(Component view) { final JLabel infoLabel = new JLabel(); infoLabel.setVerticalAlignment(JLabel.TOP); if (view instanceof TreeView) { final TreeView treeView = (TreeView) view; view.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent evt) { infoLabel.setText(treeView.getInfoText(evt)); } }); } JScrollPane scrollPane = new JScrollPane(); scrollPane.setMinimumSize(new Dimension(0, 0)); scrollPane.setViewportView(infoLabel); return scrollPane; }
public JLabel getPixelLabel() { if (pixelLabel == null) { pixelLabel = new JLabel(" , "); pixelLabel.setPreferredSize(new Dimension(200, 35)); final JImageCanvas ic = getImageCanvas(); ic.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { Point cp = e.getPoint(); Point2D ip = ic.convertToImage(cp); String text = String.format("%4d, %4d", Math.round(ip.getX()), Math.round(ip.getY())); pixelLabel.setText("Current X, Y: " + text); } }); } return pixelLabel; }
protected MacButtonlessScrollbarUI() { myMouseMotionListener = new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { boolean inside = isOverThumb(e.getPoint()); if (inside != myMouseIsOverThumb) { myMouseIsOverThumb = inside; e.getComponent().repaint(); } } }; myMouseListener = new MouseAdapter() { @Override public void mouseExited(MouseEvent e) { if (myMouseIsOverThumb) { myMouseIsOverThumb = false; e.getComponent().repaint(); } } }; }
/** Constructs the histogram panel object. @param histogram Histogram to display */ public HistogramPanel(Histogram h) { this.histogram = h; initClass(); addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent e) { int x = e.getX(); int bin = x*maxBins / size.width; int[][] bins = histogram.getBins(); int numBands = bins.length; String txt = Integer.toString(bins[0][bin]); for (int i = 1; i < numBands; i++) { txt = txt+","+bins[i][bin]; } setToolTipText("Bin: "+bin+" ["+txt+"]"); } }); }
@Override protected MouseMotionAdapter onSubscribe(final Observer<? super MouseEvent> observer) { LOG.trace("onSubscribe(): {}", observer); final MouseMotionAdapter listener = new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { LOG.trace("mouseDragged(): {}", e); onNext(e); } }; component.addMouseMotionListener(listener); return listener; }
@Override protected MouseMotionListener onSubscribe(final Observer<? super MouseEvent> observer) { LOG.trace("onSubscribe(): {}", observer); final MouseMotionAdapter listener = new MouseMotionAdapter() { @Override public void mouseMoved(final MouseEvent event) { checkNotNull(event, "event"); onNext(event); } }; component.addMouseMotionListener(listener); return listener; }
private JLabel setPie1() { int[] angle = new int[numClust]; double[] prc = info.percent; int i; angle[0] = 0; for (i = 1; i < numClust; i++) { angle[i] = angle[i - 1] + (int) ((360) * prc[i - 1]); } for (; i < angle.length; i++) { angle[i] = 360; } final JLabel l = new JLabel(); final pieChartIcon p = new pieChartIcon(numClust); l.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int pos; pos = p.getPosXY(e.getX(), e.getY()); if (pos != -1) { l.setToolTipText(tableClusters.getValueAt(pos, 2).toString()); } else { l.setToolTipText(""); } } }); p.setAngle(angle); l.setIcon(p); return l; }
private JLabel setPie2(int var) { int[] angle = new int[numClust]; int i; angle[0] = 0; for (i = 1; i < numClust; i++) { angle[i] = angle[i - 1] + (int) ((360) * info.infoCluster[i].percVar[var]); } for (; i < angle.length; i++) { angle[i] = 360; } final JLabel l = new JLabel(); pieChartVars = new pieChartIcon(numClust); l.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int pos; pos = pieChartVars.getPosXY(e.getX(), e.getY()); if (pos != -1) { l.setToolTipText(tableVars.getValueAt(pos, 1).toString()); } else { l.setToolTipText(""); } } }); pieChartVars.setAngle(angle); l.setIcon(pieChartVars); return l; }
/** * Builds a new Sectors3D Panel to show results of 3-class models * @param s3d results vector * @param classNames array with class names */ public Sectors3DPanel(Vector<Object> s3d, String[] classNames) { super(new BorderLayout()); this.s3d = s3d; this.classNames = classNames; this.setBackground(BGCOLOR); this.setBorder(BorderFactory.createEtchedBorder()); // Label to show coordinates coordLabel = new JLabel(); coordLabel.setBorder(BorderFactory.createEtchedBorder()); coordLabel.setVisible(false); coordLabel.setOpaque(true); // Puts label on south-east corner JPanel tmp = new JPanel(new BorderLayout()); tmp.add(coordLabel, BorderLayout.EAST); tmp.setOpaque(false); this.add(tmp, BorderLayout.SOUTH); // Adds a mouseListener to show graph coordinates this.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { if (isShown) { String coord = getCoordinates(e.getX(), e.getY()); if (coord != null) { coordLabel.setText(coord); coordLabel.setVisible(true); Sectors3DPanel.this.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } else { coordLabel.setText(""); coordLabel.setVisible(false); Sectors3DPanel.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); }
public GlassPane() { setOpaque(false); setVisible(false); Color base = UIManager.getColor("inactiveCaptionBorder"); base = (base == null) ? Color.LIGHT_GRAY : base; Color background = new Color(base.getRed(), base.getGreen(), base.getBlue(), 128); setBackground(background); // Disable Mouse events for the panel addMouseListener(new MouseAdapter() {}); addMouseMotionListener(new MouseMotionAdapter() {}); }
public TopTablePanel(final ElistTablePanel panel, JTable table) { super(table.getColumnModel()); this.panel = panel; this.table = table; this.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { setToolTipText(panel.getToolTipText(getHeight() - e.getY(), e .getX())); } }); setResizingAllowed(false); panel.setSize(getSize().height, getSize().width); }
public BusyGlassPane() { initializeComponents(); addMouseListener(new MouseAdapter() { }); addMouseMotionListener(new MouseMotionAdapter() { }); addKeyListener(new KeyAdapter() { }); }
private static void constructTestUI() { frame1 = new Frame(); frame1.setBounds(100, 100, 100, 100); frame1.addMouseMotionListener(new MouseMotionAdapter() { private boolean shown = false; @Override public void mouseMoved(MouseEvent e) { if (shown) { return; } shown = true; frame2 = new Frame(); frame2.setBounds(120, 120, 120, 120); frame2.setVisible(true); Point positionInFrame2 = frame2.getMousePosition(); if (positionInFrame2.x != 30 || positionInFrame2.y != 30) { throw new RuntimeException("Wrong position reported. Should be [30, 30] but was [" + positionInFrame2.x + ", " + positionInFrame2.y + "]"); } Point positionInFrame1 = frame1.getMousePosition(); if (positionInFrame1 != null) { throw new RuntimeException("Wrong position reported. Should be null"); } } }); frame1.setVisible(true); }
protected void initializeMouseMotionListener() { addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { SB_TabbedCanvas tabbedCanvas = (SB_TabbedCanvas) e.getSource(); if (!tabbedCanvas._dragging && tabbedCanvas._downIndex != -1) { tabbedCanvas._dragging = true; setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } }); }