?? template.java
字號:
//// BaseApplet - An applet with an offscreen image for drawing into, and a few// other kooky things that turned out to be useful.// Created from mdb's DBApplet class.//// $Id: BaseApplet.java,v 1.0 1996/12/16 09:09:38 wfk Exp $import java.applet.Applet;import java.awt.Color;import java.awt.Dimension;import java.awt.Event;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics;import java.awt.Image;public abstract class Template extends Applet implements Runnable{ // // BaseApplet public member functions public void init () { int fontSize; Dimension d = size(); try { fontSize = Integer.parseInt(getParameter("fontsize")); } catch (NumberFormatException e) { fontSize = 10; } defaultFont = new Font("Helvetica", Font.PLAIN, fontSize); _offImage = createImage(d.width, d.height); _offGraphics = _offImage.getGraphics(); // clear out the background _offGraphics.setColor(Color.white); _offGraphics.fillRect(0, 0, d.width, d.height); _offGraphics.setColor(Color.black); _offGraphics.setFont(defaultFont); // get some graphics stuff _metrics = _offGraphics.getFontMetrics(); _height = _metrics.getHeight(); _ascent = _metrics.getAscent(); _descent = _metrics.getDescent(); } public void start () { } public void stop () { } public abstract void run (); public void update (Graphics g) { g.drawImage(_offImage, 0, 0, null); } public void paint (Graphics g) { g.drawImage(_offImage, 0, 0, null); } public void title (String line1, String line2) { Dimension d = size(); int width = _metrics.stringWidth(line1); _offGraphics.drawString(line1, (d.width/3)+15, 5 + _ascent); width = _metrics.stringWidth(line2); _offGraphics.drawString(line2, (d.width/3)+15, 5 + _ascent + _height); } public void message (String line1, String line2, String line3, String line4) { Dimension d = size(); _mwidth = Math.max(_metrics.stringWidth(line1), _metrics.stringWidth(line2)); _offGraphics.drawString(line1, 5, 5+_ascent); _offGraphics.drawString(line2, 5, 5+_ascent+_height); _offGraphics.drawString(line3, 5, d.height - (_ascent + _height)); _offGraphics.drawString(line4, 5, d.height - _ascent); } public void clearMessage () { Dimension d = size(); _offGraphics.setColor(Color.white); _offGraphics.fillRect(5, 5, 5+_mwidth, 5+_ascent+_height); _offGraphics.fillRect(5, d.height - (_ascent+_height), 5 + d.width, 5+_ascent+(2*_height)); _offGraphics.setColor(Color.black); } // // BaseApplet protected data members Image _offImage; Graphics _offGraphics; Font defaultFont; FontMetrics _metrics; int _height; int _ascent; int _descent; int _mwidth; /* Following are workarounds for font size calculations, as Netscape * reports unappealing font height/ascents on varying platforms. */ static final int FIXED_FONT_HEIGHT = 18; static final int FIXED_FONT_ASCENT = 9; String _srcString; // original input string StringBuffer _workString; // current work string};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -