package Test;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ShadowTextFrame extends JFrame {
private ShadowTextPanel shadowTextPanel=new ShadowTextPanel();
public static void main(String args[]){
ShadowTextFrame frame=new ShadowTextFrame();
frame.setVisible(true);
}
public ShadowTextFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,600,320);
setTitle("阴影字体效果");
getContentPane().add(shadowTextPanel);
}
class ShadowTextPanel extends JPanel{
public void paint(Graphics g){
String value="阴影字体效果";
int x=16;
int y=100;
Font font=new Font("华文行楷",Font.BOLD,72);
g.setFont(font);
g.setColor(Color.GRAY);
g.drawString(value, x, y);
x-=3;
y-=3;
g.setColor(Color.BLACK);
g.drawString(value, x, y);
}
}
}