BrowserToolBar.java A basic tool bar for holding multiple buttons. import java.awt.*; import javax.swing.*; /** Part of a small example showing basic use of JToolBar. * Creates a small dockable toolbar that is supposed to look * vaguely like one that might come with a Web browser. * Makes use of ToolBarButton, a small extension of …
Category: Root
Aug 25
Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference
Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference. The dialog returns a Color object based on the user’s selection or null if the user entered Cancel. import java.awt.*; import java.awt.event.*; import javax.swing.*; /** Simple example illustrating the use of …
Aug 25
WebClient – Client application that can talk interactively to Web servers. Requires the components listed below
import java.awt.*; // For BorderLayout, GridLayout, Font, Color. import java.awt.event.*; import java.util.*; import javax.swing.*; /** A graphical client that lets you interactively connect to * Web servers and send custom request lines and * request headers. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * © …
Aug 25
EchoServer.java A simple HTTP server that creates a Web page showing all data sent from the client (browser), including all HTTP request headers sent form the client. Uses the following classes
EchoServer.java A simple HTTP server that creates a Web page showing all data sent from the client (browser), including all HTTP request headers sent form the client. Uses the following classes: import java.net.*; import java.io.*; import java.util.StringTokenizer; /** A simple HTTP server that generates a Web page showing all * of the data that …
Aug 25
StoppableThread.java A template to place a thread in a RUN, WAIT, or STOP state.
/** A template to control the state of a thread through setting * an internal flag. public class StoppableThread extends Thread { public static final int STOP = 0; public static final int RUN = 1; public static final int WAIT = 2; private int state = RUN; /** Public …
Aug 25
mall example showing the basic use of a JToolBar
mall example showing the basic use of a JToolBar import java.awt.*; import javax.swing.*; import java.awt.event.*; /** Small example showing basic use of JToolBar. * * */ public class JToolBarExample extends JFrame implements ItemListener { private BrowserToolBar toolbar; private JCheckBox labelBox; public static void main(String[] args) { new JToolBarExample(); } …
Aug 25
UrlRetriever2.java Illustrates how the URL class can simplify communication to an HTTP server.
UrlRetriever2.java Illustrates how the URL class can simplify communication to an HTTP server. import java.net.*; import java.io.*; /** Read a remote file using the standard URL class * instead of connecting explicitly to the HTTP server. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * © …
Aug 25
RMI Example – Message, illustrates retrieving a message from an object located on a remote server. Requires the following classes
Rem.java Establishes which methods the client can access in the remote object. import java.rmi.*; /** The RMI client will use this interface directly. The RMI * server will make a real remote object that implements this, * then register an instance of it with some URL. * * Taken from Core Web Programming from * …
Aug 25
Creates three common types of sliders
Creates three common types of sliders: one without tick marks, one with tick marks, and one with both tick marks and labels. import java.awt.*; import javax.swing.*; /** Simple example illustrating the use of JSliders, especially * the ability to specify tick marks and labels. * * */ public class JSliders extends JFrame { …
Aug 25
Basic Swing Details
WindowUtilities.java Utility class that simplifies creating a window and setting the look and feel. ExitListener.java A WindowListener with support to close the window. JAppletExample.java A simple applet (JApplet) created in Swing. Illustrates setting the look and feel, adding components to the content pane, and changing the layout to FlowLayout (default is BorderLayout). See JAppletExample.html (requires …
