Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caption with awt

 
Soum Sark
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi how do i create a caption with Panels or Frames.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean? could you be more specific?
 
Soum Sark
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kind of like this.
----- Question 1 of 8 ------------------------
| ______________________________________ |
| | | |
| | This is a TextAre | |
| |_____________________________________| |
|____________________________________________|

the outer border with rectangle kind of and with a caption 'Question # of #' . All the dotted lines will be continuous though (can't do it here in text. Hope you get it this time
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, you mean like TitledBorder... unfortunately, components having borders was introduced in Swing, so you'll have to do this yourself by overriding the paint( Graphics ) method of Panel and paint the border on the component yourself. To figure out how big the caption should be you'll have to use the FontMetrics class to get the dimensions of the String... you'll also have to mess with setInsets() and getInsets() to make sure and put enough space around the component to draw the border correctly...
[ August 02, 2002: Message edited by: Nathan Pruett ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic