Example usage for java.awt Container doLayout

List of usage examples for java.awt Container doLayout

Introduction

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

Prototype

public void doLayout() 

Source Link

Document

Causes this container to lay out its components.

Usage

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   ww w.j  a  v  a2  s.c  o  m*/
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.eclipse.wb.internal.swing.utils.SwingImageUtils.java

private static void fetchMenuVisualData_JMenu_JPopupMenu(MenuVisualData menuData, Container menuObject)
        throws Exception {
    JPopupMenu popupMenu = menuObject instanceof JPopupMenu ? (JPopupMenu) menuObject
            : ((JMenu) menuObject).getPopupMenu();
    // image/*from w  w w  .  j  a v  a  2s. c o  m*/
    {
        prepareForPrinting(popupMenu);
        // OSX Java since jdk 1.6.0_20 requires menu invoker to be visible.
        // traverse parents until null or already visible and make sure that all are visible.
        // CHECK: it could flash on Windows.
        Point parentLocation = null;
        Component parent = popupMenu.getInvoker();
        while (parent != null && !parent.isShowing()) {
            Container parent2 = parent.getParent();
            if (parent2 != null) {
                parent = parent2;
            } else {
                break;
            }
        }
        if (parent != null) {
            parentLocation = parent.getLocation();
            prepareForPrinting(parent);
        }
        // fetch image
        try {
            Container popupMenuParent = popupMenu.getParent();
            if (popupMenuParent != null) {
                popupMenuParent.doLayout();
            }
            popupMenu.doLayout();
            menuData.m_menuImage = createComponentShot(popupMenu);
        } finally {
            setVisible(popupMenu, false);
            if (parent != null) {
                parent.setLocation(parentLocation);
                if (parent instanceof JPopupMenu) {
                    setVisible(parent, false);
                }
            }
        }
    }
    // bounds
    {
        org.eclipse.swt.graphics.Rectangle imageBounds = menuData.m_menuImage.getBounds();
        menuData.m_menuBounds = new Rectangle(0, 0, imageBounds.width, imageBounds.height);
    }
    // items
    fetchMenuVisualData_items(menuData, popupMenu);
}

From source file:org.sikuli.ide.SikuliIDE.java

private void initSikuliIDE(String[] args) {
    prefs = PreferencesUser.getInstance();
    if (prefs.getUserType() < 0) {
        prefs.setUserType(PreferencesUser.NEWBEE);
        prefs.setIdeSession("");
        prefs.setDefaults(prefs.getUserType());
    }// w  w w.jav a  2  s .  c o  m

    ResourceLoader.get().check(Settings.SIKULI_LIB);

    _windowSize = prefs.getIdeSize();
    _windowLocation = prefs.getIdeLocation();
    Screen m = (Screen) (new Location(_windowLocation)).getScreen();
    if (m == null) {
        String em = "Remembered window not valid.\nGoing to primary screen";
        log(-1, em);
        Sikulix.popError(em, "IDE has problems ...");
        m = Screen.getPrimaryScreen();
        _windowSize.width = 0;
    }
    Rectangle s = m.getBounds();
    if (_windowSize.width == 0 || _windowSize.width > s.width || _windowSize.height > s.height) {
        if (s.width < 1025) {
            _windowSize = new Dimension(1024, 700);
            _windowLocation = new Point(0, 0);
        } else {
            _windowSize = new Dimension(s.width - 150, s.height - 100);
            _windowLocation = new Point(75, 0);
        }
    }
    setSize(_windowSize);
    setLocation(_windowLocation);

    Debug.log(3, "IDE: Adding components to window");
    initMenuBars(this);
    final Container c = getContentPane();
    c.setLayout(new BorderLayout());
    Debug.log(3, "IDE: creating tabbed editor");
    initTabPane();
    Debug.log(3, "IDE: creating message area");
    initMsgPane(prefs.getPrefMoreMessage() == PreferencesUser.HORIZONTAL);
    // RaiMan not used      initSidePane(); // IDE UnitTest

    Debug.log(3, "IDE: creating combined work window");
    JPanel codeAndUnitPane = new JPanel(new BorderLayout(10, 10));
    codeAndUnitPane.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
    codeAndUnitPane.add(tabPane, BorderLayout.CENTER);
    // RaiMan not used      codeAndUnitPane.add(_sidePane, BorderLayout.EAST);
    if (prefs.getPrefMoreMessage() == PreferencesUser.VERTICAL) {
        _mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, codeAndUnitPane, msgPane);
    } else {
        _mainSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, codeAndUnitPane, msgPane);
    }
    _mainSplitPane.setResizeWeight(0.6);
    _mainSplitPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    Debug.log(3, "IDE: Putting all together");
    JPanel editPane = new JPanel(new BorderLayout(0, 0));

    JComponent cp = createCommandPane();

    if (PreferencesUser.getInstance().getPrefMoreCommandBar()) {
        editPane.add(cp, BorderLayout.WEST);
    }

    editPane.add(_mainSplitPane, BorderLayout.CENTER);
    c.add(editPane, BorderLayout.CENTER);

    JToolBar tb = initToolbar();
    c.add(tb, BorderLayout.NORTH); // the buttons

    c.add(initStatusbar(), BorderLayout.SOUTH);
    c.doLayout();

    initShortcutKeys();
    initHotkeys();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    initWindowListener();
    initTooltip();

    autoCheckUpdate();

    _inited = true;
    try {
        getCurrentCodePane().requestFocus();
    } catch (Exception e) {
    }

    restoreSession(0);
    if (tabPane.getTabCount() == 0) {
        (new FileAction()).doNew(null);
    }
    tabPane.setSelectedIndex(0);

    Debug.log(3, "Sikuli-IDE startup: " + ((new Date()).getTime() - start));
    setVisible(true);
    _mainSplitPane.setDividerLocation(0.6);
    return; // as breakpoint
}