Insets定义了构件离容器四边的最小距离,可是这个距离究竟是因为什么而产生的呢?
Container中并没有setInsets()之类的东东啊?

解决方案 »

  1.   

    直接去new Insets(10, 10, 10, 10)就可以了.
      

  2.   

    new了一个Insets后怎么把它赋值给一个Container对象呢?
    Container类有getInsets()函数,却没有setInsets()啊!
      

  3.   

    getInsets()这个方法是给JVM调用的, 你只需要给JVM一个Insets对象就可以了, 设置工作由它来完成.
      

  4.   

    你为什么不看API doc呢?getInsets
    public Insets getInsets()
    Determines the insets of this container, which indicate the size of the container's border. 
    A Frame object, for example, has a top inset that corresponds to the height of the frame's title bar. 改变insets的方法很多,setMargin是其中一种,setBorder也是Insets其实就是Windows里面的non-client area,我想。例如,JScrollPane的滚动条,应该也是Insets之内的东西。