What you see in csdn, write it down here.
(http://bbs.csdn.net/topics/390703095)
Importjavax.swing.*;Importjava.awt.*;ImportJava.awt.font.GlyphVector; PublicclassTestextendsJComponent { PublicStatic voidMain (string[] args) {Swingutilities.invokelater (NewRunnable () {@Override Publicvoidrun () {JFrame test=NewJFrame ("Test"); Test.setcontentpane (NewTest ()); Test.pack (); Test.setlocationrelativeto (NULL); Test.setdefaultcloseoperation (Jframe.exit_on_close); Test.setvisible (true); } }); } Test () {setpreferredsize (NewDimension (800, 600)); } @Overrideprotected voidpaintcomponent (Graphics g) {Font F=NewFont ("Courier New", Font.Bold, 140); Glyphvector v= F.createglyphvector (Getfontmetrics (f). Getfontrendercontext (), "Hello"); Shape Shape=V.getoutline (); Rectangle bounds=shape.getbounds (); graphics2d GG=(graphics2d) G; Gg.translate ((getwidth ()-Bounds.width)/2-bounds.x, (getheight ()-Bounds.height)/2-bounds.y); Gg.setrenderinghint (renderinghints.key_antialiasing, renderinghints.value_antialias_on); Gg.setcolor (Color.White); Gg.fill (Shape); Gg.setcolor (Color.BLUE.darker (). darker ()); Gg.setstroke (NewBasicstroke (3)); Gg.draw (Shape); }}
Java graphics2d Draw Text Stroke effect