Java Code Examples for javax.swing.JToolTip#getPreferredSize()

The following examples show how to use javax.swing.JToolTip#getPreferredSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TooltipImageTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkSize(JToolTip tip, int width, int height) {
   Dimension d = tip.getPreferredSize();
   Insets insets = tip.getInsets();
   //6 seems to be the extra width being allocated for some reason
   //for a tooltip window.
   if (!((d.width - insets.right - insets.left - 6) == width) &&
       !((d.height - insets.top - insets.bottom) == height)) {
       throw new RuntimeException("Test case fails: Expected width, height is " + width + ", " + height +
               " whereas actual width, height are " + (d.width - insets.right - insets.left - 6) + " " +
               (d.height - insets.top - insets.bottom));
   }
}
 
Example 2
Source File: TooltipImageTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkSize(JToolTip tip, int width, int height) {
   Dimension d = tip.getPreferredSize();
   Insets insets = tip.getInsets();
   //6 seems to be the extra width being allocated for some reason
   //for a tooltip window.
   if (!((d.width - insets.right - insets.left - 6) == width) &&
       !((d.height - insets.top - insets.bottom) == height)) {
       throw new RuntimeException("Test case fails: Expected width, height is " + width + ", " + height +
               " whereas actual width, height are " + (d.width - insets.right - insets.left - 6) + " " +
               (d.height - insets.top - insets.bottom));
   }
}
 
Example 3
Source File: TooltipImageTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void checkSize(JToolTip tip, int width, int height) {
   Dimension d = tip.getPreferredSize();
   Insets insets = tip.getInsets();
   //6 seems to be the extra width being allocated for some reason
   //for a tooltip window.
   if (!((d.width - insets.right - insets.left - 6) == width) &&
       !((d.height - insets.top - insets.bottom) == height)) {
       throw new RuntimeException("Test case fails: Expected width, height is " + width + ", " + height +
               " whereas actual width, height are " + (d.width - insets.right - insets.left - 6) + " " +
               (d.height - insets.top - insets.bottom));
   }
}
 
Example 4
Source File: FlashingIcon.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Point getToolTipLocation( MouseEvent event ) {

    JToolTip tip = createToolTip();
    tip.setTipText( getToolTipText() );
    Dimension d = tip.getPreferredSize();
    
    
    Point retValue = new Point( getWidth()-d.width, -d.height );
    return retValue;
}
 
Example 5
Source File: FlashingIcon.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Point getToolTipLocation(MouseEvent event) {

    JToolTip tip = createToolTip();
    tip.setTipText(getToolTipText());
    Dimension d = tip.getPreferredSize();


    Point retValue = new Point(getWidth() - d.width, -d.height);
    return retValue;
}
 
Example 6
Source File: FlashingIcon.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Point getToolTipLocation( MouseEvent event ) {

    JToolTip tip = createToolTip();
    tip.setTipText( getToolTipText() );
    Dimension d = tip.getPreferredSize();
    
    
    Point retValue = new Point( getWidth()-d.width, -d.height );
    return retValue;
}
 
Example 7
Source File: IOLocationTileList.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public Point getToolTipLocation(MouseEvent event) {
	if (event != null) {
		Point p = event.getPoint();
		int index = locationToIndex(p);
		ListCellRenderer r = getCellRenderer();
		Rectangle cellBounds;

		if (index != -1 && (r instanceof BasicTileCellRenderer)
				&& (cellBounds = getCellBounds(index, index)) != null
				&& cellBounds.contains(p.x, p.y)) {
			String text = getToolTipText(event);
			JToolTip tip = new JToolTip();
			tip.setTipText(text);
			Dimension tipSize = tip.getPreferredSize();
			BasicTileCellRenderer btcr = (BasicTileCellRenderer) r;

			int yOffset = cellBounds.height / 2;
			if (btcr.thumbnail.getUI() instanceof ThumbnailLabelUI) {
				ThumbnailLabelUI ui = (ThumbnailLabelUI) btcr.thumbnail
						.getUI();
				yOffset = ui.getTextRect().y;
			}
			return new Point(cellBounds.x + cellBounds.width / 2
					- tipSize.width / 2, cellBounds.y + yOffset);
		}
	}
	return super.getToolTipLocation(event);
}
 
Example 8
Source File: TooltipImageTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void checkSize(JToolTip tip, int width, int height) {
   Dimension d = tip.getPreferredSize();
   Insets insets = tip.getInsets();
   //6 seems to be the extra width being allocated for some reason
   //for a tooltip window.
   if (!((d.width - insets.right - insets.left - 6) == width) &&
       !((d.height - insets.top - insets.bottom) == height)) {
       throw new RuntimeException("Test case fails: Expected width, height is " + width + ", " + height +
               " whereas actual width, height are " + (d.width - insets.right - insets.left - 6) + " " +
               (d.height - insets.top - insets.bottom));
   }
}