posted 25 years ago
import java.awt.Graphics;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class IsReq extends Applet implements ActionListener {
private TextField text1, text2, text3;
private Button submit, clear;
private Label label1, label2, label3, label4;
private CheckboxGroup group;
private Checkbox check1, check2;
private DataOutputStream output;
public void init()
{
label1 = new Label( "Your name: " );
add( label1 );
text1 = new TextField( 25 );
add( text1 );
label2 = new Label( "Department:" );
add( label2 );
text2 = new TextField( 25 );
add( text2 );
label3 = new Label( "Date Required:" );
add( label3 );
text3 = new TextField( 8 );
add( text3 );
group = new CheckboxGroup();
label4 = new Label( "Problem Type:" );
add( label4 );
check1 = new Checkbox( "Software", group, false );
add( check1 );
check2 = new Checkbox( "Hardware", group, false );
add( check2 );
submit = new Button( "Submit" );
submit.addActionListener( this );
add( submit );
clear = new Button( "Clear" );
clear.addActionListener( this );
add( clear );
}
public void actionPerformed( ActionEvent e )
{
if ( e.getSource() == submit )
{
showStatus( "Submitting information..." );
try
{
output = new DataOutputStream(
new FileOutputStream( "temp.dat" ) );
output.writeUTF( "Name: " + text1.getText() );
output.close();
showStatus( "Information submitted!" );
}
catch( IOException a )
{
showStatus( a.toString() );
}
}
if ( e.getSource() == clear )
{
text1.setText( "" );
text2.setText( "" );
text3.setText( "" );
check1.setState( false );
check2.setState( false );
}
}
}
Let me know if you need anything else.