aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes A few GUI questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "A few GUI questions" Watch "A few GUI questions" New topic
Author

A few GUI questions

Dave Johnson
Ranch Hand

Joined: May 25, 2003
Posts: 111
The first question concerns layour managers. Let's say we have a main JPanel with FlowLayout. We then add another JPanel to that main JPanel and its layout is GridLayout. Just one JButton is added to this second JPanel. When the smaller JPanel is added to out main JPanel it sit centre of out main JPanel (vertically speaking). What I would like to know is how I can align the contents of the smaller JPanel so that when added to the main JPanel it sits at the top of the JPanel?
One more question, is it possible to have a JButton with 2 lines of text?
If so can we have 1 line bold and the other in a smaller font?
Thanks, Dave.
[ December 22, 2003: Message edited by: Dave Johnson ]
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
What are you really trying to do. A panel within a panel for 1 button doesn't really make much sense.
For your second question, use html. There was a post within the last week that detailed this.
Dave Johnson
Ranch Hand

Joined: May 25, 2003
Posts: 111
Thanks for your help Paul.
With regards to my first question, a panel within a panel with a single button was maybe an oversimplified example of what I am trying to do. The real example is a panel that has three panels added. One of which will have about 7 buttons in one column. What I would like to do is align the panel to the top of the parent panel.
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
If I have understood what you want try an horizontal Box. The panel that you want aligned with the top of the container should have alignmentY set to 1.


SCJP2. Please Indent your code using UBB Code
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
With regards to my first question, a panel within a panel with a single button was maybe an oversimplified example of what I am trying to do. The real example is a panel that has three panels added. One of which will have about 7 buttons in one column. What I would like to do is align the panel to the top of the parent panel.

Unless I misunderstand what you're doing you shouldn't be using FlowLayout, it just puts the components in a single row, adding rows as needed. BorderLayout is probably the simplest LayoutManager to use for aligning the panel to the top of the parent panel, you can find out how to use it and other LayoutManagers in this tutorial. The visual guide to LayoutManagers will probably help you pick one.
One more question, is it possible to have a JButton with 2 lines of text?
If so can we have 1 line bold and the other in a smaller font?

This tutorial will show you how to do it using HTML.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A few GUI questions
 
Similar Threads
JButton -> Size
unable to remove spaces between buttons(making a calculator)
Question about GUI (with NetBeans IDE)
JButton in JPanel
Only repaints once