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

The following are Jave code examples for showing how to use doLayout() 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: incubator-netbeans   File: ComponentMorpher2.java   View Source Code Vote up 6 votes
private Image getComponentImage(JComponent component) {
    // Initial component sizing & layout
    component.setSize((getClientSize().width == 0) ? component.getPreferredSize() : getClientSize()); // try to fit the component to ComponentMorpher
    component.doLayout(); // layout component

    // Correct component sizing & layout
    component.setSize(new Dimension(getClientSize().width, component.getPreferredSize().height)); // Width of component is fixed, update height
    component.doLayout(); // layout component

    // One more iteration because of nested JTextAreas
    component.setSize(new Dimension(getClientSize().width, component.getPreferredSize().height)); // Width of component is fixed, update height
    component.doLayout(); // layout component

    // Paint component into BufferedImage
    BufferedImage componentImage = new BufferedImage(component.getSize().width, component.getSize().height,
                                                     BufferedImage.TYPE_INT_RGB);
    component.printAll(componentImage.getGraphics());

    return componentImage;
}
 
Example 2
Project: incubator-netbeans   File: TabLayoutManager.java   View Source Code Vote up 4 votes
final void resizeContainer() {
    JComponent c = ( JComponent ) container.getParent();
    c.invalidate();
    c.revalidate();
    c.doLayout();
}