• Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel Question  RSS feed

 
Jeff Boynton
Greenhorn
Posts: 18
Android Chrome Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

So I am working on an ABV calculator for some practice, and one problem I am running into is that I am unable to set a JLabel properly on the top of the window that is created. It will display the text with no problem, but only on one column. Is there a way to center a JLabel across 2 columns? The label I am working with is titleL.

 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simple answer is you can't do it using GridLayout as each component can only be a single cell. But don't despair there are other options, such as:
1. If you're feeling brave you could use GridBagLayout.
2. You could use BorderLayout to split the panel into areas and put your JLabel in the NORTH section (probably in a panel with FlowLayout set to center) and the rest of the components in the CENTER section (in a panel with GridLayout).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!