• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A few GUI questions

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic