Java Code Examples for java.awt.event.MouseMotionAdapter

The following are top voted examples for showing how to use java.awt.event.MouseMotionAdapter. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: Outline.java   Source Code and License 6 votes vote down vote up
@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();
    }
}
 
Example 2
Project: LivroJavaComoProgramar10Edicao   File: PaintPanel.java   Source Code and License 6 votes vote down vote up
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
         } 
      } 
   ); 
}
 
Example 3
Project: ramus   File: TopTablePanel.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 4
Project: jdk8u-jdk   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 5
Project: openjdk-jdk10   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 6
Project: sbc-qsystem   File: JTreeComboBox.java   Source Code and License 6 votes vote down vote up
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();
            }
        }
    });
}
 
Example 7
Project: openjdk9   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 8
Project: jdk8u_jdk   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 9
Project: lookaside_java-1.8.0-openjdk   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 10
Project: MercuryTrade   File: ComponentsFactory.java   Source Code and License 6 votes vote down vote up
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;
    }
 
Example 11
Project: SWAT20   File: WorkbenchPopupToolBar.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 12
Project: amos-ss15-proj3   File: Requirement_ElementHandler.java   Source Code and License 6 votes vote down vote up
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>");
            }
        }
    });
}
 
Example 13
Project: compomics-utilities   File: SequenceModificationPanel.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 14
Project: uosl   File: MapView.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 15
Project: filthy-rich-clients   File: ProgressGlassPane.java   Source Code and License 6 votes vote down vote up
/** 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));
}
 
Example 16
Project: infobip-open-jdk-8   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 17
Project: jdk8u-dev-jdk   File: bug7154841.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 18
Project: WOLFGANG   File: PopupToolBar.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 19
Project: txtUML   File: UI.java   Source Code and License 6 votes vote down vote up
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));
			}
		}
	});
}
 
Example 20
Project: GPLshared   File: PaintPanel.java   Source Code and License 6 votes vote down vote up
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
}
 
Example 21
Project: magarena   File: ImagePermanentViewer.java   Source Code and License 6 votes vote down vote up
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();
            }
        }
    });
}
 
Example 22
Project: union-find-inspector   File: UnionFindVisualizer.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 23
Project: vars   File: ImageAnnotationFrame.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 24
Project: consulo   File: MacButtonlessScrollbarUI.java   Source Code and License 6 votes vote down vote up
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();
      }
    }
  };
}
 
Example 25
Project: pdfxtk   File: HistogramPanel.java   Source Code and License 6 votes vote down vote up
/** 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+"]");
	}
      });
  }
 
Example 26
Project: reactive-stream-swing   File: MouseDraggedSubject.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 27
Project: reactive-stream-swing   File: MouseMovedSubject.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 28
Project: jmt   File: KMeansInfoClustering.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 29
Project: jmt   File: KMeansInfoClustering.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 30
Project: jmt   File: Sectors3DPanel.java   Source Code and License 5 votes vote down vote up
/**
 * 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));
				}
			}
		}
	});
}
 
Example 31
Project: jmt   File: InGateWaySectionPanel.java   Source Code and License 5 votes vote down vote up
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() {});
}
 
Example 32
Project: QN-ACTR-Release   File: KMeansInfoClustering.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 33
Project: QN-ACTR-Release   File: KMeansInfoClustering.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 34
Project: QN-ACTR-Release   File: Sectors3DPanel.java   Source Code and License 5 votes vote down vote up
/**
 * 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));
				}
			}
		}
	});
}
 
Example 35
Project: WordnetLoom   File: BusyGlassPane.java   Source Code and License 5 votes vote down vote up
public BusyGlassPane() {
    initializeComponents();
    addMouseListener(new MouseAdapter() {
    });
    addMouseMotionListener(new MouseMotionAdapter() {
    });
    addKeyListener(new KeyAdapter() {
    });
}
 
Example 36
Project: jdk8u-jdk   File: GetMousePositionWithPopup.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 37
Project: openjdk9   File: GetMousePositionWithPopup.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 38
Project: SimBionic   File: SB_TabbedCanvas.java   Source Code and License 5 votes vote down vote up
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));
            }
        }
    });
}
 
Example 39
Project: pumpernickel   File: AutocompleteTextField.java   Source Code and License 5 votes vote down vote up
/** 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);
}
 
Example 40
Project: jdk8u_jdk   File: GetMousePositionWithPopup.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 41
Project: lookaside_java-1.8.0-openjdk   File: GetMousePositionWithPopup.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 42
Project: cuba   File: DisabledGlassPane.java   Source Code and License 5 votes vote down vote up
public DisabledGlassPane() {
    //  Set glass pane properties

    setOpaque(false);
    Color base = UIManager.getColor("control");
    if (base == null)
        base = Color.gray;
    Color background = new Color(base.getRed(), base.getGreen(), base.getBlue(), 128);
    setBackground(background);
    setLayout(new GridBagLayout());

    //  Add a message label to the glass pane

    add(message, new GridBagConstraints());
    message.setOpaque(true);
    message.setBorder(MESSAGE_BORDER);

    //  Disable Mouse, Key and Focus events for the glass pane

    addMouseListener(new MouseAdapter() {
    });
    addMouseMotionListener(new MouseMotionAdapter() {
    });

    addKeyListener(this);

    setFocusTraversalKeysEnabled(false);
}
 
Example 43
Project: intellij-ce-playground   File: ClickNavigator.java   Source Code and License 5 votes vote down vote up
private void addMouseMotionListener(final Editor view,
                                    final SyntaxHighlighter highlighter,
                                    final HighlightData[] data, final boolean isBackgroundImportant) {
  view.getContentComponent().addMouseMotionListener(new MouseMotionAdapter() {
    @Override
    public void mouseMoved(MouseEvent e) {
      LogicalPosition pos = view.xyToLogicalPosition(new Point(e.getX(), e.getY()));
      navigate(view, false, pos, highlighter, data, isBackgroundImportant);
    }
  });
}
 
Example 44
Project: intellij-ce-playground   File: SimpleEditorPreview.java   Source Code and License 5 votes vote down vote up
private void addMouseMotionListener(final Editor view,
                                    final SyntaxHighlighter highlighter,
                                    final HighlightData[] data, final boolean isBackgroundImportant) {
  view.getContentComponent().addMouseMotionListener(new MouseMotionAdapter() {
    @Override
    public void mouseMoved(MouseEvent e) {
      LogicalPosition pos = view.xyToLogicalPosition(new Point(e.getX(), e.getY()));
      navigate(view, false, pos, highlighter, data, isBackgroundImportant);
    }
  });
}
 
Example 45
Project: intellij-ce-playground   File: NavBarListWrapper.java   Source Code and License 5 votes vote down vote up
public NavBarListWrapper(final JList list) {
  super(list);
  list.addMouseMotionListener(new MouseMotionAdapter() {
    boolean myIsEngaged = false;
    @Override
    public void mouseMoved(MouseEvent e) {
      if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
        final Point point = e.getPoint();
        final int index = list.locationToIndex(point);
        list.setSelectedIndex(index);
      } else {
        myIsEngaged = true;
      }
    }
  });

  ScrollingUtil.installActions(list);

  final int modelSize = list.getModel().getSize();
  setBorder(BorderFactory.createEmptyBorder());
  if (modelSize > 0 && modelSize <= MAX_SIZE) {
    list.setVisibleRowCount(0);
    getViewport().setPreferredSize(list.getPreferredSize());
  } else {
    list.setVisibleRowCount(MAX_SIZE);
  }
  myList = list;
}
 
Example 46
Project: WorldGrower   File: WorldPanel.java   Source Code and License 5 votes vote down vote up
public void startBuildMode(BuildAction buildAction, int[] args) {
	this.buildModeOutline.startBuildMode(playerCharacter, buildAction, args, imageInfoReader);
	this.mouseMotionListener = new MouseMotionAdapter() {

		@Override
		public void mouseMoved(MouseEvent mouseEvent) {
			super.mouseMoved(mouseEvent);
			WorldPanel.this.repaintWorldView();
		}
		
	};
	this.addMouseMotionListener(this.mouseMotionListener);
	bindEscapeButtonToCancelBuildMode();
}
 
Example 47
Project: compomics-utilities   File: SequenceFragmentationPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new SequenceFragmentationPanel working with B and Y ions.
 *
 * @param aSequence String with the Modified Sequence of an peptide
 * identification.
 * @param aIonMatches ArrayList with Fragmentation ion matches.
 * @param boolModifiedSequence boolean describing the sequence. This
 * constructor can be used to enter a ModifiedSequence or a normal sequence.
 * @param aHighlightModifications boolean decides whether the modification
 * are highlighted by adding a star above the modified residue instead if
 * displaying the PTM short name
 * @param modificationProfile the modification profile
 * @param forwardIon the forward ion type (for instance B ion) as indexed by
 * the PeptideFragmentIon static fields
 * @param rewindIon the rewind ion type (for instance Y ion) as indexed by
 * the PeptideFragmentIon static fields
 * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @see javax.swing.JComponent#getDefaultLocale
 */
