Michelle Baxter

Greenhorn
+ Follow
since Jun 09, 2000
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michelle Baxter

Given a rectangle of some arbitrary size, I need to create a Shape that represents a string that will fit inside the rectangle. I've read some things about TextLayout and GlyphVector which say that I can get a Shape object that represents the outline of my text. However, it seems to create these things, I need a Font. That leads to specifying a font size, and possibly to getting a FontRenderContext. But at the time I'm setting up the text, I don't have a Graphics2D object at my disposal, so all the stuff about LineMetrics and sizing is not available. Does anyone have an idea about how to do this? I think I'm in over my head.
22 years ago
Take a look at the examples that discuss setting the cell renderers. I did something similar by setting the cell renderer to a text area. Then you can iterate through the columns of that row asking the renderer for the size it would be and get the one with the largest height to set the rowHeight. For this to work you also have to set the column widths (another iteration of using some "reasonable" value or the column header width, whichever was larger) so the text area knows how to wrap. Sorry I don't have anything online to show you - I got all of this from the Java Swing forum and from a book: graphic Java 2 - Mastering the JFC by Geary (the Swing volume). Hope this makes sense enough to help!
22 years ago