【发布时间】:2017-05-30 08:13:39
【问题描述】:
我需要使用带有图标和文本的 JButton。我尝试使用
JButton btnLogout = new JButton();
ImageIcon icon = new ImageIcon(getClass().getResource("icon.png"));
btnLogout.setIcon(icon);
btnLogout.setText("Logout");
但这给了我一个像
这样的按钮+---------+
|icon|text|
+---------+
但我需要像这样的按钮
+--------+
| icon |
| Text |
+--------+
我如何在 java 中做到这一点?
【问题讨论】: