This has been undermining me for a while. If I define setTextin JButton before the definition setAction, the text disappears:
JButton test = new JButton();
test.setText("test");
test.setAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
}
});
this.add(test);
If after, no problem.
JButton test = new JButton();
test.setAction(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
}
});
test.setText("test");
this.add(test);
Also, if I set the text in the JButton constructor, this is great! Yarghh!
Why is this happening?
source
share