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());
  • 相关阅读:
    深入理解DB2缓冲池(BufferPool)
    收银台采坑总结
    webpack4的总结
    无心法师-讲解
    cache 缓存的处理
    用es6方式的写的订阅发布的模式
    Skeleton Screen -- 骨架屏--应用
    promise实现原理
    业务线移动端适配方案总结
    vdom,diff,key 算法的了解
  • 原文地址:https://www.cnblogs.com/ddw1997/p/2334027.html
Copyright © 2011-2022 走看看