Java Reference
In-Depth Information
LISTING 11.11
//********************************************************************
// JukeBox.java Author: Lewis/Loftus
//
// Demonstrates the use of a combo box.
//********************************************************************
import
javax.swing.*;
public class
JukeBox
{
//-----------------------------------------------------------------
// Creates and displays the controls for a juke box.
//-----------------------------------------------------------------
public static void
main (String[] args)
{
JFrame frame =
new
JFrame ("Java Juke Box");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
JukeBoxControls controlPanel =
new
JukeBoxControls();
frame.getContentPane().add(controlPanel);
frame.pack();
frame.setVisible(
true
);
}
}
DISPLAY
Once created, the
URL
objects are used to create
AudioClip
objects using the static
newAudioClip
method of the
JApplet
class. The audio clips are stored in an array.
The first entry in the array, at index 0, is set to
null
. This entry corresponds to the
initial combo box option, which simply encourages the user to make a selection.
Search WWH ::
Custom Search