Java源代码-Applet-居中显示文字
来源:互联网 发布:程序员有多少种语言 编辑:程序博客网 时间:2024/05/02 10:54
import java.awt.*;
import java.applet.*;
public class PrintCenterString extends Applet
{
Font F;
Color C;
FontMetrics FM;
int X,Y;
int Ascent,Descent,Width,AppletWidth,AppletHeight;
String str;
public void init()
{
str=new String("Cent");
AppletWidth=getSize().width;
AppletHeight=getSize().height;
setBackground(Color.green);
}
public void paint(Graphics g)
{
F=new Font("宋体",Font.BOLD+Font.ITALIC,72);
C=new Color(110,110,110);
g.setFont(F);
g.setColor(C);
FM=g.getFontMetrics();
Ascent=FM.getAscent();
Descent=FM.getDescent();
Width=FM.stringWidth(str);
X=(AppletWidth-Width)/2;
Y=(AppletHeight-(Ascent + Descent ))/2;
g.drawString(str,X,Y);
g.setColor(Color.white);
g.drawString(str,X+5,Y+5);
}
}
- Java源代码-Applet-居中显示文字
- 文字居中显示
- RaidoButton文字居中显示
- java applet PseudoScreen类源代码
- Java Applet编程小技巧之文字显示-Java基础-Java-编程开发
- Accordion头部文字居中显示
- TextView文字+drawableLeft居中显示
- 设TextView文字居中显示
- tabhost tabwidget文字居中显示
- 关于spinner文字居中显示
- Android TextView 文字居中显示
- 文本框文字居中编辑 显示
- html文字居中对齐显示
- java graphic2D 矩形文字居中
- 如何让TextView中的文字居中显示
- 输入框显示文字垂直居中
- 图片文字绝对居中,并排显示
- RadioButton上的文字居中显示
- 软件测试-掌握有效测试软件的方法与技术之七
- 软件测试-掌握有效测试软件的方法与技术之八
- 高效的Java音乐播放类
- 软件测试-掌握有效测试软件的方法与技术之九
- 软件测试-掌握有效测试软件的方法与技术之十
- Java源代码-Applet-居中显示文字
- div布局的一些特性
- ERP与十四顶帽子[转]
- C-源代码-计算简单表达式
- java中的版本问题
- 也谈百度的C2C江湖大战
- Windows XP Home版本无法运行gpedit.msc(组策略)命令之解决
- 软件缺陷的生命周期
- Matlab 图像处理