【发布时间】:2013-12-26 03:37:39
【问题描述】:
我想尝试使用 miglayout,因为它更灵活。 我尝试添加日期和一些按钮,但是在我使用 wrap 之后,按钮之间的差距是库存和交易变得很远,但交易按钮和添加项目按钮之间是可以的。
这是我的代码:
top = new JPanel();
top.setLayout(new MigLayout("","",""));
center = new JPanel();
bottom = new JPanel();
right = new JPanel();
left = new JPanel();
inventory = new JButton("Inventory");
transaction = new JButton("Transaction");
addItem = new JButton("Add Item");
date = new Date();
dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
dateTime = new JLabel(dateFormat.format(date));
top.add(dateTime,"wrap");
dateTime.setBorder(BorderFactory.createLineBorder(Color.red));
top.add(inventory);
inventory.setBorder(BorderFactory.createLineBorder(Color.red));
top.add(transaction);
transaction.setBorder(BorderFactory.createLineBorder(Color.red));
top.add(addItem);
addItem.setBorder(BorderFactory.createLineBorder(Color.red));
add(top,BorderLayout.NORTH);
显示:
---------------------------------------------- 2013/12/09 13.09.15
[库存] [交易] [添加项目]
【问题讨论】:
-
请展示一个展示行为的SSCCE(与您想要实现的目标相比)