【发布时间】:2016-03-16 12:05:42
【问题描述】:
我有一个 JToolBar,上面有几个 Jbutton,它们在我的程序中充当图标。我想实现一个按钮,当按下它时,会增加工具栏中所有图标的大小。例如:
我在这里创建我的工具栏:
private JToolBar toolBar = new JToolBar();
在这里我创建了一些我的图标:
private JButton openButton = new JButton(am.getToolbarOpenFileAction());
private JButton closeButton = new JButton(am.getToolbarCloseFileAction());
private JButton undoButton = new JButton(am.getToolbarUndoAction());
private JButton redoButton = new JButton (am.getToolbarRedoAction());
private JButton cutButton = new JButton(am.getToolbarEditCutAction());
然后我有一个创建工具栏的方法:
public void createToolbar() throws Exception {
toolBar.setFloatable(false);
toolBar.add(openButton);
toolBar.add(closeButton);
statusButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
statusButton.setFocusable(false);
statusButton.setBorderPainted(false);
statusButton.setContentAreaFilled(false);
statusButton.setText("Status");
statusButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
setCompileStatus(1);
}
但是,无论我做什么,我似乎都找不到改变工具栏中 JButton 大小的方法。有没有人对我如何实现改变按钮大小的方法有任何建议?更改工具栏或按钮本身的大小会更好吗?
提前致谢。
【问题讨论】:
标签: java swing jbutton jtoolbar