java的字体大小设置
㈠ java中控制字体大小的设置
改成这样就可以了
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,但是这并不影响对象中的属性,对象的属性还是和之前定义时一样;所以不会改变。。。
㈡ 怎么调整Java-Eclipse编辑框和控制台的字体大小
打开Eclipse,选择windows(系统)选项
然后点开--->preferences(首选项)
弹出首选项的窗口点击Appearance(外观)
再点击color and font (颜色和字体)
再点击Java---->Java editor text font(java 编辑器文本字体)
再点击Edit进行编辑
设置字体大小
控制台的字体设置点击Debug----->点击console font(控制台字体)步骤同上面一样点击Edit,进行字体大小设置
㈢ java怎么缩小字体
摘要 打开eclipse找到工具栏的Window 选择Preferences。
㈣ java中如何设置按钮文字的大小、颜色和字体
submit= new JButton("登陆");
submit.setFont(new Font("宋体", Font.PLAIN, 16));
三个参数分别表示: 字体,样式(粗体,斜体等),字号
submit.setForeground(Color.RED);
这个表示给组件上的文字设置颜色Color.RED表示红色
当然你也可以自己给RGB的值 比如 submit.setForeground(new Color(215,215,200));
JLabel组件支持HTML标记代码
infoLab= new JLabel("<html><a href='地址'>用户登陆系统</a></html>", JLabel.CENTER);
*注意:地址要单引号引起来。这个表示给用户登录系统几个字增加超链接
infoLab .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
这个表示给这个文字添加鼠标样式,当鼠标移动到文字上,鼠标变成手型
㈤ Java中怎么设置JLabel的字体样式,大小,颜色
1、打开Myeclipse的相关界面,在Window那里点击Preferences。
㈥ java 设置字体格式
Java Swing中可以给每个控件设置字体格式和其他属性的设置,示例如下:
submit= new JButton("登陆");
submit.setFont(new Font("宋体", Font.PLAIN, 16));
三个参数分别表示: 字体,样式(粗体,斜体等),字号
submit.setForeground(Color.RED);
这个表示给组件上的文字设置颜色Color.RED表示红色
当然你也可以自己给RGB的值 比如 submit.setForeground(new Color(215,215,200));
㈦ java里面怎么设置字体大小
JTextArea t = new JTextArea();
Font font = new Font("Default",Font.PLAIN,size);
t.setFont(font);
//其中size 就是字体的大小,可以设置。只要再用t.setFont()安装新的字体就行了。
㈧ java 字体设置
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:为color
8、文本背景颜色的设置
MutableAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setBackground(attr, bg);
setCharacterAttributes(editor, attr, false);
㈨ java的编程环境里怎么去设置中文的字体大小
在
MyEclipse
的工具栏中选择
Window
的
Preferences
选项:
在弹出框中选择第一个
General
下的->
Appearance
下的->
Colors
and
Fonts
->
在左边选择
Java
下的->
Java
Editor
Text
Font
,选中后右边有一个
Change
,点击它会弹出一个字体对话框
里面可设置编程时,代码的字体、字形、大小等,选择后确定即可!