It's easy to customize a JButton border...but how do you customize an AWT Button border without overriding the paint method?

See, here's the problem:I can override the paint method, but then the text on the button looks UGLY. I can add renderinghints and the like, but compared to the default AWT button text, it's just ugly. I tried overriding the paint method, calling super first and then painting rectangles around the border, but when a popupmenu comes up, the repaint calls stop working for the buttons, and the borders come back.

So, can I customize an AWT button border? Or, even better, how does the default AWT button paint method paint such beautiful, perfectly antialiased text? If I knew that, I'd just override the whole thing and do it myself.

One word: compatibility.[...]I originally wrote the app in swing, but have been trying to port it over to AWT in hope that it'll work with older versions of java. :-/

That certainly is a good idea. It just seems kind of weird on this forum, where people are already talking about the nanotimer in the *beta* of 1.5.0 .I'm not saying you shouldn't care about compatibility though .

I actually had the same issue with Swing. You override the paint method, cast to Graphics2D, establish some rendering hints...but the text would just come out ugly. I'm actually reading through all the source code right now, trying to find how they antialias the text...I'm down to the Component.java source, but still no luck.

I'm not a pro on AWT/Swing stuff, so I'm just putting this out as an idea, but I wonder if the actual text rendering for AWT components is handled by the OS. After all AWT uses heavyweight OS peers to render the components (though I don't know if the text is included in that).

I've been sifting through the source code. I can't seem to trace back where the actual painting of the label on the button is taking place...and actually, I can't even find anything about the border either.

I found the awt folder, when in to button.java.Saw that it doesn't have a paint method, but extends component.java.Went to component.java, which doesn't extend anything, but who's paint method is completely empty. Now, how does THAT work??!!?

I was just thinking that if the system can make a call to the OS at some point to render some text, can we make that same call after painting over the old stuff?

Maybe I'm tackling this the wrong way (wouldn't be the first time). I typically use Java2D with addrenderinghints; it's just that the text still doesn't look all that great compared to the OS rendering (in windows or linux). There's several types of renderinghints available, or maybe there's even a better way to do it without them. So, what's the best way to render anti-aliased (or just smoothed) text in java apps and applets? I just want to make sure my applications look professional.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org