/* File: Download.java archiving, compressing, and downloading a server directory on-the-fly */ import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Download extends Applet implements ActionListener, ItemListener { private Label directoryLabel, formatLabel, fileLabel; private Choice directoryList, formatList; private Button downloadButton; public void init() { setBackground( Color.white ); directoryLabel = new Label( "Directory: ", Label.RIGHT ); directoryList = new Choice(); directoryList.addItem( "HTML" ); directoryList.addItem( "JavaScript" ); directoryList.addItem( "CGI" ); directoryList.addItem( "Java" ); directoryList.addItem( "JDBC" ); directoryList.addItem( "VRML" ); // Select "JavaScript" as the default menu choice: directoryList.select(1); formatLabel = new Label( " Format: ", Label.RIGHT ); formatList = new Choice(); formatList.addItem( ".zip" ); formatList.addItem( ".tar.Z" ); formatList.addItem( ".tar.gz" ); formatList.addItem( ".sit" ); // Select ".tar.gz" as the default menu choice: formatList.select(2); fileLabel = new Label(); fileLabel.setAlignment( Label.LEFT ); updateLabel(); downloadButton = new Button( "Download" ); int rows = 2, cols = 3; setLayout( new GridLayout( rows, cols ) ); add( directoryLabel ); add( directoryList ); add( fileLabel ); add( formatLabel ); add( formatList ); add( downloadButton ); directoryList.addItemListener( this ); formatList.addItemListener( this ); downloadButton.addActionListener( this ); } public void actionPerformed( ActionEvent event ) { showStatus( "Not yet implemented!" ); } public void itemStateChanged( ItemEvent event ) { updateLabel(); } public void updateLabel() { String s = directoryList.getSelectedItem(); s += formatList.getSelectedItem(); fileLabel.setText( "File: " + s ); } }