public SequenceFragmentationPanel(String aSequence, ArrayList<IonMatch> aIonMatches, boolean boolModifiedSequence,
        boolean aHighlightModifications, PtmSettings modificationProfile, int forwardIon, int rewindIon) throws HeadlessException {
    super();

    this.forwardIon = forwardIon;
    forwardColor = SpectrumPanel.determineFragmentIonColor(Ion.getGenericIon(Ion.IonType.PEPTIDE_FRAGMENT_ION, forwardIon), false);
    this.rewindIon = rewindIon;
    rewindColor = SpectrumPanel.determineFragmentIonColor(Ion.getGenericIon(Ion.IonType.PEPTIDE_FRAGMENT_ION, rewindIon), false);

    this.modificationProfile = modificationProfile;
    isModifiedSequence = boolModifiedSequence;
    iSequenceComponents = parseSequenceIntoComponents(aSequence);
    iIonMatches = aIonMatches;
    iHighlightModifications = aHighlightModifications;

    this.normalizeMatchedIons();
    this.setPreferredSize(new Dimension(estimateWidth(), estimateHeight()));

    tooltipRectangles = new HashMap<String, Rectangle>();

    addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent me) {
            mouseMovedHandler(me);
        }
    });
}
 
Example 48
Project: compomics-utilities   File: SequenceFragmentationPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new SequenceFragmentationPanel working with B and Y ions.
 *
 * @param taggedModifiedSequence the tagged modified peptide sequence
 * @param aIonMatches ArrayList with Fragmentation ion matches.
 * @param aHighlightModifications boolean decides whether the modification
 * are highlighted by adding a star above the modified residue instead if
 * displaying the PTM short name
 * @param modificationProfile the modification profile
 * @param forwardIon the forward ion type (for instance B ion) as indexed by
 * the PeptideFragmentIon static fields
 * @param rewindIon the rewind ion type (for instance Y ion) as indexed by
 * the PeptideFragmentIon static fields
 * @throws java.awt.HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @see javax.swing.JComponent#getDefaultLocale
 */
