欢迎光临
我们一直在努力

java设置字体,JAVA 输入字体设置eclipse

1,JAVA 输入字体设置eclipse

话说,你老师是不是在给你的题目里面把John、54、Celine、57等字加粗咧?你老师的最后一句是让你注意上面哪些字是程序提示的,哪些字是要你手动输入的。比如说“Enter the name of the person: ”是要程序输出的,而名字John则是用户手动输入的。明白没?外教,没啥概念,自己看书的好玩~~

JAVA 输入字体设置eclipse

2,java 中怎样只设置指定文字的字体如宋体等而不是字号什么的都

一般有一个Font类,然后应用到相应位置object.setFont(new Font());Java.awt.Font设计字体显示效果 Font mf = new Font(String 字体,int 风格,int 字号);字体:TimesRoman, Courier, Arial等风格:三个常量 lFont.PLAIN, Font.BOLD, Font.ITALIC字号:字的大小(磅数)设置组件当前使用的字体:setFont(Font fn)获取组件当前使用的字体:getFont()

java 中怎样只设置指定文字的字体如宋体等而不是字号什么的都

3,请问java中怎样设置字体的颜色

1、选中要修改的文字2、格式—字体3、如果修改艺术字的字体颜色,选中艺术字,格式—艺术字格式
定义Font可以为控件设置字体样式。Font font=new Font(“宋体”,Font.ITALIC|Font.BOLD,16);就可以定义出一个粗体加斜体,16号的宋体Font再为需要的标签设置Font即可。因为这个Font类是在awt包中的,所以一般用起来都是为控件进行设置字体样式的。要为控件上的字体设置颜色,可以设置该控件的前景色,比如Button控件,就可以利用其中的方法setForeground(Color)来设置。如果是要设置applet中的字体颜色就更好办了,直接利用g.setColor()方法,再用g来绘制字符串就可以了。你的这个问题问的不太清楚,也不知道是不是想要设置控件上的字体颜色。
下拉框和textfield,textarea这些控件都有setforeground方法,这个函数是设置前景色的,设置为红色就行了.例如:textfield txt=new textfield(“请输入姓名”); txt.setforeground(color.red);

请问java中怎样设置字体的颜色

4,java里面怎么设置字体大小

JTextArea t = new JTextArea();Font font = new Font(“Default”,Font.PLAIN,size);t.setFont(font);//其中size 就是字体的大小,可以设置。只要再用t.setFont()安装新的字体就行了。
Myelice进入上面Windows,选择最后一个Pre那个,在搜索栏输入text,然后可以直接修改
两个方法: 一是如果你安装了插件(SWT)你就可以到界面设计里直接找Front这个属性直接改 二是到代码里去手写,其中你可以写一个字体封装类然后那个界面需要就调用一下这个类就可以属性是找 Size惊醒设置也行
改成这样就可以了 import java.applet.applet; import java.awt.*; import java.awt.event.*; public class controlstring extends applet implements actionlistener button btn1, btn2; int i = 20; textarea tx; public void init() btn1 = new button(“big”); btn2 = new button(“small”); tx = new textarea(50, 50); add(btn1); add(btn2); add(tx); tx.setfont(new font(“sansserif”, font.bold, i)); btn1.addactionlistener(this); btn2.addactionlistener(this); } public void actionperformed(actionevent e) if (e.getsource() == btn1 && i < 60) i = i + 4; tx.setfont(new font(“sansserif”, font.bold, i)); tx.settext(“i is changed to” + i); } else if (e.getsource() == btn2 && i > 4) i = i – 4; tx.setfont(new font(“sansserif”, font.bold, i)); tx.settext(“i is changed to” + i); } } }——————font font1=new font(“sansserif”,font.bold,i); 在这里 你创建了一个对象font1,然后其属性都在这里定义了;之后你增加了变量i,但是这并不影响对象中的属性,对象的属性还是和之前定义时一样;所以不会改变。。。

5,java 字体设置

Font –style的样式常量。样式参数可以为 PLAIN,或 BOLD 和 ITALIC ,不知道你要的是不是这个呀?
new 一个buttom(用它来控制字体设置) 然后 监听端口boldjcheckbox = new jcheckbox(“bold”);boldjcheckbox.additemlistener(new checkboxhandler());private class checkboxhandler implements itemlistener private int valbold = font.plain; public void itemstatechanged(itemevent event) if (event.getsource()==boldjcheckbox) valbold = boldjcheckbox.isselected()?font.bold: font.plain); textfield.setfont(new font(“serif”, valbold, 14); }}代码直接敲的 没测试 主要是实现方法对于问题二 java 里不清楚 .net里倒有刷新语句ps 我是不是理解错你问题意思了?
!!!!!!!
1、对字体的操作MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setFontFamily(attr, family); setCharacterAttributes(editor, attr, false);family为字体2、对字体大小的操作MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setFontSize(attr, size); setCharacterAttributes(editor, attr, false);size为字号3、是否是粗体的操作StyledEditorKit kit = getStyledEditorKit(editor); MutableAttributeSet attr = kit.getInputAttributes(); boolean bold = (StyleConstants.isBold(attr)) ? false : true; SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setBold(sas, bold); setCharacterAttributes(editor, sas, false);4、是否是斜体的操作StyledEditorKit kit = getStyledEditorKit(editor); MutableAttributeSet attr = kit.getInputAttributes(); boolean italic = (StyleConstants.isItalic(attr)) ? false : true; SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setItalic(sas, italic); setCharacterAttributes(editor, sas, false);5、是否有下划线的操作StyledEditorKit kit = getStyledEditorKit(editor); MutableAttributeSet attr = kit.getInputAttributes(); boolean underline = (StyleConstants.isUnderline(attr)) ? false : true; SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setUnderline(sas, underline); setCharacterAttributes(editor, sas, false);6、左中右对齐的处理MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setAlignment(attr, a); setParagraphAttributes(editor, attr, false);public static final void setParagraphAttributes(JEditorPane editor, AttributeSet attr, boolean replace) int p0 = editor.getSelectionStart(); int p1 = editor.getSelectionEnd(); StyledDocument doc = getStyledDocument(editor); doc.setParagraphAttributes(p0, p1 – p0, attr, replace);}a:0:左,1:中,2:右7、文本字体颜色的设置MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, fg); setCharacterAttributes(editor, attr, false);fg:为color8、文本背景颜色的设置MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setBackground(attr, bg); setCharacterAttributes(editor, attr, false);
赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。