Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
176
Chapter 7 Generating the Server Response: HTTP Response Headers
Listing 7.11 ShadowedTextFrame.java
package coreservlets;
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
/** Interactive interface to MessageImage class.
* Enter message, font name, and font size on the command
* line. Requires Java2.
*/
public class ShadowedTextFrame extends JPanel {
private Image messageImage;
public static void main(String[] args) {
String message = "Shadowed Text";
if (args.length > 0) {
message = args[0];
}
String fontName = "Serif";
if (args.length > 1) {
fontName = args[1];
}
int fontSize = 90;
if (args.length > 2) {
try {
fontSize = Integer.parseInt(args[2]);
} catch(NumberFormatException nfe) {}
}
JFrame frame = new JFrame("Shadowed Text");
frame.addWindowListener(new ExitListener());
JPanel panel =
new ShadowedTextFrame(message, fontName, fontSize);
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
public ShadowedTextFrame(String message,
String fontName,
int fontSize) {
messageImage = MessageImage.makeMessageImage(message,
fontName,
fontSize);
int width = messageImage.getWidth(this);
int height = messageImage.getHeight(this);
setPreferredSize(new Dimension(width, height));
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved