zoukankan      html  css  js  c++  java
  • getPreferredSize()、setPreferredSize()、getSize()、setSize()、revalidate()、pack()

    有时候对容器内的组件期望尺寸信息进行了改变setPreferredSize(),却没有立即看到效果,

    那可能是由于布局管理器缓存了布局信息,这时候我们就需要使布局失效,迫使他在下一次

    重绘的时候重新计算排列容器内的组件。比较常用的方法是调用组件的方法revalidate ,这
    样会使调用该方法的组件与该组件外层的所有容器都标记为需要重新布局。

    1 /**
    2 * Causes this component to be sized to fit the preferred size.
    3 */
    4 public function pack():void
    5 {
    6    setSize(getPreferredSize());
    7 }
     1 /**
     2 * layout this container
     3 */
     4 public function doLayout():void
     5 {
     6    if(isVisible())
     7    {
     8       layout.layoutContainer(this);
     9    }
    10 }
     1 UIManager.setLookAndFeel(new MusicLookAndFeel(getSkinProxy()));
     2 AsWingUtils.updateChildrenUI(app); 
     3 
     4 //Component.getUI().getPreferredSize(Component);
     5 //Component.getPreferredSize();
     6 //Component.setSize(new IntDimension(w, h));
     7 Container.pack();
     8 Container.setSize(new IntDimension(w, h));
     9 Container.doLayout();
    10 Container.revalidate();
    11 trace (Container.getPaintBounds(), Container.getSize(), Container.getPreferredSize());
  • 相关阅读:
    [SDOI2017]新生舞会
    [SCOI2007]最大土地面积
    [JLOI2014]松鼠的新家
    [AHOI2009]中国象棋
    【转载】树链剖分.By.Xminh
    HGOI20180904(NOIP2018模拟sxn出题)
    HGOI20180831 NOIP2018模拟
    【字符串算法1】 再谈字符串Hash(优雅的暴力)
    【字符串算法2】浅谈Manacher算法
    【字符串算法3】浅谈KMP算法
  • 原文地址:https://www.cnblogs.com/ddw1997/p/2334027.html
Copyright © 2011-2022 走看看