java字体设置?
来源:百度知道 编辑:UC知道 时间:2024/05/18 11:11:12
请问上述问题该如何实现?求大虾指点。
我知道需要自己编写,因为自己不会才向大家求教。
java中没有自带的字体对话框,这需要自己来编写。
text.setFond("字体名字",字形(如,fond.bold),大小)
import java.awt.*;
import java.awt.event.*;
import javax.swing.JColorChooser;
//import javax.swing.border.*;
class ff extends Frame implements ActionListener
{
Choice font,size,bolder;
Button bb;
ff(String s)
{
setTitle(s);
font=new Choice();
bolder=new Choice();
size=new Choice();
//bolder.add加监视器
//font.add加监视器
//size.add加监视器
Panel p1=new Panel();
Panel p2=new Panel();
bb=new Button("点击打开");
bb.addActionListener(this);
p1.setLayout(new GridLayout(4,1));
p2.setLayout(new GridLayout(4,1));
GraphicsEnvironment gg=GraphicsEnvironment.getLocalGraphicsEnvironment();
String ss[]=gg.getAvailableFontFamilyNames();
String bold[]={"Font.BOLD","Font.CENTER_BASELINE","Font.CENTER_BASELINE","Font.I