Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
12.3 Including Applets for the Java Plug In
281
Listing 12.10 ShadowedTextApplet.java
package coreservlets;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/** Applet interface to the ShadowedTextFrame
* class. Requires Swing and Java 2D.
*/
public class ShadowedTextApplet extends JApplet
implements ActionListener {
private JTextField messageField;
private JComboBox fontBox;
private JSlider fontSizeSlider;
private JButton showFrameButton;
public void init() {
WindowUtilities.setNativeLookAndFeel();
Color bgColor = new Color(0xFD, 0xF5, 0xE6);
Font font = new Font("Serif", Font.PLAIN, 16);
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout(4, 1));
contentPane.setBackground(bgColor);
// Use a JTextField to gather the text for the message.
// If the MESSAGE parameter is in the HTML,
// use it as the initial value of this text field.
messageField = new JTextField(20);
String message = getParameter("MESSAGE");
if (message != null) {
messageField.setText(message);
}
JPanel messagePanel =
new LabelPanel("Message:", "Message to Display",
bgColor, font, messageField);
contentPane.add(messagePanel);
// Use a JComboBox to let users choose any
// font available on their system.
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames = env.getAvailableFontFamilyNames();
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