我需要添加一个简单的间隙/空格/边距,以便在这两个按钮之间留出空间。不幸的是我不能让它工作。谁能给我一些建议?
它基于BorderLayout
,按钮位于JToolBar
我需要添加一个简单的间隙/空格/边距,以便在这两个按钮之间留出空间。不幸的是我不能让它工作。谁能给我一些建议?
它基于BorderLayout
,按钮位于JToolBar
JPanel
包含这些按钮的布局是什么?您可以使用 aBoxLayout
并添加Box.createHorizontalStrut()
到它。
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.add(playButton);
buttonPanel.add(previousButton);
buttonPanel.add(Box.createHorizontalStrut(25));
buttonPanel.add(stopButton);
buttonPanel.add(Box.createHorizontalGlue());