📄 t.java
字号:
if ((at = getParameter("href")) != null) {
try { url_ = new URL(getDocumentBase(), at); } catch (Exception e) { url_ = null; }
}
// use default bgco = blue, if url is given; black otherwise if (url_ == null) { bgCo = Color.black; } else { bgCo = Color.blue; }
// get the colors
txtCo = readColor(getParameter("txtco"), bgCo); bgCo = readColor(getParameter("bgco"), getBackground()); }
/** Parameter Info. */
public String[][] getParameterInfo() {
String[][] info = {
{"msg", "String", "Message to display (New!)"}, {"speed", "int", "animation speed in pixels (10)"},
{"txtco", "int[3]", "RGB-Color of Message (black/blue)"}, {"bgco", "int[3]", "RGB-Color of background (getBackground)"}, {"exp", "int[3]", "Date to expire: Y, M, D; if not set, no expiration"}, };
return info;
}
/** Applet Info. */
public String getAppletInfo() {
return "ticker.java, V b1.0, 10/06/95 by Thomas Wendt, http://www.uni-kassel.de/fb16/ipm/mt/staff/thwendte.html"; }
/**
* Convert a ","-delimited String with RGB-Values to Color * Uses aDefault, if no or not enough RGB-Values */
public Color readColor(String aColor, Color aDefault) {
if (aColor == null) { return aDefault; }
int r, g, b;
StringTokenizer st = new StringTokenizer(aColor, ",");
try {
r = Integer.valueOf(st.nextToken()).intValue(); g = Integer.valueOf(st.nextToken()).intValue(); b = Integer.valueOf(st.nextToken()).intValue(); return new Color(r,g,b);
}
catch (Exception e) { return aDefault; } }
/**
* Create the image Parameters.
* Called, if just created or size has changed */
public void createParams() {
// Init some constants
int w = size().width;
int h = size().height;
lastS.width = w;
lastS.height = h;
// Calc the font and positions. Message must fit applets area. int refH = 14;
Font tf = new Font("TimesRoman", Font.BOLD, refH); setFont(tf);
FontMetrics tfm = getFontMetrics(tf);
int fh = tfm.getHeight();
fh = refH*(h-10)/fh;
messageF = new Font("TimesRoman", Font.BOLD, fh); FontMetrics fm = getFontMetrics(messageF); fh = fm.getHeight();
messageX = w;
messageY = ((h-fh) >> 1)+fm.getAscent(); messageW = fm.stringWidth(message);
}
/** Show the stuff, call update */
public void paint(Graphics g) { update(g); }
/** Show the stuff */
public void update(Graphics g) {
// Exit, if expired
if (expired) { return; }
// Recalc params, if something has changed if ((size().height != lastS.height) || (size().width != lastS.width)) { createParams(); }
// Use double buffering to avoid flicker. Image im = createImage(lastS.width, lastS.height); Graphics gr = im.getGraphics();
// fill area with bgcolor
gr.setColor(bgCo);
gr.fillRect(0,0,lastS.width-1,lastS.height-1);
// if url is given, let it look like a link if (url_ != null) {
gr.setColor(Color.blue);
gr.drawRect(0,0,lastS.width-1,lastS.height-1); gr.drawRect(1,1,lastS.width-3,lastS.height-3); gr.setColor(bgCo);
gr.draw3DRect(2,2,lastS.width-5, lastS.height-5, true); gr.draw3DRect(3,3,lastS.width-7, lastS.height-7, true); gr.clipRect(5,4,lastS.width-10, lastS.height-8); }
// draw the text
gr.setColor(txtCo);
gr.setFont(messageF);
gr.drawString(message, messageX, messageY);
// finally show all together on the screen g.drawImage(im,0,0,this);
}
/** Run the loop. This method is called by class Thread. */ public void run() {
// do nothing, if expired
if (expired) { return; }
// others might be more important
Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (active) {
// indirectly call update
repaint();
// decrement position
messageX -= speed;
// and stay in the bounds
if ((messageX + messageW) < 0) {
messageX = size().width;
// pause
try {Thread.sleep(100);}
catch (InterruptedException e){}
}
}
}
/** Start the applet by forking an animation thread. */ public void start() {
if (!active) {
t = new Thread(this);
active = true;
t.start();
}
}
/** Stop the applet. The thread will exit because run() exits. */ public void stop() {
active = false;
t = null; // give GC a chance.
}
/** Switch to url, if url is given. */
public boolean mouseUp(Event evt, int x, int Y) {
if (url_ != null) { getAppletContext().showDocument(url_); } // might not work with some early browsers return true;
}
}
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: jline.java
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 95
/*
* Permission to use, copy, modify and distribute this software and its * documentation without fee for NON-COMMERCIAL purposes is hereby granted * provided that this notice with a reference to the original source and * the author appears in all copies or derivatives of this software. *
* THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THIS SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY ANYBODY AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */
import java.awt.*;
import java.applet.*;
import java.lang.*;
import java.net.*;
/**
* jline - Text (with optional url) which is hidden for all Browsers except HotJava.<br> * use align=top<br>
*
* <p>V b1.00, 10/01/95: Ported by Thomas Wendt (thw) to pre-beta<br> * V b1.01, 11/18/95: Cleaning up the code by thw; renamed from javaline to jline<br> *
* <p><a href="http://www.uni-kassel.de/fb16/ipm/mt/java/javae.html"><b>origin</b></a> of jline.<br> *
* @author <A HREF="http://www.uni-kassel.de/fb16/ipm/mt/staff/thwendte.html">Thomas Wendt</A> * @version b1.01, 11/18/95
*/
public class jline extends Applet {
/** The text to be displayed. */
public String message;
/** y-position of the text. */
public int messageY;
/** URL to switch to. */
public URL url_ = null;
/**
* Initialize the applet.
* Get parameters and resize font- and message-dependant. */
public void init () {
// Get parameters.
message = ((message = getParameter("msg")) != null) ? message : "jline 1.01"; String attr = getParameter("msgh");
Integer msgH = new Integer((attr == null) ? "14" : attr); if ((attr = getParameter("href")) != null) {
try { url_ = new URL(getDocumentBase(), attr); } catch (Exception e) { url_ = null; }
}
// Set up the stuff needed for displaying. Font f = new Font("TimesRoman", Font.PLAIN, msgH.intValue()); FontMetrics fm = getFontMetrics(f);
setFont(f);
resize(fm.stringWidth(message), fm.getHeight()); // resize doesn't work with some browsers. messageY = fm.getAscent();
}
/** Parameter Info. */
public String[][] getParameterInfo() {
String[][] info = {
{"msg", "String", "Message to display (jline 1.0)"}, {"msgh", "int", "Fontsize of Message (14)"},
{"href", "Url", "optional url to switch to"},
};
return info;
}
/** Applet Info. */
public String getAppletInfo() {
return "javaline.java, V b1.01, 11/18/95 by Thomas Wendt, http://www.uni-kassel.de/fb16/ipm/mt/staff/thwendte.html"; }
/**
* Paint the applet.
* use blue, if url is given; black otherwise. */
public void paint(Graphics g) {
if (url_ != null) { g.setColor(Color.blue); } else { g.setColor(Color.black); }
g.drawString(message, 0, messageY);
}
/** switch to the document referenced by url_. */ public boolean mouseUp(Event evt, int x, int Y) {
if (url_ != null) { getAppletContext().showDocument(url_); } // may be defunctional with some browsers. return true;
}
}
----------
X-Sun-Data-Type: default-app
X-Sun-Data-Description: default
X-Sun-Data-Name: waisfr.java
X-Sun-Charset: us-ascii
X-Sun-Content-Lines: 159
/*
* Permission to use, copy, modify and distribute this software and its * documentation without fee for NON-COMMERCIAL purposes is hereby granted * provided that this notice with a reference to the original source and * the author appears in all copies or derivatives of this software. *
* THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THIS SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY ANYBODY AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.lang.*;
import java.applet.Applet;
/**
* waisfr - Simple frontend to wais scripts<br> *
* <p>V b1.00, 10/16/95: Creation by Thomas Wendt (thw)<br> * V b1.01, 11/18/95: Cleaning up the code; removed appletviewer support by thw<br> *
* <p><a href="http://www.uni-kassel.de/fb16/ipm/mt/java/javae.html"><b>origin</b></a> of waisfr.<br> *
* @author <A HREF="http://www.uni-kassel.de/fb16/ipm/mt/staff/thwendte.html">Thomas Wendt</A>
* @version b1.01, 11/18/95
*/
public class waisfr extends Applet {
/** Flag, if currently operation is in progress. */ public boolean atwork = false;
/** The URL of the script (relative to the host). */ public String cgi;
/** The host of the script. */
public String host;
/** The database to search. */
public String db;
/** Last type of search. */
public int lasti = -1;
/** Last search topic. */
public String lastq = null;
/** The textfild for the search topic. */ public TextField textField;
/** Lets you choose the type of search. */ public Choice chooser;
public void init() {
String at = getParameter("cgi");
cgi = (at != null) ? at : "/cgi-bin/SFgate"; db = ((at= getParameter("data")) != null) ? at : "www.uni-kassel.de"; host = ((at = getParameter("host")) != null) ? at : "www.uni-kassel.de";
//Build the left half of this applet.
textField = new TextField(10);
Panel left = new Panel();
left.add(new Label("Search for", Label.CENTER)); left.add(textField);
//Build the right half of this panel.
Panel right = new Panel();
chooser = new Choice();
chooser.addItem("Body");
chooser.addItem("Title");
chooser.addItem("Address");
right.add(new Label(" at", Label.CENTER)); right.add(chooser);
//Put everything in this panel.
setLayout(new BorderLayout());
add("North", new Label("WAIS frontend", Label.CENTER)); add("West", left);
add("Center", right);
add("South", new Button("Start Query")); }
/** Parameter Info. */
public String[][] getParameterInfo() {
String[][] info = {
{"host", "String", "Host"},
{"cgi", "String", "Script for searching"}, {"data", "String", "Database to search"}, };
return info;
}
/** Applet Info. */
public String getAppletInfo() {
return "waisfr.java, V b1.01, 11/18/95 by Thomas Wendt, http://www.uni-kassel.de/fb16/ipm/mt/staff/thwendte.html"; }
/** Query the server and show the Results. */ public void query() {
int i = chooser.getSelectedIndex();
String sf = textField.getText();
// first do some preprocessing
if (i == lasti && sf.equals(lastq)) {
showStatus("Identical Queries not allowed"); return;
}
if (sf.length() < 5) {
showStatus("Your topic is too short");
return;
}
// remember this topic
lasti = i;
lastq = sf;
// set up the query
String ti = "&ti=";
String ad = "&ad=";
String text = "&text=";
switch (i) {
case 0:
text += sf;
break;
case 1:
ti += sf;
break;
case 2:
ad += sf;
break;
}
// build the 'URL'
String us = cgi+"?database="+db+"%2Fwww-pages"+ti+ad+text+"&maxhits=5"; URL u;
try { u = new URL("http", host, -1, us); } catch (Exception e) { u = null; }
// return, if error
if (u == null) { return; }
// else show the results. May be defunctional with early browsers. getAppletContext().showDocument(u);
}
/** Respond to user actions. */
public boolean handleEvent(Event e) {
// if the one and only button is pressed if (e.target instanceof Button) {
// and if the user is not too fast
if (!atwork) {
atwork = true;
// ask the server
query();
atwork = false;
}
return true;
} else { return false; }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -