Solved

Adjusting a size of a JToolBar

Posted on 2003-11-17
7
744 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
InNoCenT_Ch1ld earned 35 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

615 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