File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Caption with awt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Caption with awt" Watch "Caption with awt" New topic
Author

Caption with awt

Soum Sark
Ranch Hand

Joined: May 31, 2002
Posts: 50
Hi how do i create a caption with Panels or Frames.
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
what do you mean? could you be more specific?
Soum Sark
Ranch Hand

Joined: May 31, 2002
Posts: 50
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

Joined: Oct 18, 2000
Posts: 4121

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 ]

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
jQuery in Action, 2nd edition
 
subject: Caption with awt
 
Similar Threads
eclipse plugin file dialog
This is begging for a caption
Remove URL from the title
Customizing View Title Area
When people complain about the curtailment of freedom of speech