当前位置:首页 » 编程语言 » 字体java

字体java

发布时间: 2022-12-30 06:45:25

A. 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));

B. java字体库中的字体打印不出来

java字体库中的字体打印不出来的原因如下:
javac Hallojava.java是编译这个文件,要打印出来你还需要打java Hallojava去运行它的class文件。
Java是一门面向对象的编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。Java语言作为静态面向对象编程语言的代表,极好地实现了面向对象理论,允许程序员以优雅的思维方式进行复杂的编程。

C. 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);

D. java字体设置

字体 Font
setFont("隶书",Font.ITATIC,23)
意思就是("字体名字",字形(如,fond.bold),大小)
等等

E. 你们在编写java的代码的时候一般用什么样的字体

一般适合用作程序代码显示的字体,有下列几个:
(1):Courier New 9pt, Verdana, Lucida Console (宋体,新宋体等不在讨论之列)
首先说说Courier New, 这个字体虽说经典,但总体感觉其实不好。因为是等宽字体,所以对编程而言,其优点是每个字符区分的十分清楚,方便查找程序中的输入错误。不好的地方在于,因为是等宽字体,特别浪费显示空间,在看代码的时候恨不得显示器变成 21寸的才好。总之就是感觉用来看那种大的框架的源代码的时候,非常不适合。一屏只能看到很少的几句代码,有只见树木,不见森林之感,不利于从宏观角度理解代码的逻辑。另外在 VS.NET 2003 里面该字体显示的中文特别大,而且很丑陋 -_-!
(2):Verdana: 非等宽字体。总体可读性好些,但是小的错误,比如多一个少一个空格之类的,很难排查。
Lucida Console 是等宽字体。可读性也不错,但是 vs.Net 显示出来有锯齿。
serif 字体通常不同笔顺的粗细有别,且起笔落笔处有多余的小折线。
sans-serif 字体笔画不论方向粗细相同,且起笔落笔没有多余折线。
中文字体中,可以与此类比:宋体相当于 serif 字体,黑体相当于 sans-serif 字体。
正文中应该用 serif 字体以提高可读性,标题可以用 sans serif 字体以示强调。
(3):serif 字体在视觉上强调单词的整体,因此作为正文更可读;而 sans serif 强调单个的字母。
研究显示,在 web 中 sans-serif 字体更易阅读。正文字体比较好的选择:Arial 9.75 或 MS Sans Serif 9.75。为了提高阅读准确性和速度,最好的字体大小是 8.25, 9.0, 或 9.75("MS Serif 8.25" 除外)。
(4)养眼的编辑器配色
环境:VS2005
字体:Verdana, 10pt
普通文本背景色:238,239,230 (#E6EFEE)

热点内容
android画虚线 发布:2025-07-03 04:11:04 浏览:383
系统启动密码怎么取消 发布:2025-07-03 04:08:06 浏览:745
python程序设计第三版课后答案 发布:2025-07-03 03:58:08 浏览:213
socket上传文件 发布:2025-07-03 03:57:24 浏览:895
安卓cleo脚本 发布:2025-07-03 03:41:26 浏览:245
编程器解读 发布:2025-07-03 03:22:49 浏览:24
中国电信加密通信业务 发布:2025-07-03 03:06:00 浏览:521
脚本家的台词 发布:2025-07-03 03:05:50 浏览:709
arcgisforpython 发布:2025-07-03 03:05:46 浏览:899
期计算法 发布:2025-07-03 02:56:53 浏览:405