以下是代码和屏幕。
JPanel tableListPanel = new JPanel(new BorderLayout(5, 5));
tableListPanel.setPreferredSize(new Dimension(150, 100));
tableListPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5),
BorderFactory.createTitledBorder("Added Tables")));
PosButton btnRemoveTable = new PosButton("REMOVE");
// code to add lable.
tableListPanel.add(new JLable("Test")):
答案 0 :(得分:0)
更改此行:
tableListPanel.add(new JLabel("Test")):
有关:
tableListPanel.add(new JLabel("Test"), BorderLayout.WEST):
//You can also use BorderLayout.EAST, BorderLayout.NORTH or BorderLayout.SOUTH
<强>编辑:强>
也可能想要更改此功能(仅当第一次更改无法自行完成时):
JPanel tableListPanel = new JPanel(new BorderLayout(5, 5));
有关:
JPanel tableListPanel = new JPanel(new BorderLayout());
EDITED 10/03/2017:
为JLabel更改了JLable。