Java Code Examples for java.awt.Container#validate()
The following examples show how to use
java.awt.Container#validate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WrapLayout.java From Briss-2.0 with GNU General Public License v3.0 | 6 votes |
/** * Layout the components in the Container using the layout logic of the parent * FlowLayout class. * * @param target the Container using this WrapLayout */ @Override public final void layoutContainer(final Container target) { Dimension size = preferredLayoutSize(target); // When a frame is minimized or maximized the preferred size of the // Container is assumed not to change. Therefore we need to force a // validate() to make sure that space, if available, is allocated to // the panel using a WrapLayout. if (size.equals(preferredLayoutSize)) { super.layoutContainer(target); } else { preferredLayoutSize = size; Container top = target; while (!(top instanceof Window) && top.getParent() != null) { top = top.getParent(); } top.validate(); } }
Example 2
Source File: InternalWindow.java From stendhal with GNU General Public License v2.0 | 6 votes |
/** * Close the window. Either deletes or hides it, according to the policy * set with {@link #setHideOnClose}. */ public void close() { if (hideOnClose) { setVisible(false); } else { Container parent = InternalWindow.this.getParent(); if (parent != null) { parent.remove(InternalWindow.this); parent.validate(); parent.repaint(); } } // notify listeners for (CloseListener listener : closeListeners) { listener.windowClosed(this); } }
Example 3
Source File: BasicLizziePaneUI.java From lizzie with GNU General Public License v3.0 | 6 votes |
public void windowClosing(WindowEvent w) { if (lizziePane.isFloatable()) { if (dragWindow != null) dragWindow.setVisible(false); floating = false; if (floatingLizziePane == null) floatingLizziePane = createFloatingWindow(lizziePane); if (floatingLizziePane instanceof Window) ((Window) floatingLizziePane).setVisible(false); floatingLizziePane.getContentPane().remove(lizziePane); String constraint = constraintBeforeFloating; if (dockingSource == null) dockingSource = lizziePane.getParent(); if (propertyListener != null) UIManager.removePropertyChangeListener(propertyListener); dockingSource.add(lizziePane, constraint); dockingSource.invalidate(); Container dockingSourceParent = dockingSource.getParent(); if (dockingSourceParent != null) dockingSourceParent.validate(); dockingSource.repaint(); } }
Example 4
Source File: GraphViewer.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** Repaint this component. */ public void alloyRepaint() { Container c = getParent(); while (c != null) { if (c instanceof JViewport) break; else c = c.getParent(); } setSize((int) (graph.getTotalWidth() * scale), (int) (graph.getTotalHeight() * scale)); if (c != null) { c.invalidate(); c.repaint(); c.validate(); } else { invalidate(); repaint(); validate(); } }
Example 5
Source File: Handler.java From ramus with GNU General Public License v3.0 | 6 votes |
/** * Docks the associated toolbar at the secified edge and indicies. */ public void dockToolBar(final int edge, final int row, final int index) { final Container target = ourDockLayout.getTargetContainer(); if (target == null) return; target.remove(ourToolBar); final JDialog floatFrame = getFloatingFrame(); if (floatFrame != null) { floatFrame.setVisible(false); floatFrame.getContentPane().remove(ourToolBar); } ourConstraints.setEdge(edge); ourConstraints.setRow(row); ourConstraints.setIndex(index); target.add(ourToolBar, ourConstraints); ourToolBarShouldFloat = false; target.validate(); target.repaint(); }
Example 6
Source File: Handler.java From ramus with GNU General Public License v3.0 | 5 votes |
/** * Floats the associated toolbar at the specified screen location, * optionally centering the floating frame on this point. */ public void floatToolBar(int x, int y, final boolean center) { final JDialog floatFrame = getFloatingFrame(); if (floatFrame == null) return; final Container target = ourDockLayout.getTargetContainer(); if (target != null) target.remove(ourToolBar); floatFrame.setVisible(false); floatFrame.getContentPane().remove(ourToolBar); ourToolBar.setOrientation(ToolBarLayout.HORIZONTAL); floatFrame.getContentPane().add(ourToolBar, BorderLayout.CENTER); floatFrame.pack(); if (center) { x -= floatFrame.getWidth() / 2; y -= floatFrame.getHeight() / 2; } // x and y are given relative to screen floatFrame.setLocation(x, y); floatFrame.setTitle(ourToolBar.getName()); floatFrame.setVisible(true); ourToolBarShouldFloat = true; if (target != null) { target.validate(); target.repaint(); } }
Example 7
Source File: TextPanel.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Sets the text. * * The position is ignored if the location is set to a corner. * * @param _text */ public void setText(String _text) { _text = TeXParser.parseTeX(_text); if(text==_text) { return; } text = _text; if(text==null) { text = ""; //$NON-NLS-1$ } final Container c = this.getParent(); if(c==null) { return; } Runnable runner = new Runnable() { public synchronized void run() { if(c.getLayout() instanceof OSPLayout) { ((OSPLayout) c.getLayout()).quickLayout(c, TextPanel.this); repaint(); } else { c.validate(); } } }; if(SwingUtilities.isEventDispatchThread()) { runner.run(); } else { SwingUtilities.invokeLater(runner); } }
Example 8
Source File: GroupChatInvitationUI.java From Spark with Apache License 2.0 | 5 votes |
/** * Removes this interface from it's parent. */ private void removeUI() { final Container par = getParent(); if (par != null) { par.remove(this); par.invalidate(); par.validate(); par.repaint(); } }
Example 9
Source File: FlutterSettingsStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onWizardStarting(@NotNull ModelWizard.Facade wizard) { FlutterProjectModel model = getModel(); myKotlinCheckBox.setText(FlutterBundle.message("module.wizard.language.name_kotlin")); mySwiftCheckBox.setText(FlutterBundle.message("module.wizard.language.name_swift")); myBindings.bindTwoWay(new SelectedProperty(myUseAndroidxCheckBox), getModel().useAndroidX()); TextProperty packageNameText = new TextProperty(myPackageName); Expression<String> computedPackageName = new DomainToPackageExpression(model.companyDomain(), model.projectName()) { @Override public String get() { return super.get().replaceAll("_", ""); } }; BoolProperty isPackageSynced = new BoolValueProperty(true); myBindings.bind(packageNameText, computedPackageName, isPackageSynced); myBindings.bind(model.packageName(), packageNameText); myListeners.listen(packageNameText, value -> isPackageSynced.set(value.equals(computedPackageName.get()))); // The wizard changed substantially in 3.5. Something causes this page to not get properly validated // after it is added to the Swing tree. Here we check that we have to validate the tree, then do so. // It only needs to be done once, so we remove the listener to prevent possible flicker. focusListener = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); Container parent = myRoot; while (parent != null && !(parent instanceof JBLayeredPane)) { parent = parent.getParent(); } if (parent != null) { parent.validate(); } myPackageName.removeFocusListener(focusListener); } }; myPackageName.addFocusListener(focusListener); }
Example 10
Source File: FlutterSettingsStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onWizardStarting(@NotNull ModelWizard.Facade wizard) { FlutterProjectModel model = getModel(); myKotlinCheckBox.setText(FlutterBundle.message("module.wizard.language.name_kotlin")); mySwiftCheckBox.setText(FlutterBundle.message("module.wizard.language.name_swift")); myBindings.bindTwoWay(new SelectedProperty(myUseAndroidxCheckBox), getModel().useAndroidX()); TextProperty packageNameText = new TextProperty(myPackageName); Expression<String> computedPackageName = new DomainToPackageExpression(model.companyDomain(), model.projectName()) { @Override public String get() { return super.get().replaceAll("_", ""); } }; BoolProperty isPackageSynced = new BoolValueProperty(true); myBindings.bind(packageNameText, computedPackageName, isPackageSynced); myBindings.bind(model.packageName(), packageNameText); myListeners.listen(packageNameText, value -> isPackageSynced.set(value.equals(computedPackageName.get()))); // The wizard changed substantially in 3.5. Something causes this page to not get properly validated // after it is added to the Swing tree. Here we check that we have to validate the tree, then do so. // It only needs to be done once, so we remove the listener to prevent possible flicker. focusListener = new FocusAdapter() { @Override public void focusGained(FocusEvent e) { super.focusGained(e); Container parent = myRoot; while (parent != null && !(parent instanceof JBLayeredPane)) { parent = parent.getParent(); } if (parent != null) { parent.validate(); } myPackageName.removeFocusListener(focusListener); } }; myPackageName.addFocusListener(focusListener); }
Example 11
Source File: Frame.java From Logisim with GNU General Public License v3.0 | 5 votes |
private void placeToolbar() { String loc = AppPreferences.TOOLBAR_PLACEMENT.get(); Container contents = getContentPane(); contents.remove(toolbar); mainPanelSuper.remove(toolbar); if (AppPreferences.TOOLBAR_HIDDEN.equals(loc)) { ; // don't place value anywhere } else if (AppPreferences.TOOLBAR_DOWN_MIDDLE.equals(loc)) { toolbar.setOrientation(Toolbar.VERTICAL); mainPanelSuper.add(toolbar, BorderLayout.WEST); } else { // it is a BorderLayout constant Object value = BorderLayout.NORTH; for (Direction dir : Direction.cardinals) { if (dir.toString().equals(loc)) { if (dir == Direction.EAST) value = BorderLayout.EAST; else if (dir == Direction.SOUTH) value = BorderLayout.SOUTH; else if (dir == Direction.WEST) value = BorderLayout.WEST; else value = BorderLayout.NORTH; } } contents.add(toolbar, value); boolean vertical = value == BorderLayout.WEST || value == BorderLayout.EAST; toolbar.setOrientation(vertical ? Toolbar.VERTICAL : Toolbar.HORIZONTAL); } contents.validate(); }
Example 12
Source File: KTrussControllerTopComponent.java From constellation with Apache License 2.0 | 5 votes |
private static void revalidateParents(Container container) { while (container != null) { container.invalidate(); container.validate(); container.repaint(); container = container.getParent(); } }
Example 13
Source File: Handler.java From ramus with GNU General Public License v3.0 | 5 votes |
/** * Hides the associated toolbar by removing it from its dock or by closing * its client floating frame. */ public void hideToolBar() { final Container target = ourDockLayout.getTargetContainer(); target.remove(ourToolBar); final JDialog floatFrame = getFloatingFrame(); if (floatFrame != null) { floatFrame.setVisible(false); floatFrame.getContentPane().remove(ourToolBar); } target.validate(); target.repaint(); }
Example 14
Source File: FormView.java From arcusplatform with Apache License 2.0 | 5 votes |
private void repaint() { this.panel.invalidate(); Container parent = this.panel.getParent(); if(parent != null) { parent.validate(); parent.repaint(); } }
Example 15
Source File: AbstractTaskInfo.java From ghidra with Apache License 2.0 | 5 votes |
public void setScrollFraction(float fraction) { component.setHiddenViewAmount(fraction); component.invalidate(); Container parent = component.getParent(); if (parent != null) { Container grandParent = parent.getParent(); if (grandParent != null) { grandParent.validate(); } } }
Example 16
Source File: HierarchicalControllerTopComponent.java From constellation with Apache License 2.0 | 5 votes |
private static void revalidateParents(Container container) { while (container != null) { container.invalidate(); container.validate(); container.repaint(); container = container.getParent(); } }
Example 17
Source File: BasicLizziePaneUI.java From lizzie with GNU General Public License v3.0 | 4 votes |
public void setFloating(boolean b, Point p) { if (lizziePane.isFloatable()) { boolean visible = false; Window ancestor = SwingUtilities.getWindowAncestor(lizziePane); if (ancestor != null) { visible = ancestor.isVisible(); } if (dragWindow != null) dragWindow.setVisible(false); this.floating = b; if (floatingLizziePane == null) { floatingLizziePane = createFloatingWindow(lizziePane); } if (b == true) { if (dockingSource == null) { dockingSource = lizziePane.getParent(); dockingSource.remove(lizziePane); } constraintBeforeFloating = calculateConstraint(); if (propertyListener != null) UIManager.addPropertyChangeListener(propertyListener); floatingLizziePane.getContentPane().add(lizziePane, BorderLayout.CENTER); if (floatingLizziePane instanceof Window) { ((Window) floatingLizziePane).pack(); ((Window) floatingLizziePane).setLocation(floatingX, floatingY); Insets insets = ((Window) floatingLizziePane).getInsets(); Dimension d = new Dimension( originSize.width + insets.left + insets.right, originSize.height + insets.top + insets.bottom); ((Window) floatingLizziePane).setSize(d); if (visible) { ((Window) floatingLizziePane).setVisible(true); } else { ancestor.addWindowListener( new WindowAdapter() { public void windowOpened(WindowEvent e) { ((Window) floatingLizziePane).setVisible(true); } }); } } } else { if (floatingLizziePane == null) floatingLizziePane = createFloatingWindow(lizziePane); if (floatingLizziePane instanceof Window) ((Window) floatingLizziePane).setVisible(false); floatingLizziePane.getContentPane().remove(lizziePane); String constraint = getDockingConstraint(dockingSource, p); if (constraint != null) { if (dockingSource == null) dockingSource = lizziePane.getParent(); if (propertyListener != null) UIManager.removePropertyChangeListener(propertyListener); dockingSource.add(constraint, lizziePane); } } dockingSource.invalidate(); Container dockingSourceParent = dockingSource.getParent(); if (dockingSourceParent != null) dockingSourceParent.validate(); dockingSource.repaint(); } }
Example 18
Source File: JWindowToolBarUI.java From pdfxtk with Apache License 2.0 | 4 votes |
public void setFloating(boolean b, Point p) { if (toolBar.isFloatable() == true) { if (dragWindow != null) dragWindow.setVisible(false); this.floating = b; if (b == true) { if (dockingSource == null) { dockingSource = toolBar.getParent(); dockingSource.remove(toolBar); } if ( propertyListener != null ) UIManager.addPropertyChangeListener( propertyListener ); if (floatingFrame == null) floatingFrame = _createFloatingFrame(toolBar); floatingFrame.getContentPane().add(toolBar,BorderLayout.CENTER); floatingFrame.pack(); floatingFrame.setLocation(floatingX, floatingY); floatingFrame.show(); } else { if (floatingFrame == null) floatingFrame = _createFloatingFrame(toolBar); floatingFrame.setVisible(false); floatingFrame.getContentPane().remove(toolBar); String constraint = getDockingConstraint(dockingSource, p); int orientation = mapConstraintToOrientation(constraint); setOrientation(orientation); if (dockingSource== null) dockingSource = toolBar.getParent(); if ( propertyListener != null ) UIManager.removePropertyChangeListener( propertyListener ); dockingSource.add(constraint, toolBar); } dockingSource.invalidate(); Container dockingSourceParent = dockingSource.getParent(); if (dockingSourceParent != null) dockingSourceParent.validate(); dockingSource.repaint(); } }