?
Solved

Adjusting a size of a JToolBar

Posted on 2003-11-17
7
Medium Priority
?
745 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:simple21
  • 5
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
InNoCenT_Ch1ld earned 140 total points
ID: 9769337
setFloatable(false);

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

Expert Comment

by:Tols
ID: 9769338
Do not change the layout of JToolBar, it has it's own layout alocating components properly.
0
 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
ID: 9769353
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
ID: 9769358
Tols is rite..
0
 
LVL 2

Expert Comment

by:Tols
ID: 9769511
;-)
0
 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
ID: 9784008
Please close the question.
0
 
LVL 3

Expert Comment

by:InNoCenT_Ch1ld
ID: 9828938
;-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question