📄 util.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.cnxinshe.noteview;import java.io.IOException;import java.util.Vector;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Image;/** * * @author 尹佳 * QQ:387687685 * email:387687685@qq.com */public class Util { private static Font font = Font.getDefaultFont(); //根据文件名得到对应的图片 public static Image getImage(String name) { try { return Image.createImage("/" + name + ".png"); } catch (IOException ex) { ex.printStackTrace(); } return null; } //分割字符(分行 支持“\n”换行) public static Vector textToRows(int width, String src) { Vector list = new Vector(); if (font.stringWidth(src) <= width) { list.addElement(src); return list; } //最多可以显示汉字数目 StringBuffer sb = new StringBuffer(); int len = src.length(); int position = 0; int tempWidth = 0; while (position <= len) { tempWidth = font.stringWidth(sb.toString()); while (tempWidth <= width - Platform.FONT_WIDHT_ZH) { if (position + 1 <= len && src.charAt(position) == '\\' && src.charAt(position + 1) == 'n') { position += 2; break; } char temp = src.charAt(position); sb.append(temp); tempWidth += font.charWidth(temp); position++; if (position >= len) { break; } } list.addElement(sb.toString()); sb.setLength(0); tempWidth = 0; if (position >= len) { break; } // if (len - position >= 0 && len - position <= maxCount) { // list.addElement(src.substring(position, len)); // break; // } } return list; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -