Solved

Adjusting a size of a JToolBar

Posted on 2003-11-17
7
743 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 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 60
hibernate jars 4 45
CSV file parsing thru Java 13 34
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

830 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