public SequenceFragmentationPanel(String taggedModifiedSequence, ArrayList<IonMatch> aIonMatches, 
        boolean aHighlightModifications, PtmSettings modificationProfile, int forwardIon, int rewindIon) throws HeadlessException {
    super();

    this.forwardIon = forwardIon;
    forwardColor = SpectrumPanel.determineFragmentIonColor(Ion.getGenericIon(Ion.IonType.PEPTIDE_FRAGMENT_ION, forwardIon), false);
    this.rewindIon = rewindIon;
    rewindColor = SpectrumPanel.determineFragmentIonColor(Ion.getGenericIon(Ion.IonType.PEPTIDE_FRAGMENT_ION, rewindIon), false);

    this.modificationProfile = modificationProfile;
    isModifiedSequence = true;
    iSequenceComponents = parseSequenceIntoComponents(taggedModifiedSequence);
    iIonMatches = aIonMatches;
    iHighlightModifications = aHighlightModifications;

    this.normalizeMatchedIons();
    this.setPreferredSize(new Dimension(estimateWidth(), estimateHeight()));

    tooltipRectangles = new HashMap<String, Rectangle>();

    addMouseMotionListener(new MouseMotionAdapter() {

        public void mouseMoved(MouseEvent me) {
            mouseMovedHandler(me);
        }
    });
}
 
Example 49
Project: openwonderland   File: LogViewerFrame.java   Source Code and License 5 votes vote down vote up
public ManualScrollEditorPane() {
    addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
            forceScroll(r);
        }
    });
}
 
Example 50
Project: SmartTokens   File: PopdownButton.java   Source Code and License 5 votes vote down vote up
private MouseMotionListener createToggleButtonMouseMotionListener() {
    return new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            MenuSelectionManager.defaultManager().processMouseEvent(e);
        }
    };
}
 
Example 51
Project: SmartTokens   File: WindowDragger.java   Source Code and License 5 votes vote down vote up
private MouseMotionAdapter createMouseMotionListener() {
    return new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            Point dragPoint = new Point(e.getPoint());
            SwingUtilities.convertPointToScreen(dragPoint, fComponent);

            fWindow.setLocation(dragPoint.x - dX, dragPoint.y - dY);
        }
    };
}
 
Example 52
Project: SmartTokens   File: EPComboPopup.java   Source Code and License 5 votes vote down vote up
public MouseMotionListener getMouseMotionListener() {
    return new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            MenuSelectionManager.defaultManager().processMouseEvent(e);
        }
    };
}
 
