java.awt.Window.validate()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中java.awt.Window.validate()方法的一些代码示例,展示了Window.validate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.validate()方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:validate

Window.validate介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

/** Tries to resize wizard wisely if needed. Keeps "display inertia" so that
 * wizard is only enlarged, not shrinked, and location is changed only when
 * wizard window exceeds screen bounds after resize.
 */
private void resizeWizard(Window parentWindow, Dimension prevSize) {
  assert SwingUtilities.isEventDispatchThread () : "getComponent() must be called in EQ only.";
  Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize();
  // only enlarge if needed, don't shrink
  if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) {
    Rectangle origBounds = parentWindow.getBounds();
    int newWidth = Math.max(origBounds.width + (curSize.width - prevSize.width), origBounds.width);
    int newHeight = Math.max(origBounds.height + (curSize.height - prevSize.height), origBounds.height);
    Rectangle screenBounds = Utilities.getUsableScreenBounds();
    Rectangle newBounds;
    // don't allow to exceed screen size, center if needed
    if (((origBounds.x + newWidth) > screenBounds.width) || ((origBounds.y + newHeight) > screenBounds.height)) {
      newWidth = Math.min(screenBounds.width, newWidth);
      newHeight = Math.min(screenBounds.height, newHeight);
      newBounds = Utilities.findCenterBounds(new Dimension(newWidth, newHeight));
    } else {
      newBounds = new Rectangle(origBounds.x, origBounds.y, newWidth, newHeight);
    }
    parentWindow.setBounds(newBounds);
    parentWindow.invalidate();
    parentWindow.validate();
    parentWindow.repaint();
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

@Override
public void mouseDragged(MouseEvent e) {
  Point newPos = e.getPoint();
  SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
  int xDelta = newPos.x - origPos.x;
  int yDelta = newPos.y - origPos.y;
  Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
  if (wind!=null) { // Should always be true
    if (getComponentOrientation().isLeftToRight()) {
      int w = wind.getWidth();
      if (newPos.x>=wind.getX()) {
        w += xDelta;
      }
      int h = wind.getHeight();
      if (newPos.y>=wind.getY()) {
        h += yDelta;
      }
      wind.setSize(w,h);
    }
    else { // RTL
      int newW = Math.max(1, wind.getWidth()-xDelta);
      int newH = Math.max(1, wind.getHeight()+yDelta);
      wind.setBounds(newPos.x, wind.getY(), newW, newH);
    }
    // invalidate()/validate() needed pre-1.6.
    wind.invalidate();
    wind.validate();
  }
  origPos.setLocation(newPos);
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

/** validates a detached dockable, regardless of its type (frame or dialog) */
public static void validate(FloatingDockableContainer fdc) { //2006/02/20
  ((Window) fdc).validate();
}

代码示例来源:origin: com.metsci.glimpse/glimpse-platform-fixes

public void run( )
  {
    Window window = findWindow( hwnd );
    if ( window != null )
    {
      window.invalidate( );
      window.validate( );
    }
  }
} );

代码示例来源:origin: stackoverflow.com

Window window = SwingUtilities.getWindowAncestor(popupMenu);
 window.pack();
 window.validate();

代码示例来源:origin: stackoverflow.com

// Create a window for full-screen mode; add a button to leave full-screen mode
Frame frame = new Frame(gs.getDefaultConfiguration());
Window win = new Window(frame);
Canvas c = new Canvas();
c.setBackground(Color.RED);
win.add(c);
win.show();  //or setVisible(true);

// Enter full-screen mode
gs.setFullScreenWindow(win);
win.validate();

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

/**
 * {@inheritDoc}
 */
public void mouseReleased(MouseEvent e) {
  validPress = !SwingUtilities.isLeftMouseButton(e);
  window.validate();
  window.setCursor(null);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

public void mouseReleased(MouseEvent ev)
{
  if (dragCursor != 0 && window != null && !window.isValid())
  {
    // Some Window systems validate as you resize, others won't,
    // thus the check for validity before repainting.
    window.validate();
    getRootPane().repaint();
  }
  isMovingWindow = false;
  dragCursor = 0;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * {@inheritDoc}
 */
@Override
public void mouseReleased(MouseEvent e) {
  validPress = !SwingUtilities.isLeftMouseButton(e);
  window.validate();
  window.setCursor(null);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * {@inheritDoc}
 */
@Override
public void mouseReleased(MouseEvent e) {
  validPress = !SwingUtilities.isLeftMouseButton(e);
  window.validate();
  window.setCursor(null);
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
 * {@inheritDoc}
 */
@Override
public void mouseReleased(MouseEvent e) {
  validPress = !SwingUtilities.isLeftMouseButton(e);
  window.validate();
  window.setCursor(null);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

public void mouseReleased(MouseEvent ev) {
  if (dragCursor != 0 && window != null && !window.isValid()) {
    // Some Window systems validate as you resize, others won't,
    // thus the check for validity before repainting.
    window.validate();
    getRootPane().repaint();
  }
  isMovingWindow = false;
  dragCursor = 0;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
 * {@inheritDoc}
 */
@Override
public void mouseReleased(MouseEvent e) {
  validPress = !SwingUtilities.isLeftMouseButton(e);
  window.validate();
  window.setCursor(null);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf

public void mouseReleased(MouseEvent ev) {
 if (dragCursor != 0 && window != null && !window.isValid()) {
  // Some Window systems validate as you resize, others won't,
  // thus the check for validity before repainting.
  window.validate();
  getRootPane().repaint();
 }
 isMovingWindow = false;
 dragCursor = 0;
}

代码示例来源:origin: khuxtable/seaglass

/**
 * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
 */
public void mouseReleased(MouseEvent ev) {
  if (dragCursor != 0 && window != null && !window.isValid()) {
    // Some Window systems validate as you resize, others won't,
    // thus the check for validity before repainting.
    window.validate();
    getRootPane().repaint();
  }
  isMovingWindow = false;
  dragCursor     = 0;
}

代码示例来源:origin: org.java.net.substance/substance

public void mouseReleased(MouseEvent ev) {
  if ((this.dragCursor != 0)
      && (SubstanceRootPaneUI.this.window != null)
      && !SubstanceRootPaneUI.this.window.isValid()) {
    // Some Window systems validate as you resize, others won't,
    // thus the check for validity before repainting.
    SubstanceRootPaneUI.this.window.validate();
    SubstanceRootPaneUI.this.getRootPane().repaint();
  }
  this.isMovingWindow = false;
  this.dragCursor = 0;
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
public void mouseReleased(MouseEvent ev) {
  if ((this.dragCursor != 0)
      && (SubstanceRootPaneUI.this.window != null)
      && !SubstanceRootPaneUI.this.window.isValid()) {
    // Some Window systems validate as you resize, others won't,
    // thus the check for validity before repainting.
    SubstanceRootPaneUI.this.window.validate();
    SubstanceRootPaneUI.this.getRootPane().repaint();
  }
  this.isMovingWindow = false;
  this.dragCursor = 0;
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

public void actionPerformed(ActionEvent ae) {
    Dimension contentSize = null;
    if (w instanceof JDialog) {
      contentSize = ((JDialog)w).getContentPane().getSize();
    } else {
      contentSize = ((JFrame)w).getContentPane().getSize();
    }
    Dimension dialogSize = w.getSize();
    int ydiff = dialogSize.height - contentSize.height;
    Dimension paneSize = pane.getSize();
    w.setSize(new Dimension(dialogSize.width, paneSize.height + ydiff));
    w.validate();
    w.repaint();
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
  public void actionPerformed(ActionEvent ae) {
    Dimension contentSize = null;
    if (w instanceof JDialog) {
      contentSize = ((JDialog)w).getContentPane().getSize();
    } else {
      contentSize = ((JFrame)w).getContentPane().getSize();
    }
    Dimension dialogSize = w.getSize();
    int ydiff = dialogSize.height - contentSize.height;
    Dimension paneSize = pane.getSize();
    w.setSize(new Dimension(dialogSize.width, paneSize.height + ydiff));
    w.validate();
    w.repaint();
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
  public void actionPerformed(ActionEvent ae) {
    Dimension contentSize = null;
    if (w instanceof JDialog) {
      contentSize = ((JDialog)w).getContentPane().getSize();
    } else {
      contentSize = ((JFrame)w).getContentPane().getSize();
    }
    Dimension dialogSize = w.getSize();
    int ydiff = dialogSize.height - contentSize.height;
    Dimension paneSize = pane.getSize();
    w.setSize(new Dimension(dialogSize.width, paneSize.height + ydiff));
    w.validate();
    w.repaint();
  }
}

相关文章

Window类方法