作者TonyQ (骨头)
看板java
标题Re: [J2SE] Layout的选择
时间Tue Mar 27 10:16:12 2007
※ 引述《bypang (第一次上ptt)》之铭言:
: 各位大大好
: 小弟最近在学习java,然而却卡在layout上
: 我想要把JLabel分布在一个panel上(label的size大小固定)
: 一个row可容纳8个label,每个label按照顺序,
: 有点类似Nautilus或My Computer的排序
: 如图(x代表JLabel)
: ______________________
: | x x x x x x x |
: | x x x x x x x |
: | x |
: | |
: | |
: | |
: | |
: | |
: |_____________________|
: 如果使用GridLayout,会变成
: ______________________
: | |
: | x x x x x x x |
: | |
: | |
: | x x x x x x x |
: | |
: | |
: | x |
: |_____________________|
: 请问要怎麽修改,还是要选择其他的layout?
: 谢谢
忘记有没有更简单的作法了
很少用Java的Layout - -a
我所想到最简单的解法
假设你的panel是container
在container上叠加一个subpanel(JPanel),
采用GirdLayout并设定好大小(setBound),再叠到你显示的大panel上。
container layout设null ;
container.add(subpanel);
--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.134.27.68