java - How to overlay a Jbutton over a JprogressBar -


i'm working on swing gui, , i'd overlay button on progressbar. have wrote code update progress bar , button event, don't know how manage layout!

currently panel code following:

public static void main(string[] args) throws ioexception {          jframe myframe = new jframe("myjftitle");         myframe.setlayout(new borderlayout());         jpanel mypanel = new jpanel();         jbutton mybutton = new jbutton("click me");         jprogressbar mybar = new jprogressbar();         mybar.setvalue(50);         mypanel.add(mybutton);         mypanel.add(mybar);         myframe.add(mypanel,borderlayout.center);         myframe.setvisible(true); } 

which gives following result:

enter image description here

i'm trying unsuccesfully obtain this:

enter image description here

can explain me kind of layout (or whatever) should use, or link me same reference can read how it??

update:

by adding following code, managed overly 2 components, m still not able enlarge progress bar fit panel size:

layoutmanager overlay = new overlaylayout(mypanel); mypanel.setlayout(overlay); 

try this:

public class test {     public static void main(string[] args) throws ioexception {          jframe myframe = new jframe("myjftitle");         myframe.setlayout(new borderlayout());         jbutton mybutton = new jbutton("click me");         mybutton.setalignmentx(component.center_alignment);         jprogressbar mybar = new jprogressbar();         layoutmanager overlay = new overlaylayout(mybar);         mybar.setlayout(overlay);         mybar.setvalue(50);         mybar.add(mybutton);         myframe.add(mybar, borderlayout.center);         myframe.pack();         myframe.setsize(new dimension(300,100));         myframe.setvisible(true);     } } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -