I'm getting some trouble with a toolbar I made. In this I have 4 JButtons
and below a JTable
, which is set on focus when my windows shows in order to see the JButtons
unfilled.
This is how I set each JButton
:
btn = new JButton("New");
btn.setFocusPainted(false);
btn.setBackground(SystemColor.window);
btn.setVerticalTextPosition(SwingConstants.BOTTOM);
btn.setHorizontalTextPosition(SwingConstants.CENTER);
btn.addActionListener(new ActionListener() {
...
});
btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
toolBar_General.add(btn);
btn.setIcon(new ImageIcon(MainWindow.class.getResource("/icons/file11.png")));
Example of my toolbar at start: http://www.tiikoni.com/tis/view/?id=0ef950b
But after clicking on a JButton
, it remains filled after itsactionListener
does his work.
Example of my toolbar after clicking a JButton
: http://www.tiikoni.com/tis/view/?id=9e88ea4
My question is: how can I mantain my buttons contentAreaFilled
property true
(so the user can tab between components in my window and see which control he has selected) and unfocus my button after the user click?
The result I would like to have is that of the first photo.