java.awt.Container#validate ( )源码实例Demo

下面列出了java.awt.Container#validate ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lizzie   文件: BasicLizziePaneUI.java
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();
  }
}
 
源代码2 项目: org.alloytools.alloy   文件: GraphViewer.java
/** 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();
    }
}
 
源代码3 项目: ramus   文件: Handler.java
/**
 * 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();
}
 
源代码4 项目: stendhal   文件: InternalWindow.java
/**
 * 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);
	}
}
 
源代码5 项目: Briss-2.0   文件: WrapLayout.java
/**
 * 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();
    }
}
 
private static void revalidateParents(Container container) {
    while (container != null) {
        container.invalidate();
        container.validate();
        container.repaint();
        container = container.getParent();
    }
}
 
private static void revalidateParents(Container container) {
    while (container != null) {
        container.invalidate();
        container.validate();
        container.repaint();
        container = container.getParent();
    }
}
 
源代码8 项目: ghidra   文件: AbstractTaskInfo.java
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();
		}
	}
}
 
源代码9 项目: arcusplatform   文件: FormView.java
private void repaint() {
   this.panel.invalidate();
   Container parent = this.panel.getParent();
   if(parent != null) {
      parent.validate();
      parent.repaint();
   }
}
 
源代码10 项目: ramus   文件: Handler.java
/**
 * 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();
}
 
源代码11 项目: ramus   文件: Handler.java
/**
 * 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();
    }
}
 
源代码12 项目: Logisim   文件: Frame.java
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();
}
 
源代码13 项目: flutter-intellij   文件: FlutterSettingsStep.java
@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);
}
 
源代码14 项目: flutter-intellij   文件: FlutterSettingsStep.java
@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);
}
 
源代码15 项目: Spark   文件: GroupChatInvitationUI.java
/**
 * 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();
    }

}
 
源代码16 项目: osp   文件: TextPanel.java
/**
 * 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);
  }
}
 
源代码17 项目: lizzie   文件: BasicLizziePaneUI.java
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();
  }
}
 
源代码18 项目: pdfxtk   文件: JWindowToolBarUI.java
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();
   }
 }