我有一个垂直框,我称之为父母。我添加一个JLable,然后添加一个JTextArea。Next接下来,我将创建两个分别称为right和left的垂直Box容器。Next我向它们添加2个JLable,并将这两个Box容器放入一个称为Bot的水平Box中。Bot被添加到我首先创建的父框中这两个标签在中心彼此相邻绘制。第一个是左对齐的,第二个是右对齐的。我希望他们两个都说对了,所以他们不会彼此相邻Box boxParent = Box.createVerticalBox(); String indName="test"; String indDescription="Description"; Box boxTitle = Box.createHorizontalBox(); boxTitle.add(new JLabel(" Indicater:")); boxTitle.add(new JLabel(in dName)); boxParent.add(boxTitle); JTextArea description = new JTextArea(indDescription,5,2); boxParent.add(description); Box bot= Box.createHorizontalBox(); Box right = Box.createVerticalBox(); right.add(new JLabel("right")); right.setAlignmentX(Component.LEFT_ALIGNMENT); Box left = Box.createVerticalBox(); left.setAlignmentX(Component.LEFT_ALIGNMENT); left.add(new JLabel("left")); bot.add(right); bot.add(left); boxParent.add(bot);
1 回答
![?](http://img1.sycdn.imooc.com/5458626a0001503602200220-100-100.jpg)
HUH函数
TA贡献1836条经验 获得超4个赞
我希望他们两个都说对了,所以他们不会彼此相邻。
不确定我是否了解您的要求。他们俩都在同一行,因此无法证明自己是正确的。
如果要在两个组件之间留出空间,则可能需要:
bot.add(right); bot.add(Box.createHorizontalGlue()); bot.add(left);
添加回答
举报
0/150
提交
取消