Adjusting a size of a JToolBar

Hello;

I have a problem, I want my JButtons on my JToolBar to stay the same in size but when I tried to maximize
my JFrame my buttons became more bigger too. I dont want my JButtons to become bigger, I want it to be
the same even if the JFrame is resized.

Here is what I used and did not worked :

-----------------------------------------

JToolBar x1 = new JToolBar();

JButtons y1 = new JButton("N");
JButtons y2 = new JButton("O");
JButtons y3 = new JButton("S");

x1.setLayout(new GridLayout(1,3));
x1.add(y1);
x1.add(y2);
x1.add(y3);

this.getContentPane.add(x1, BorderLayout.NORTH);

---------------------------------------

Also last thing is there any methods or way so that my JToolBar would not be floatable,
because if I tried to drag the JToolBar it floats outside the frame.

Thanks, Mwah :0
simple21Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

InNoCenT_Ch1ldCommented:
setFloatable(false);

i think so... i think i read it somewhere..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TolsCommented:
Do not change the layout of JToolBar, it has it's own layout alocating components properly.
0
InNoCenT_Ch1ldCommented:
try use another LayoutManager for your toolbar, try null..

x1.setLayout(null);

y1.setBounds(new Rectangle(0, 0, 20, 20,));
x1.add(y1);

y2.setBounds(new Rectangle(20, 0, 20, 20,));
x1.add(y2);

y3.setBounds(new Rectangle(40, 0, 20, 20,));
x1.add(y3);

not really a good way(i guess), but should be able to do the trick

0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

InNoCenT_Ch1ldCommented:
Tols is rite..
0
TolsCommented:
;-)
0
InNoCenT_Ch1ldCommented:
Please close the question.
0
InNoCenT_Ch1ldCommented:
;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.