i have put a jtextfield at the menubar by using createHorizontalGlue() to make the jtextfield at the right most part of my menubar
it appears at the right most part of my menubar but the width of that jtextfield doesn't changes
i try to make it shorter but that is not working can you have any other method to solve my problem
all i need is my jtextfield should have 30 columns but now it have more than 100 columns and strange thing is i m unable to change this size by invoking any methods.
Nitin Surana wrote:Which layout manager are you using? We need to have a look at your code, in order to figure out what is going wrong.
its a big project and lot of code so i cant put the code here
but as far as layout is concern i guess menu bar uses box layout isn't it ?
and i m adding jtextfield to menu bar
when ever i put textfield in jscrollpane it appears at the right hand side but with a long width
but if i remove jscrollpane and just add the jtextfield into menu bar the white area appears till help menu or sometimes overlap help menu
but my search word inside search textfield remain at the right most part of menubar
you can do one thing :
put your jtextfield within a JPanel, now that JPanel is the one which will have large size, but that won't be visible and then you can control the layout of JPanel and hence you can control the size of the jtextfield.
you have to add a JToolBar.Separator
try this code before you add the textField and the "search" jButton
yourMenuBar.add(new JToolBar.Separator(new Dimension(int here the length of the separating area,0));