I need to use a JButton with a icon and text. I tried using
JButton btnLogout = new JButton();
ImageIcon icon = new ImageIcon(getClass().getResource("icon.png"));
btnLogout.setIcon(icon);
btnLogout.setText("Logout");
but this gives me a button like
+---------+
|icon|text|
+---------+
but i need the button like
+--------+
| icon |
| Text |
+--------+
How can i do this in java ?