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

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

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

Window.invalidate介绍

暂无

代码示例

代码示例来源: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: com.metsci.glimpse/glimpse-platform-fixes

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

代码示例来源:origin: com.jtattoo/JTattoo

public void windowDeactivated(WindowEvent e) {
    e.getWindow().invalidate();
    e.getWindow().repaint();
  }
} // end class MyWindowHandler

代码示例来源:origin: com.jtattoo/JTattoo

public void windowActivated(WindowEvent e) {
  e.getWindow().invalidate();
  e.getWindow().repaint();
}

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

parentWindow.invalidate();
parentWindow.validate();
parentWindow.repaint();

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

parentWindow.invalidate();
parentWindow.validate();
parentWindow.repaint();

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

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: stackoverflow.com

@Override
public void paint(Graphics g)
{
  checkResizeWindow(this);
  super.paint(g);
}

public static void checkResizeWindow(Window window)
{
  if (!window.isShowing())
  {
    return;
  }
  Component[] components = window.getComponents();
  if (components.length == 0)
  {
    return;
  }
  Component comp = components[0];
  Insets insets = window.getInsets();
  Dimension innerSize = window.getSize();
  innerSize.width -= insets.left + insets.right;
  innerSize.height -= insets.top + insets.bottom;
  if (!innerSize.equals(comp.getSize()))
  {
    window.invalidate();
    window.validate();
  }
}

代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea

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.nuiton/nuiton-widgets

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: com.fifesoft/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: com.fifesoft/autocomplete

@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: com.fifesoft.rtext/fife.common

window.invalidate();
window.validate();
origPos.setLocation(newPos);

相关文章

Window类方法