This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A few GUI questions

 
Dave Johnson
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ken Blair
Ranch Hand
Posts: 1078
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic