package 作业;
/**
* 第5周作业-字体设置
* xiaowei
*/
import java.awt.*;
import java.awt.font.*;
import javax.swing.*;
import java.*;
public class FontSet
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
FontFrame frame = new FontFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class FontFrame extends JFrame
{
public FontFrame()
{
setTitle("设置字体");
setSize(WIDTH,HEIGHT);
FontPanel panel = new FontPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final int WIDTH = 300;
public static final int HEIGHT = 140;
}
class FontPanel extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Font f = new Font("宋体",Font.BOLD+Font.ITALIC,20);
Choice txt = new Choice();
txt.addItem("宋体");
txt.addItem("微软");
txt.addItem("黑体");
add(txt);
g.setFont(f);
g.drawString("java欢迎你", x, y);
}
public int x=55;
public int y=50;
}
第五周作业:字体设置
最新推荐文章于 2018-10-13 18:15:00 发布