myfont.java

来自「简单的聊天程序」· Java 代码 · 共 50 行

JAVA
50
字号
import java.awt.Color;
import java.awt.Font;
import java.util.StringTokenizer;
public class MyFont{
		public String color;
		public int size;
		public String fontName;
		public int style;
		public boolean isUnderLine;
		public MyFont(){
			this.color = "black";
			size = 3;
			fontName = "宋体";
			style = Font.PLAIN;
			isUnderLine = false;
		}
		public MyFont(Color color,int size,String fontName,
				int style,
				boolean isUnderLine){
			this.color = MyUtilities.getColor0XFromRGB(color);
			this.size = size;
			this.fontName = fontName;
			this.style = style;
			this.isUnderLine = isUnderLine;
		}
		public String toString(){
			
			StringBuffer sb = new StringBuffer();
			sb.append(color);
			sb.append("&");
			sb.append(size);
			sb.append("&");
			sb.append(fontName);
			sb.append("&");
			sb.append(style);
			sb.append("&");
			sb.append(isUnderLine);
			return String.valueOf(sb);
		}
		public static MyFont createMyFont(String str){
			MyFont font = new MyFont();
			StringTokenizer st = new StringTokenizer(str,"&");
			font.color = st.nextToken();
			font.size = Integer.parseInt(st.nextToken());
			font.fontName = st.nextToken();
			font.style = Integer.parseInt(st.nextToken());
			font.isUnderLine = Boolean.parseBoolean(st.nextToken());
			return font;
		}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?