List of usage examples for javax.swing JComponent revalidate
public void revalidate()
From source file:Main.java
public static void validate(JComponent c) { c.revalidate(); }
From source file:Main.java
public static void revalidateTree(java.awt.Component c) { if (c instanceof javax.swing.JComponent) { javax.swing.JComponent jc = (javax.swing.JComponent) c; jc.revalidate(); }/*from w ww . j ava 2s . c om*/ if (c instanceof java.awt.Container) { java.awt.Container container = (java.awt.Container) c; for (java.awt.Component component : container.getComponents()) { revalidateTree(component); } } }
From source file:Main.java
/** * Repaints the parent of the given component. If the parent is null, the component itself is repainted. * /* w w w .j a va 2s.c om*/ * @param component The component whose parent will be repainted. */ public static void repaintParent(JComponent component) { // Get the parent of the component. JComponent parentComponent = (JComponent) SwingUtilities.getAncestorOfClass(JComponent.class, component); // Could we find a parent? if (parentComponent != null) { // Repaint the parent. parentComponent.revalidate(); parentComponent.repaint(); } else { // Repaint the component itself. component.revalidate(); component.repaint(); } }
From source file:Main.java
public static void showAsOnlyVisibleChild(JComponent container, Component childToBeMadeVisible) { for (Component child : container.getComponents()) { boolean visible = child.equals(childToBeMadeVisible); child.setVisible(visible);/*from www. j a va 2s . c o m*/ if (visible) { container.getLayout().addLayoutComponent(BorderLayout.CENTER, child); } else { container.getLayout().removeLayoutComponent(child); } child.repaint(); } container.revalidate(); container.repaint(); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java
protected void requestRepaint() { if (!scheduledRepaint) { SwingUtilities.invokeLater(new Runnable() { @Override//w w w . jav a 2s .c o m public void run() { JComponent view = DesktopComponentsHelper.getComposition(content); view.revalidate(); view.repaint(); scheduledRepaint = false; } }); scheduledRepaint = true; } }
From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java
protected JComponent showWindowThisTab(Window window, String caption, String description) { getDialogParams().reset();//from w ww. j ava 2 s .c o m window.setWidth("100%"); window.setHeight("100%"); JComponent layout; if (isMainWindowManager) { layout = (JComponent) tabsPane.getSelectedComponent(); } else { layout = (JComponent) frame.getContentPane().getComponent(0); } WindowBreadCrumbs breadCrumbs = tabs.get(layout); if (breadCrumbs == null) throw new IllegalStateException("BreadCrumbs not found"); Window currentWindow = breadCrumbs.getCurrentWindow(); Window currentWindowFrame = (Window) currentWindow.getFrame(); windowOpenMode.get(currentWindowFrame).setFocusOwner(frame.getFocusOwner()); Set<Map.Entry<Window, Integer>> set = windows.entrySet(); boolean pushed = false; for (Map.Entry<Window, Integer> entry : set) { if (entry.getKey().equals(currentWindow)) { windows.remove(currentWindow); stacks.get(breadCrumbs).push(entry); pushed = true; break; } } if (!pushed) { stacks.get(breadCrumbs).push(new AbstractMap.SimpleEntry<>(currentWindow, null)); } windows.remove(window); layout.remove(DesktopComponentsHelper.getComposition(currentWindow)); JComponent component = DesktopComponentsHelper.getComposition(window); layout.add(component); breadCrumbs.addWindow(window); if (isMainWindowManager) { setActiveWindowCaption(caption, description, tabsPane.getSelectedIndex()); } else { setTopLevelWindowCaption(caption); component.revalidate(); component.repaint(); } return layout; }
From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java
protected void closeWindow(Window window, WindowOpenInfo openInfo) { if (!disableSavingScreenHistory) { screenHistorySupport.saveScreenHistory(window, openInfo.getOpenMode()); }//w w w.j a va 2 s .c o m switch (openInfo.getOpenMode()) { case DIALOG: { JDialog dialog = (JDialog) openInfo.getData(); dialog.setVisible(false); dialog.dispose(); cleanupAfterModalDialogClosed(window); fireListeners(window, tabs.size() != 0); break; } case NEW_TAB: case NEW_WINDOW: { JComponent layout = (JComponent) openInfo.getData(); layout.remove(DesktopComponentsHelper.getComposition(window)); if (isMainWindowManager) { tabsPane.remove(layout); } WindowBreadCrumbs windowBreadCrumbs = tabs.get(layout); if (windowBreadCrumbs != null) { windowBreadCrumbs.clearListeners(); windowBreadCrumbs.removeWindow(); } tabs.remove(layout); stacks.remove(windowBreadCrumbs); fireListeners(window, tabs.size() != 0); if (!isMainWindowManager) { closeFrame(getFrame()); } break; } case THIS_TAB: { JComponent layout = (JComponent) openInfo.getData(); final WindowBreadCrumbs breadCrumbs = tabs.get(layout); if (breadCrumbs == null) throw new IllegalStateException("Unable to close screen: breadCrumbs not found"); breadCrumbs.removeWindow(); Window currentWindow = breadCrumbs.getCurrentWindow(); if (!stacks.get(breadCrumbs).empty()) { Map.Entry<Window, Integer> entry = stacks.get(breadCrumbs).pop(); putToWindowMap(entry.getKey(), entry.getValue()); } JComponent component = DesktopComponentsHelper.getComposition(currentWindow); Window currentWindowFrame = (Window) currentWindow.getFrame(); final java.awt.Component focusedCmp = windowOpenMode.get(currentWindowFrame).getFocusOwner(); if (focusedCmp != null) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { focusedCmp.requestFocus(); } }); } layout.remove(DesktopComponentsHelper.getComposition(window)); if (App.getInstance().getConnection().isConnected()) { layout.add(component); if (isMainWindowManager) { // If user clicked on close button maybe selectedIndex != tabsPane.getSelectedIndex() // Refs #1117 int selectedIndex = 0; while ((selectedIndex < tabs.size()) && (tabsPane.getComponentAt(selectedIndex) != layout)) { selectedIndex++; } if (selectedIndex == tabs.size()) { selectedIndex = tabsPane.getSelectedIndex(); } setActiveWindowCaption(currentWindow.getCaption(), currentWindow.getDescription(), selectedIndex); } else { setTopLevelWindowCaption(currentWindow.getCaption()); component.revalidate(); component.repaint(); } } fireListeners(window, tabs.size() != 0); break; } default: throw new UnsupportedOperationException(); } }