Example usage for java.awt Container repaint

List of usage examples for java.awt Container repaint

Introduction

In this page you can find the example usage for java.awt Container repaint.

Prototype

public void repaint() 

Source Link

Document

Repaints this component.

Usage

From source file:Main.java

/**
 * Calls {@link Container#validate()} then {@link Container#repaint()} on
 * the given {@link Container} to fully reload the Container.
 * // www  .j  a  v  a  2 s.c o  m
 * @param c
 *            - the Container to use
 * @see Container#repaint()
 * @see Container#validate()
 */
public static void validate(Container c) {
    c.validate();
    c.repaint();
}

From source file:Main.java

public static void replaceComponent(Container cont, int index, Component comp) {
    cont.remove(index);/*from   w  w  w .  j  ava2 s.  c om*/
    // cont.validate();
    cont.add(comp, index);
    cont.validate();
    cont.repaint();
}

From source file:Main.java

public static void replaceComponent(Container cont, Component comp1, Component comp2, String constraints) {
    int index = -1;
    int i = 0;//from  w ww. jav  a2s  . com
    for (Component comp : cont.getComponents()) {
        if (comp.equals(comp1)) {
            index = i;
            break;
        }
        ++i;
    }
    // cont.setIgnoreRepaint(true);
    cont.remove(comp1);
    cont.add(comp2, constraints, index);
    cont.validate();
    // cont.setIgnoreRepaint(false);
    cont.repaint();
}

From source file:fr.ign.cogit.geoxygene.appli.layer.LayerViewAwtPanel.java

/**
 * Repaint the panel using the repaint method of the super class
 * {@link JPanel}. Called in order to perform the progressive rendering.
 * // w  ww  . j  a va  2s .co m
 * @see #paintComponent(Graphics)
 */
@Override
public final void superRepaint() {
    Container parent = this.getParent();
    if (parent != null) {
        parent.repaint();
    }
}

From source file:org.adempiere.apps.graph.PerformanceIndicator.java

/**
 *    Action Listener./*from   ww w .  j a va 2  s.  c o m*/
 *    Update Display
 *   @param e event
 */
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == mRefresh) {
        m_goal.updateGoal(true);
        updateDisplay();
        //
        Container parent = getParent();
        if (parent != null)
            parent.invalidate();
        invalidate();
        if (parent != null)
            parent.repaint();
        else
            repaint();
    }
}

From source file:net.sf.firemox.clickable.target.card.VirtualCard.java

/**
 * Update the layout of this card, and also generate a new random angle.
 *//*from w ww .jav  a2s  . c om*/
public void updateLayout() {
    // Update the bounds
    if (updateSizes()) {

        // Update the layout
        doLayout();
        Container parent = getParent();
        if (parent != null) {
            parent.doLayout();
            parent = parent.getParent();
            if (parent != null) {
                parent.repaint();
            }
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/** 
 * Lays out the components composing main panel. 
 * /*w w w .  j a v a 2s.com*/
 * @param fromPreferences   Pass <code>true</code> to indicate that the 
 *                      method is invoked while setting the user 
 *                      preferences, <code>false</code> otherwise.
 */
private void layoutComponents(boolean fromPreferences) {
    //initSplitPanes();
    Dimension d;
    int diff;
    Container container = getContentPane();
    container.removeHierarchyBoundsListener(boundsAdapter);
    int width = 0, height = 0;
    JComponent rightComponent;
    //int divider = 0;
    int vExtra = 2;
    int addition;
    switch (displayMode) {
    case RENDERER:
        rightComponent = model.getMetadataViewer().getEditorUI();
        rendererSplit.setRightComponent(rightComponent);
        if (restoreSize == null) {
            rendererSplit.setResizeWeight(1.0);
            return;
        }
        d = model.getMetadataViewer().getIdealRendererSize();
        rightComponent.setMinimumSize(d);
        tabs.setMinimumSize(restoreSize);
        height = restoreSize.height;
        diff = d.height - restoreSize.height;
        if (diff > 0)
            height += diff;
        else
            height += vExtra;
        addition = rendererSplit.getDividerSize() + 2 * (refInsets.left + refInsets.right);

        width = restoreSize.width + d.width;
        width += 4 * addition;
        break;
    case HISTORY:
        container.remove(mainComponent);
        historyUI.doGridLayout();
        addComponents(historySplit, tabs, historyUI);
        mainComponent = historySplit;
        container.add(mainComponent, BorderLayout.CENTER);
        container.validate();
        container.repaint();
        height = restoreSize.height;
        width = restoreSize.width;
        d = historyUI.getIdealSize();
        addition = historySplit.getDividerSize() + 2 * (refInsets.top + refInsets.bottom);
        height += d.height;
        historySplit.setResizeWeight(0.49);
        height += addition;
        break;
    case HISTORY_AND_RENDERER:
        historySplit.setResizeWeight(0.49);
        container.remove(mainComponent);
        historyUI.doGridLayout();
        rightComponent = model.getMetadataViewer().getEditorUI();
        addComponents(rendererSplit, tabs, rightComponent);
        addComponents(historySplit, rendererSplit, historyUI);
        mainComponent = historySplit;
        container.add(mainComponent, BorderLayout.CENTER);
        container.validate();
        container.repaint();

        d = model.getMetadataViewer().getIdealRendererSize();
        height = restoreSize.height;
        diff = d.height - restoreSize.height;
        if (diff > 0)
            height += diff;
        else
            height += vExtra;
        addition = rendererSplit.getDividerSize() + 2 * (refInsets.left + refInsets.right);

        width = restoreSize.width + d.width;
        width += 4 * addition;
        d = historyUI.getPreferredSize();
        addition = historySplit.getDividerSize() + 2 * (refInsets.top + refInsets.bottom);
        height += d.height;
        height += addition;
        break;
    case NEUTRAL:
        rightComponent = model.getMetadataViewer().getEditorUI();
        rendererSplit.remove(rightComponent);
        if (restoreSize == null)
            return;
        width = restoreSize.width;
        height = restoreSize.height;
        break;
    default:
    }
    //rendererSplit.setDividerLocation(-1);
    //rendererSplit.setResizeWeight(1.0);
    //historySplit.setDividerLocation(-1);
    d = getIdealSize(width, height);

    /* Need to review that code.
     * Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int w = (int) (screen.width*SCREEN_RATIO);
    int h = (int) (screen.height*SCREEN_RATIO);
    if (d.width > w || d.height > h) {
       setSize(width, height);
    } else setSize(d);
    */
    setSize(d);
    setPreferredSize(d);
    pack();
    container.addHierarchyBoundsListener(boundsAdapter);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/** Resets the size of the components hosting this component.*/
private void resetComponentSize() {
    Container pane = getComponent(getParent());
    pane.setSize(getPreferredSize());//from www  .  j  a  va  2s  .com
    pane.validate();
    pane.repaint();
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void setActive(boolean mode, StateRenderer2D source) {
    super.setActive(mode, source);
    Container parent = source.getParent();
    while (parent != null && !(parent.getLayout() instanceof BorderLayout))
        parent = parent.getParent();/*from   www .  j  a v a  2  s .c o  m*/
    if (mode) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(slider, BorderLayout.CENTER);
        panel.add(minTimeLabel, BorderLayout.WEST);
        panel.add(maxTimeLabel, BorderLayout.EAST);
        parent.add(panel, BorderLayout.SOUTH);
    } else {
        parent = slider.getParent().getParent();
        parent.remove(slider.getParent());
    }
    parent.invalidate();
    parent.validate();
    parent.repaint();

}