• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ERROR IN SOURCE CODE

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I wrote the program, bu don't understand why it gives me 3 errors. All errors from AlertDialog Alert; line
import java.applet.Applet;
import java.awt.Button;
import java.awt.Component;
import java.awt.Container;
import java.awt.Label;
import java.awt.TextComponent;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventObject;
public class PayrollMessage extends Applet implements ActionListener {
TextField rate;
TextField newrate;
TextField time;
TextField payment;
float wt;
float ra;
float money;
Button cal;
Button clear;
String message;
String newra;
AlertDialog Alert;

{
Label label1 = new Label( "Input the payment per hour :" );
Label label2 = null;
Label label3 = null;
add( label1 );
rate = new TextField( 25 );
add( rate );
label2 = new Label( "Input work hours per week :" );
add( label2 );
time = new TextField( 25 );
add( time );
label3 = new Label( "The total payment is" );
add( label3 );
payment = new TextField( 25 );
add( payment );
payment.setEditable( false );
cal = new Button( "Calculate" );
add( cal );
cal.addActionListener( this );
clear = new Button( "Clear" );
add( clear );
clear.addActionListener( this );
}
public void actionPerformed(ActionEvent actionevent1)
{
if( ((EventObject) actionevent1).getSource() == clear )
{
rate.setText( " " );
time.setText( " " );
payment.setText( " " );
}
else
{
try
{
ra = Float.valueOf( rate.getText() ).floatValue();
wt = Float.valueOf( time.getText() ).floatValue();
if( (double) ra < 5.25 )
{
message = new String( "The pay rate cannot be less than $5.25 per hour!" );
if( AlertDialog.alert( message ) == true )
{
money = wt * ra;
payment.setText( Float.toString( money ) );
return;
}
}
else if( wt <= 40.0F )
{
money = wt * ra;
payment.setText( Float.toString( money ) );
return;
}
else
{
if( (double) ra < 5.25 | | wt <= 40.0F )
return;
money = (float) ((double) (40.0F * ra) + (double) ((wt - 40.0F) * ra) * 1.5);
payment.setText( Float.toString( money ) );
}
}
catch( NumberFormatException unused2 )
{
message = new String( "The input pay rate should be a number !!" );
AlertDialog.query( message );
ra = Float.valueOf( newra ).floatValue();
rate.setText( "" );
rate.setText( "newra" );
money = wt * ra;
payment.setText( Float.toString( money ) );
return;
}
}
}
}
Thanks
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is AlertDialog defined? I don't see any import in your code...
Junilu
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the file(class) AlertDialog. How can you a class and it's methods when it is not present.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was already answered in the Swing/AWT forum.
reply
    Bookmark Topic Watch Topic
  • New Topic