Java Code Examples for java.awt.Component#repaint()

The following examples show how to use java.awt.Component#repaint() . 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: JLayeredPane.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
Example 2
Source File: JLayeredPane.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
Example 3
Source File: ValueModelClump.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param g2d
 */
public void paint ( Graphics2D g2d ) {

    RenderingHints rh = g2d.getRenderingHints();
    rh.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    rh.put( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY );
    g2d.setRenderingHints( rh );

    g2d.setColor( Color.black );
    DrawBounds( g2d );

    //  paint valuesliders
    for (Component vms : getComponents()) {
        if ( vms instanceof JPanel ) {
            vms.repaint();
        }
    }

}
 
Example 4
Source File: JLayeredPane.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
Example 5
Source File: JLayeredPane.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
Example 6
Source File: JLayeredPane.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
Example 7
Source File: JLayeredPane.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void addImpl(Component comp, Object constraints, int index) {
    int layer;
    int pos;

    if(constraints instanceof Integer) {
        layer = ((Integer)constraints).intValue();
        setLayer(comp, layer);
    } else
        layer = getLayer(comp);

    pos = insertIndexForLayer(layer, index);
    super.addImpl(comp, constraints, pos);
    comp.validate();
    comp.repaint();
    validateOptimizedDrawing();
}
 
Example 8
Source File: ElementBoxView.java    From SwingBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void forwardUpdate(DocumentEvent.ElementChange ec,
        DocumentEvent e, Shape a, ViewFactory f)
{
    boolean wasValid = isLayoutValid(majorAxis);
    super.forwardUpdate(ec, e, a, f);

    // determine if a repaint is needed
    if (wasValid && (!isLayoutValid(majorAxis)))
    {
        // Repaint is needed because one of the tiled children
        // have changed their span along the major axis. If there
        // is a hosting component and an allocated shape we repaint.
        Component c = getContainer();
        if ((a != null) && (c != null))
        {
            Rectangle alloc = getInsideAllocation(a);
            c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
        }
    }
}
 
Example 9
Source File: TSFrame.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void animateComponent(final Component comp) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            do {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {}
                comp.repaint();
            } while (!done);
        }
    });
    t.start();
}
 
Example 10
Source File: TSFrame.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void animateComponent(final Component comp) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            do {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {}
                comp.repaint();
            } while (!done);
        }
    });
    t.start();
}
 
Example 11
Source File: TSFrame.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void animateComponent(final Component comp) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            do {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {}
                comp.repaint();
            } while (!done);
        }
    });
    t.start();
}
 
Example 12
Source File: PaintNativeOnUpdate.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 13
Source File: TSFrame.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void animateComponent(final Component comp) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            do {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {}
                comp.repaint();
            } while (!done);
        }
    });
    t.start();
}
 
Example 14
Source File: TSFrame.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void animateComponent(final Component comp) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            do {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {}
                comp.repaint();
            } while (!done);
        }
    });
    t.start();
}
 
Example 15
Source File: BrissGUI.java    From Briss-2.0 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void componentResized(ComponentEvent e) {
    previewPanel.revalidate();
    for (Component component : previewPanel.getComponents()) {
        component.repaint();
    }
}
 
Example 16
Source File: TSFrame.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void animateComponent(final Component comp) {
    Thread t = new Thread(new Runnable() {
        public void run() {
            do {
                try {
                    Thread.sleep(50);
                } catch (InterruptedException ex) {}
                comp.repaint();
            } while (!done);
        }
    });
    t.start();
}
 
Example 17
Source File: DropdownButton.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setText(String text) {
    if (button != null) {
        String _text = button.getText();
        button.setText(text);
        
        Component parent = getParent();
        if (!Objects.equals(text, _text) && parent != null) {
            parent.invalidate();
            parent.revalidate();
            parent.repaint();
        }
    }
}
 
Example 18
Source File: GapBoxView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Process pending repaint requests from children.
 * <br>
 * Children are guaranteed to be non-null once this method gets called.
 */
protected void processRepaint(ViewLayoutState.Parent lsParent) {
    if (lsParent != null) { // parent view is ViewLayoutState.Parent
        int firstRepaintChildIndex = children.getFirstRepaintChildIndex();
        double majorAxisOffset = children.getMajorAxisOffset(firstRepaintChildIndex);
        double repaintMajorOffset;
        double repaintMajorSpan;
        float repaintMinorOffset;
        float repaintMinorSpan;
        if (isRepaintTillEnd()
            || firstRepaintChildIndex >= getViewCount() // bit strange but possible after last child remove
        ) {
            if (isMajorAxesOrthogonal()) {
                repaintMajorOffset = 0;
                repaintMajorSpan = 0; // till end of view's span in parent
                repaintMinorOffset = (float)majorAxisOffset;
                repaintMinorSpan = 0; // till parent view minor span end

            } else { // major axes equal
                repaintMajorOffset = majorAxisOffset;
                repaintMajorSpan = 0; // till end of view's span in parent
                repaintMinorOffset = 0;
                repaintMinorSpan = 0; // till parent view minor span end
            }

        } else { // repainting just single child that did not change major axis span
            double majorAxisSpan = getChild(firstRepaintChildIndex).getLayoutMajorAxisPreferredSpan();
            if (isMajorAxesOrthogonal()) {
                repaintMajorOffset = 0;
                repaintMajorSpan = 0; // till end of view's span in parent
                repaintMinorOffset = (float)majorAxisOffset;
                repaintMinorSpan = (float)majorAxisSpan;

            } else { // major axes equal
                repaintMajorOffset = majorAxisOffset;
                repaintMajorSpan = majorAxisSpan;
                repaintMinorOffset = 0;
                repaintMinorSpan = 0; // till parent view minor span end
            }
        }
        
        lsParent.repaint(this, repaintMajorOffset, repaintMajorSpan,
            repaintMinorOffset, repaintMinorSpan);
        
    } else { // do not know allocation here => repaint whole component
        Component c = getContainer();
        if (c != null) {
            c.repaint();
        }
    }
}
 
Example 19
Source File: MapControls.java    From freecol with GNU General Public License v2.0 4 votes vote down vote up
public void repaint() {
    for (Component c : getComponentsToRemove()) {
        c.repaint();
    }
}
 
Example 20
Source File: ToggleButtonListener.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void focusGained(FocusEvent e) {
	Component c = (Component) e.getSource();
	c.repaint();
}