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

Popular posts from this blog

html - height not adding height to a empty div -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

python - Robot Framework location and name of keyword -