Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes basic swing layout problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "basic swing layout problem." Watch "basic swing layout problem." New topic
Author

basic swing layout problem.

Fernando Lopez Jr.
Greenhorn

Joined: Mar 29, 2006
Posts: 17
how do i get my button to be 22 in height and use all width available to it? also i would like to align my label to the left...


Thank you.


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Check out http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Fernando Lopez Jr.
Greenhorn

Joined: Mar 29, 2006
Posts: 17


i've been reading that... but i just cant get it to work... so i will appreciate if you help me tweaking my code...

thank you.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

You should set the preferred with of the button to be 22:
That will not guarantee a height of 22, but you won't get any closer.

As for the width, that completely depends on the layout manager used. I can't help you out with BoxLayout since I've never used that, but a BorderLayout should work:
Fernando Lopez Jr.
Greenhorn

Joined: Mar 29, 2006
Posts: 17
i went with another layout manager... MiG Layout...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Fernando Lopez Jr. wrote:i went with another layout manager... MiG Layout...

Why the rolling eyes? MiG is also a good layout manager. Nobody said you have to stick to the layout managers provided in the JSE API. I myself use JGoodies Forms most of the time.
Fernando Lopez Jr.
Greenhorn

Joined: Mar 29, 2006
Posts: 17
the rolling eyes were because i was learning the default layout system... and then i had to switch to something "better?"... well anyways can you point me the pros of JGoodies? or a JGoodies vs MiG Layout thread/url? and maybe your personal point of view?


thank you.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

I'm too biased, since I've never worked with MiG. I just never bothered since JGoodies always did what I needed.
 
wood burning stoves
 
subject: basic swing layout problem.
 
Similar Threads
Do you Trust Friday Code?
2D Array Help
Box.createGlue() creates nothing
gui
Problem with custom painting and multiple JPanel