java swing怎么实现如下图片所示的布局,急急急!求大神指导。
展开全部
final JFrame frame = new JFrame("Form Example");
final JButton addButton = new JButton("Add");
final JButton deleteButton = new JButton("Delete");
final JButton modifyButton = new JButton("Modify");
final JButton closeButton = new JButton("Close");
final Box topbox = Box.createHorizontalBox();
final Box bottomBox = Box.createHorizontalBox();
final DefaultTableModel model = new DefaultTableModel();
model.addColumn("\u25A1");
model.addColumn("名称");
model.addColumn("类名称");
model.setRowCount(5);
final JTable classTable = new JTable(model);
topbox.add(Box.createHorizontalStrut(5));
topbox.add(addButton);
topbox.add(Box.createHorizontalStrut(5));
topbox.add(deleteButton);
topbox.add(Box.createHorizontalStrut(5));
topbox.add(modifyButton);
topbox.add(Box.createHorizontalGlue());
topbox.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
bottomBox.add(Box.createHorizontalGlue());
bottomBox.add(closeButton);
bottomBox.add(Box.createHorizontalStrut(5));
bottomBox.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
frame.add(topbox, BorderLayout.PAGE_START);
frame.add(new JScrollPane(classTable));
frame.add(bottomBox, BorderLayout.PAGE_END);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询