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

The following examples show how to use javax.swing.JComponent#setCursor() . 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: MagicStyle.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 File: SeaGlassTextFieldUI.java    From seaglass with 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 File: SummaryCellRenderer.java    From netbeans with 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
Source File: SummaryCellRenderer.java    From netbeans with 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 5
Source File: MaterialSliderUI.java    From material-ui-swing with 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 6
Source File: MaterialRadioButtonMenuItemUI.java    From material-ui-swing with 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 7
Source File: MaterialRadioButtonMenuItemUI.java    From material-ui-swing with MIT License 5 votes vote down vote up
@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 8
Source File: MaterialSliderUI.java    From material-ui-swing with 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 9
Source File: MaterialPopupMenuUI.java    From material-ui-swing with 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 10
Source File: TooltipWindow.java    From netbeans with 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 11
Source File: SummaryCellRenderer.java    From netbeans with 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 12
Source File: SummaryCellRenderer.java    From netbeans with 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 13
Source File: VisualGraphEventForwardingGraphMousePlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void updateCursor(VertexMouseInfo<V, E> info) {
	if (!isHandlingEvent) {
		return;
	}
	JComponent c = (JComponent) info.getEventSource();
	c.setCursor(info.getCursorForClickedComponent());
}
 
Example 14
Source File: SummaryCellRenderer.java    From netbeans with 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 15
Source File: SummaryCellRenderer.java    From netbeans with 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 16
Source File: VCSHyperlinkSupport.java    From netbeans with 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 17
Source File: VCSHyperlinkSupport.java    From netbeans with 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 18
Source File: UtilitiesProgressCursorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 19
Source File: ProfilingPoint.java    From netbeans with 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);
}
 
Example 20
Source File: MainFrameComponentFactory.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void removeLink(JComponent component) {
    this.sourceLink = null;
    component.setEnabled(false);
    component.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    component.setToolTipText("");
}