Example usage for java.awt Component validate

List of usage examples for java.awt Component validate

Introduction

In this page you can find the example usage for java.awt Component validate.

Prototype

public void validate() 

Source Link

Document

Validates this component.

Usage

From source file:Main.java

public static void forceRevalidate(Component comp) {
    comp.invalidate();
    comp.validate();
    comp.repaint();
}

From source file:Main.java

public static void validateTree(java.awt.Component c) {
    c.validate();
    if (c instanceof java.awt.Container) {
        java.awt.Container container = (java.awt.Container) c;
        for (java.awt.Component component : container.getComponents()) {
            validateTree(component);//from www  .jav a  2  s. c  o m
        }
    }
}

From source file:Main.java

/**
 * A simple minded look and feel change: ask each node in the tree
 * to <code>updateUI()</code> -- that is, to initialize its UI property
 * with the current look and feel./*from w w  w  .  j ava  2  s  . co m*/
 *
 * @param c UI component.
 */
public static void updateComponentTreeUI(Component c) {
    updateComponentTreeUI0(c);
    c.invalidate();
    c.validate();
    c.repaint();
}

From source file:Main.java

public static void validate(Component c) {
    if (c instanceof JComponent)
        ((JComponent) c).revalidate();
    else/* ww w  . j a  v  a2  s .com*/
        c.validate();
}

From source file:Main.java

/**
 * Set the look and feel of the specified component to the style of the
 * current system.//w  w w . j  av  a2  s  .c o m
 * 
 * @param c
 *            the specified component
 */
public static void setSystemLookAndFeel(Component c) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        SwingUtilities.updateComponentTreeUI(c);
        c.validate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Use this static method if you want to center a component over another
 * component.//  w w w  .j  a  v a2  s.  c  o m
 *
 * @param parent
 *            the component you want to use to place it on
 * @param toBeCentered
 *            the component you want to center
 */
public static void centerComponentInComponent(Component parent, Component toBeCentered) {
    toBeCentered.setLocation(parent.getX() + (parent.getWidth() - toBeCentered.getWidth()) / 2,
            parent.getY() + (parent.getHeight() - toBeCentered.getHeight()) / 2);

    toBeCentered.validate();
    toBeCentered.repaint();
}

From source file:Main.java

/**
 * Use this static method if you want to center a component in Window.
 *
 * @param component//from   w w  w . j  a  v  a 2 s  .  c  o m
 *            the component you want to center in window
 */
public static void centerComponentInWindow(Component component) {
    Dimension dimension = component.getToolkit().getScreenSize();

    component.setLocation((int) ((dimension.getWidth() - component.getWidth()) / 2),
            (int) ((dimension.getHeight() - component.getHeight()) / 2));
    component.validate();
    component.repaint();
}

From source file:script.imglib.analysis.ChartUtils.java

private static final void layoutComponent(final Component c) {
    synchronized (c.getTreeLock()) {
        c.doLayout();/*from  ww w. j  a v  a  2 s  .  c om*/
        if (c instanceof Container) {
            for (Component child : ((Container) c).getComponents()) {
                layoutComponent(child);
            }
        }
    }
    c.validate();
}

From source file:net.imglib2.script.analysis.ChartUtils.java

private static final void layoutComponent(final Component c) {
    synchronized (c.getTreeLock()) {
        c.doLayout();/*from   w w  w.  ja  va2s  .  c  o m*/
        if (c instanceof Container) {
            for (final Component child : ((Container) c).getComponents()) {
                layoutComponent(child);
            }
        }
    }
    c.validate();
}

From source file:edu.ku.brc.af.prefs.PreferencesDlg.java

/**
 * @param comp//from   w w w. ja  va  2 s  .  c  o  m
 * @param oldSize
 */
protected void showAndResizePane(final Component comp, final Dimension oldSize) {
    mainPanel.remove(currentComp);

    currentComp.setVisible(false);
    mainPanel.add(comp, BorderLayout.CENTER);
    comp.invalidate();
    comp.validate();
    comp.invalidate();
    comp.doLayout();
    comp.repaint();
    doLayout();
    repaint();
    currentComp = comp;
    currentComp.setVisible(true);

    Dimension oldWinDim = getSize();
    Dimension winDim = getSize();
    winDim.width += currentComp.getPreferredSize().width - oldSize.width;
    winDim.width = Math.max(winDim.width, 400);
    winDim.height = Math.max(winDim.height, 250);

    Dimension pSize = prefsToolbar.getPreferredSize();
    winDim.width = Math.max(winDim.width, pSize.width + 30);

    if (winDim.equals(oldWinDim)) // needed because JGoodies doesn't want to relayout when it is the same size.
    {
        winDim.height += 2;
    }
    setSize(winDim);
    currentComp.setSize(new Dimension(currentComp.getPreferredSize().width, oldSize.height));

    // Not sure why this combination works
    mainPanel.invalidate();
    mainPanel.validate();
    mainPanel.invalidate();
    mainPanel.doLayout();
    mainPanel.repaint();

    invalidate();
    validate();
    invalidate();
    doLayout();

    doLayout();
    repaint();
    // to here

    ((PrefsPanelIFace) comp).setShadeColor(null);

    // Without Animation
    comp.setVisible(true);
    winDim.height += currentComp.getPreferredSize().height - oldSize.height;
    winDim.height = Math.max(winDim.height, 250);
    setSize(winDim);
}