• Post Reply Bookmark Topic Watch Topic
  • New Topic

More GUI questions  RSS feed

 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the class I'm working on: TillPanel

This Panel going from top to bottom has a JButton, a JLabel and a JTextArea with a JScrollPane. However when I run this code the JTextArea appears at the top of the panel on the right hand side of the the JButton. This behaviour started when I added the JScrollPane, before it appeared at the bottom as it should. I do the the scrollbars though.
2 more questions to ask while I think on. When creating JButtons I would like to make the text in the button align to the centre of the button rather than to the left. For example: . The 2nd lot of text get bunched up in the left hand corner. The other thing I wanted to do is make the 1st line of text bold and the 2nd non-bold. I have played with this code: but I had no luck.
Thanks, Dave.
[ December 23, 2003: Message edited by: Dave Johnson ]
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You should be setting the layout of the content pane and adding items to the content pane. Use the getContentPane() method.

This Panel going from top to bottom has a JButton, a JLabel and a JTextArea with a JScrollPane. However when I run this code the JTextArea appears at the top of the panel on the right hand side of the the JButton. This behaviour started when I added the JScrollPane, before it appeared at the bottom as it should. I do the the scrollbars though.



You're still using the constraints on the textarea instead of the scrollpane.

When creating JButtons I would like to make the text in the button align to the centre of the button rather than to the left.

Use the <center> tag. It's in the code below as well.

The other thing I wanted to do is make the 1st line of text bold and the 2nd non-bold.


You're setting the button to use a font that is bold to begin with so all text will be bold regardless of the HTML tags. Change it to plain and then use the HTML to specify formatting.
 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that Ken, I really appreciate your help. I have learned a lot about GUI's in the last few days. Thankyou very much!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!