java - JPanel disappearing when changing the text of a JButton added to it -
i add jbutton jpanel subclass quiz, , if change either text or font of button, quiz object disappears, showing panel underneath it. however, if change text or font before adding button, works fine.
setupgraphics() gets called after quiz added view hierarchy
public void setupgraphics() { this.setbackground(color.red); setlayout(null); a.setbounds(20, 20, 200, 200); add(a); a.settext("hi"); }
if change code this:
public void setupgraphics() { this.setbackground(color.red); setlayout(null); a.setbounds(20, 20, 200, 200); a.settext("hi"); add(a); }
then works.
any ideas?
add(a); a.settext("hi"); --> adding button panel , setting text. that's y not displaying text. second setting text , other attributes , adding button panel.
Comments
Post a Comment