我想尝试使用miglayout,因为它更灵活。 我尝试添加日期和一些按钮,但在使用换行后,按钮之间的差距是库存和事务变得很远,但在事务按钮和添加项按钮之间没问题。MigLayout对齐
这是我的代码:
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月9日15年9月13日
[库存] [交易] [添加项目]基于
请出示演示行为的SSCCE(与你想要达到的目标) – kleopatra