java - A button does not move -


when run code, controls button appears on top. want change size of button , place of button. tried use setbounds() method doesn't change anything.

import javax.swing.*; import java.awt.*;    public class gameframe {      public jframe gameframe;     public jpanel panel;     public jbutton b1;     public jlabel lab;      public gameframe()     {         gui();     }      public void gui()     {         gameframe = new jframe("poop man");         gameframe.setvisible(true);         gameframe.setsize(800, 900);         gameframe.setdefaultcloseoperation(jframe.exit_on_close);          panel = new jpanel();          panel.setbackground(color.yellow);          b1 = new jbutton("controls");         b1.setbounds( 300,70,590,300);         //b1.setsize(new rectan          panel.add(b1);           gameframe.add(panel);     }          public static void main(string[] args)         {                 new gameframe();         } } 

after change position or text of button need call repaint() on jframe. make sure button added jframe first.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -