网站建设资讯

NEWS

网站建设资讯

设置java代码字体,java默认字体

java控制台输出字体大小怎么设置?

java控制台输出字体大小设置方法:\x0d\x0a1.打开Eclipse或者Myeclipse,选择windows(系统)选项;\x0d\x0a2.点击preferences(首选项);\x0d\x0a3.弹出首选项的窗口,点击Appearance(外观);\x0d\x0a4.点击color and font (颜色和字体);\x0d\x0a5.点击Debug展开,点击console font(控制台字体);\x0d\x0a6.再点击Edit进行编辑,进入设置大小,然后点击确定即可。

西峰网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联自2013年起到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联

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中怎么设置JLabel的字体样式,大小,颜色?

1、打开Myeclipse的相关界面,在Window那里点击Preferences。

2、弹出设置的对话框,选择General下的Appearance进入。

3、点击Colors and Fonts按钮,需要在右侧选择Java。

4、选择Java Editor Text Font,并点击Edit。

5、通过设置对应的参数以后,直接确定返回。

6、这样一来会看到图示的结果,即可设置JLabel的字体样式,大小,颜色了。

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 如何设置字体格式?

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代码字体,java默认字体
URL分享:http://cdweb.net/article/dseoehe.html