Example 53
Project: SmartTokens   File: HudWindow.java   Source Code and License 5 votes vote down vote up
private MouseMotionListener createMouseMotionListener() {
    return new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            Point windowPoint = SwingUtilities.convertPoint(fResizeCorner, e.getPoint(), fWindow);
            fWindow.setSize(windowPoint.x + fXOffsetToWindowEdge,
                    windowPoint.y + fYOffsetToWidnowEdge);

            // the following two lines are a work-around to Sun bug 6318144:
            // http://bugs.sun.com/view_bug.do;?bug_id=6318144
            fWindow.invalidate();
            fWindow.validate();
        }
    };
}
 
Example 54
Project: seaglass   File: WindowDragger.java   Source Code and License 5 votes vote down vote up
/**
 * Create the mouse motion listener.
 *
 * @return the mouse motion listener.
 */
private MouseMotionAdapter createMouseMotionListener() {
    return new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            Point dragPoint = new Point(e.getPoint());

            SwingUtilities.convertPointToScreen(dragPoint, fComponent);

            fWindow.setLocation(dragPoint.x - dX, dragPoint.y - dY);
        }
    };
}
 
Example 55
Project: infobip-open-jdk-8   File: GetMousePositionWithPopup.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 56
Project: jdk8u-dev-jdk   File: GetMousePositionWithPopup.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 57
Project: oStorybook   File: DnDTest01.java   Source Code and License 5 votes vote down vote up
private void initUi() {
		setLayout(new MigLayout());
		setTitle("IDWTest01");
		setPreferredSize(new Dimension(600, 400));
		setLocation(400, 200);
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

		GradientPanel panel =  new GradientPanel();
		panel.setPreferredSize(new Dimension(1000, 1000));
		panel.setForeground(Color.white);
		panel.setBackground(Color.blue);
//		panel.setFocusable(true);
//		panel.setAutoscrolls(true);
		JScrollPane scroller = new JScrollPane(panel);

		MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
			public void mouseDragged(MouseEvent e) {
				System.out.println("DnDTest01.initUi().new MouseMotionAdapter() {...}.mouseDragged(): ");
				Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
				((JPanel) e.getSource()).scrollRectToVisible(r);
			}
		};
		panel.addMouseMotionListener(doScrollRectToVisible);

		add(scroller);
		pack();
		setVisible(true);
	}
 
Example 58
Project: batmass   File: DisabledPanel.java   Source Code and License 5 votes vote down vote up
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() {
         });
     }
 
Example 59
Project: SE-410-Project   File: DnDTest01.java   Source Code and License 5 votes vote down vote up
private void initUi() {
		setLayout(new MigLayout());
		setTitle("IDWTest01");
		setPreferredSize(new Dimension(600, 400));
		setLocation(400, 200);
		setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

		GradientPanel panel =  new GradientPanel();
		panel.setPreferredSize(new Dimension(1000, 1000));
		panel.setForeground(Color.white);
		panel.setBackground(Color.blue);
//		panel.setFocusable(true);
//		panel.setAutoscrolls(true);
		JScrollPane scroller = new JScrollPane(panel);

		MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
			public void mouseDragged(MouseEvent e) {
				System.out.println("DnDTest01.initUi().new MouseMotionAdapter() {...}.mouseDragged(): ");
				Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
				((JPanel) e.getSource()).scrollRectToVisible(r);
			}
		};
		panel.addMouseMotionListener(doScrollRectToVisible);

		add(scroller);
		pack();
		setVisible(true);
	}
 
Example 60
Project: Juicebox   File: DisabledGlassPane.java   Source Code and License 5 votes vote down vote up
public DisabledGlassPane(int cursor) {
    super();
    //  Set glass pane properties

    setOpaque(false);
    setCursor(Cursor.getPredefinedCursor(cursor));
    Color base = UIManager.getColor("inactiveCaptionBorder");
    Color background = new Color(base.getRed(), base.getGreen(), base.getBlue(), 128);
    setBackground(background);
    setLayout(new GridBagLayout());
    message.setFont(HiCGlobals.font(30, true));
    //  Add a message label to the glass pane

    add(message, new GridBagConstraints());
    message.setOpaque(false);
    Border MESSAGE_BORDER = new EmptyBorder(20, 20, 20, 20);
    message.setBorder(MESSAGE_BORDER);

    //  Disable Mouse, Key and Focus events for the glass pane
    addMouseListener(new MouseAdapter() {
    });
    addMouseMotionListener(new MouseMotionAdapter() {
    });

    addKeyListener(this);

    setFocusTraversalKeysEnabled(false);
}