java - Add space between label and jButton on a tabbed pane header -


enter image description here

as can see in image above, i've tabbed pane. on tab header i've jlabel (tab test) , jbutton (x). placed next each other want them have small gap natural.

i've tried box has same background has text making not natural well. box has no setborders method.

here's how box:

enter image description here

here's code:

        system.out.println("newtableevent!!!!");         final string tittle = table.gettabname();          jbutton jbuttonclose = new jbutton("x");         jbuttonclose.setborderpainted(false);         jbuttonclose.setborder(null);          jpanel tabcomponent = new jpanel(new borderlayout());         tabcomponent.add(new jlabel(tittle), borderlayout.west);         tabcomponent.settooltiptext("close tab.");         component box = box.createrigidarea(new dimension(25,0));         tabcomponent.add(box, borderlayout.center);         tabcomponent.add(jbuttonclose, borderlayout.east);   //        righttabbedpane.addtab(null, table.gettable());         righttabbedpane.addtab(null, new jpanel());          // total tabs         final int totaltabs = righttabbedpane.getcomponentcount();         system.out.println("total tabs: " + totaltabs);          // set custom tab component         righttabbedpane.settabcomponentat(0, tabcomponent); 

so, how can make space jlabel , jbutton , keep background distance neutral?

i wasn't able test it, believe have tell box not opaque before add tabcomponent:

box.setopaque(false); 

hopefully, should work you.

edit

you may able set borders around label , button accomplish this:

jlabel label = new jlabel(tittle); tabcomponent.add(label); //add more space between label , button label.setborder(borderfactory.createemptyborder(0, 0, 0, 5)); tabcomponent.add(jbuttonclose); 

demo at: http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -