Use the Java2D API. The is an excellent book on it from O'Reilly.
1- Use the font you like.
2- Convert the Glyphs you need (e.g. "2" "/" and "3") into Java2D shapes.
3- Use the Java@d method to scales and place the shapes together
4- This part depends on the component. I think a lot of components take some kind of image instead of text. Convert your shapes into whatever fits into the components you w ant.
5- This should look really professional if you do a good job :)
Come on give me 50!!!
=============
Thanks so much for the points. Here is an example of how to do the first step. It'll show how to get an instance of enter code here
Shape from a character in the font of your choice.
Once you have your Shape
You can use Graphics2D to create the image you want (scale, compose, etc). All the swing components are different but all have a graphics context. Using the graphics content you can draw on any Swing Component. You can also make transparent layers and stick a transport JPanel over anything you want. If you just want to display a fraction on a label that's easy. If you had some sort of word processor in mind that's hard.
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.Shape;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
public class Utils {
public static Shape generateShapeFromText(Font font, char ch) {
return generateShapeFromText(font, String.valueOf(ch));
}
public static Shape generateShapeFromText(Font font, String string) {
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.createGraphics();
try {
GlyphVector vect = font.createGlyphVector(g2.getFontRenderContext(), string);
Shape shape = vect.getOutline(0f, (float) -vect.getVisualBounds().getY());
return shape;
} finally {
g2.dispose();
}
}
}