Java Code Examples for javax.swing.JComponent#setCursor()

The following examples show how to use javax.swing.JComponent#setCursor() . These examples are extracted from open source projects. 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
/**
 * Changes border color, background and mouse cursor for the specified component
 * to indicate that a mouse click will initiate some kind of action.
 */
public static void setHightlight(final JComponent component, final boolean value) {
    if (currentTheme != ThemeFactory.getInstance().getCurrentTheme()) {
        currentTheme = ThemeFactory.getInstance().getCurrentTheme();
        final Color refBG = currentTheme.getColor(Theme.COLOR_TITLE_BACKGROUND);
        BG1 = new Color(refBG.getRed(), refBG.getGreen(), refBG.getBlue(), 200);
        BG2 = new Color(refBG.getRed(), refBG.getGreen(), refBG.getBlue(), 220);
    }
    if (value) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setBorder(BorderFactory.createLineBorder(getRolloverColor(), 2));
        component.setBackground(BG1);
    } else {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        component.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
        component.setBackground(BG2);
    }
}
 
Example 2
Source Project: seaglass   File: SeaGlassTextFieldUI.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void mouseMoved(MouseEvent e) {
    currentMouseX = e.getX();
    currentMouseY = e.getY();
    
    Cursor cursorToUse = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR);
    if (isOverCancelButton() || isOverFindButton()) {
       cursorToUse = Cursor.getDefaultCursor();  
    }
    JComponent c = (JComponent) e.getSource();
    if (!cursorToUse.equals(c.getCursor())) {
        c.setCursor(cursorToUse);
    }
    super.mouseMoved(e);
}
 
Example 3
Source Project: netbeans   File: SummaryCellRenderer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        int i = item.getNextFilesToShowCount();
        String tooltip;
        if (i > 0) {
            tooltip = NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowMoreFiles", i); //NOI18N
        } else {
            tooltip = NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowAllFiles"); //NOI18N
        }
        component.setToolTipText(tooltip);
        return true;
    }
    return false;
}
 
Example 4
private void updateCursor(VertexMouseInfo<V, E> info) {
	if (!isHandlingEvent) {
		return;
	}
	JComponent c = (JComponent) info.getEventSource();
	c.setCursor(info.getCursorForClickedComponent());
}
 
Example 5
public void testProgressCursor () {
    JComponent testTc = new ProgressCursorComp();
    Cursor progressCursor = Utilities.createProgressCursor(testTc);
    testTc.setCursor(progressCursor);
    //testTc.open();
    Cursor compCursor = testTc.getCursor();
    if (!progressCursor.equals(compCursor)) {
        fail("Setting of progress cursor don't work: \n" +
             "Comp cursor: " + compCursor + "\n" +
             "Progress cursor: " + progressCursor);
    }
}
 
Example 6
Source Project: netbeans   File: VCSHyperlinkSupport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved(Point p, JComponent component) {
    for (int i = 0; i < start.length; i++) {
        if (bounds != null && bounds[i] != null && bounds[i].contains(p)) {
            component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            return true;
        }
    }
    return false;
}
 
Example 7
Source Project: netbeans   File: VCSHyperlinkSupport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(NbBundle.getMessage(VCSHyperlinkSupport.class, "LBL_StartChat", author));
        return true;
    }
    return false;
}
 
Example 8
Source Project: netbeans   File: SummaryCellRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved (Point p, JComponent component) {
    for (Map.Entry<Component, Rectangle> e : bounds.entrySet()) {
        if (e.getValue().contains(p)) {
            component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            component.setToolTipText(tooltips.get(e.getKey()));
            return true;
        }
    }
    return false;
}
 
Example 9
Source Project: netbeans   File: SummaryCellRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved (Point p, JComponent component) {
    for (Map.Entry<Component, Rectangle> e : bounds.entrySet()) {
        if (e.getValue().contains(p)) {
            component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            component.setToolTipText((String) labels.get(e.getKey()).getValue(Action.NAME));
            return true;
        }
    }
    return false;
}
 
Example 10
Source Project: netbeans   File: SummaryCellRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        if (item.revisionExpanded) {
            component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_CollapseRevision")); //NOI18N
        } else {
            component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ExpandRevision")); //NOI18N
        }
        return true;
    }
    return false;
}
 
Example 11
Source Project: netbeans   File: SummaryCellRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowActions")); //NOI18N
        return true;
    }
    return false;
}
 
Example 12
Source Project: netbeans   File: SummaryCellRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved(Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowLessFiles")); //NOI18N
        return true;
    }
    return false;
}
 
Example 13
Source Project: netbeans   File: TooltipWindow.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean mouseMoved (Point p, JComponent component) {
    if (bounds != null && bounds.contains(p)) {
        component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        component.setToolTipText(Bundle.CTL_AnnotationBar_action_showCommit(revision));
        return true;
    }
    return false;
}
 
Example 14
Source Project: material-ui-swing   File: MaterialPopupMenuUI.java    License: MIT License 5 votes vote down vote up
@Override
public void uninstallUI(JComponent c) {

	c.setFont (null);
	c.setBackground (null);
	c.setForeground (null);
	c.setBorder (null);
	c.setCursor(null);

	super.uninstallUI(c);
}
 
Example 15
Source Project: material-ui-swing   File: MaterialSliderUI.java    License: MIT License 5 votes vote down vote up
@Override
public void uninstallUI(JComponent c) {

	c.setFont (null);
	c.setBackground (null);
	c.setForeground (null);
	c.setBorder (null);
	c.setCursor(null);

	super.uninstallUI(c);
}
 
Example 16
@Override
public void installUI (JComponent c) {
	super.installUI (c);

	c.setBackground(UIManager.getColor("RadioButtonMenuItem.background"));
	c.setForeground(UIManager.getColor("RadioButtonMenuItem.foreground"));
	c.setBorder(UIManager.getBorder("RadioButtonMenuItem.border"));
	c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example 17
@Override
public void uninstallUI(JComponent c) {

	c.setFont (null);
	c.setBackground (null);
	c.setForeground (null);
	c.setBorder (null);
	c.setCursor(null);

	super.uninstallUI(c);
}
 
Example 18
Source Project: material-ui-swing   File: MaterialSliderUI.java    License: MIT License 5 votes vote down vote up
@Override
public void installUI (JComponent c) {
	super.installUI (c);

	JSlider slider = (JSlider) c;
	slider.setFont (UIManager.getFont ("Slider.font"));
	slider.setBackground (UIManager.getColor ("Slider.background"));
	slider.setForeground (UIManager.getColor ("Slider.foreground"));
	slider.setBorder (UIManager.getBorder ("Slider.border"));
	c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example 19
private void removeLink(JComponent component) {
    this.sourceLink = null;
    component.setEnabled(false);
    component.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    component.setToolTipText("");
}
 
Example 20
Source Project: netbeans   File: ProfilingPoint.java    License: Apache License 2.0 4 votes vote down vote up
public void setCursor(Cursor cursor) {
    super.setCursor(cursor);
    
    JComponent table = lastTable != null ? lastTable.get() : null;
    if (table != null) table.setCursor(cursor);
}