Java Code Examples for javax.swing.JComponent.repaint()

The following are Jave code examples for showing how to use repaint() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: VASSAL-src   File: MenuScroller.java   View Source Code Vote up 5 votes
private void refreshMenu() {
  if (menuItems != null && menuItems.length > 0) {
    firstIndex = Math.max(topFixedCount, firstIndex);
    firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

    upItem.setEnabled(firstIndex > topFixedCount);
    downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

    menu.removeAll();
    for (int i = 0; i < topFixedCount; i++) {
      menu.add(menuItems[i]);
    }
    if (topFixedCount > 0) {
      menu.addSeparator();
    }

    menu.add(upItem);
    for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
      menu.add(menuItems[i]);
    }
    menu.add(downItem);

    if (bottomFixedCount > 0) {
      menu.addSeparator();
    }
    for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
      menu.add(menuItems[i]);
    }

    JComponent parent = (JComponent) upItem.getParent();
    parent.revalidate();
    parent.repaint();
  }
}
 
Example 2
Project: Equella   File: FlatterCheckBoxUI.java   View Source Code Vote up 5 votes
@Override
public synchronized void mousePressed(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	if( c.isEnabled() )
	{
		c.setForeground(mTextPressed);
		c.setBackground(mBackgroundPressed);
		c.repaint();
	}
}
 
Example 3
Project: Equella   File: FlatterCheckBoxUI.java   View Source Code Vote up 5 votes
@Override
public synchronized void mouseReleased(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	c.setForeground(mTextNormal);
	c.setBackground(mBackgroundNormal);
	c.repaint();
}
 
Example 4
Project: Equella   File: FlatterCheckBoxUI.java   View Source Code Vote up 5 votes
@Override
public synchronized void mouseEntered(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	if( c.isEnabled() )
	{
		c.setForeground(mTextActive);
		c.setBackground(mBackgroundActive);
		c.repaint();
	}
}
 
Example 5
Project: Equella   File: FlatterCheckBoxUI.java   View Source Code Vote up 5 votes
@Override
public synchronized void mouseExited(MouseEvent e)
{
	JComponent c = (JComponent) e.getComponent();
	c.setForeground(mTextNormal);
	c.setBackground(mBackgroundNormal);
	c.repaint();
}
 
Example 6
Project: jaer   File: MenuScroller.java   View Source Code Vote up 5 votes
private void refreshMenu() {
  if (menuItems != null && menuItems.length > 0) {
    firstIndex = Math.max(topFixedCount, firstIndex);
    firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

    upItem.setEnabled(firstIndex > topFixedCount);
    downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

    menu.removeAll();
    for (int i = 0; i < topFixedCount; i++) {
      menu.add(menuItems[i]);
    }
    if (topFixedCount > 0) {
      menu.add(new JSeparator());
    }

    menu.add(upItem);
    for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
      menu.add(menuItems[i]);
    }
    menu.add(downItem);

    if (bottomFixedCount > 0) {
      menu.add(new JSeparator());
    }
    for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
      menu.add(menuItems[i]);
    }

    JComponent parent = (JComponent) upItem.getParent();
    parent.revalidate();
    parent.repaint();
  }
}
 
Example 7
Project: Cognizant-Intelligent-Test-Scripter   File: MenuScroller.java   View Source Code Vote up 5 votes
private void refreshMenu() {
    if (menuItems != null && menuItems.length > 0) {
        firstIndex = Math.max(topFixedCount, firstIndex);
        firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);

        upItem.setEnabled(firstIndex > topFixedCount);
        downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);

        menu.removeAll();
        for (int i = 0; i < topFixedCount; i++) {
            menu.add(menuItems[i]);
        }
        if (topFixedCount > 0) {
            menu.addSeparator();
        }

        menu.add(upItem);
        for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
            menu.add(menuItems[i]);
        }
        menu.add(downItem);

        if (bottomFixedCount > 0) {
            menu.addSeparator();
        }
        for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
            menu.add(menuItems[i]);
        }

        JComponent parent = (JComponent) upItem.getParent();
        parent.revalidate();
        parent.repaint();
    }
}
 
Example 8
Project: incubator-netbeans   File: ViewUtils.java   View Source Code Vote up 4 votes
public static void repaint(JComponent component, Rectangle2D r) {
    component.repaint((int)r.getX(), (int)r.getY(), (int)r.getWidth(), (int)r.getHeight());
}