Applet no me funciona...
HTML...
<HTML>
<HEAD>
<TITLE> A Simple Program </TITLE>
</HEAD>
<BODY>
<applet code="calculadora.class" width=180 height=150>
</APPLET>
</BODY>
</HTML>
JAVA...
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class calculadora extends Applet implements ActionListener
{
TextField text1, text2, text3;
Label multiplylabel;
Button b1,b2,b3,b4,b5;
public void init ()
{
text1 = new TextField(10);
add(text1);
text2 = new TextField(10);
add(text2);
b1 = new Button("+");
add(b1);
b1.addActionListener(this);
b2 = new Button("-");
add(b2);
b2.addActionListener(this);
b3 = new Button("*");
add(b3);
b3.addActionListener(this);
b4 = new Button("/");
add(b4);
b4.addActionListener(this);
b5 = new Button("%");
add(b5);
b5.addActionListener(this);
multiplylabel = new Label("Resultado");
add(multiplylabel);
text3 = new TextField(10);
add(text3);
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==b1)
{
double product = Double.parseDouble(text1.getText()) + Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else if (event.getSource()==b2)
{
double product = Double.parseDouble(text1.getText()) - Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else if (event.getSource()==b3)
{
double product = Double.parseDouble(text1.getText()) * Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else if (event.getSource()==b4)
{
double product = Double.parseDouble(text1.getText()) / Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else
{
double product = Double.parseDouble(text1.getText()) * Double.parseDouble(text2.getText())/100;
text3.setText(String.valueOf(product));}
}
}
<HTML>
<HEAD>
<TITLE> A Simple Program </TITLE>
</HEAD>
<BODY>
<applet code="calculadora.class" width=180 height=150>
</APPLET>
</BODY>
</HTML>
JAVA...
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class calculadora extends Applet implements ActionListener
{
TextField text1, text2, text3;
Label multiplylabel;
Button b1,b2,b3,b4,b5;
public void init ()
{
text1 = new TextField(10);
add(text1);
text2 = new TextField(10);
add(text2);
b1 = new Button("+");
add(b1);
b1.addActionListener(this);
b2 = new Button("-");
add(b2);
b2.addActionListener(this);
b3 = new Button("*");
add(b3);
b3.addActionListener(this);
b4 = new Button("/");
add(b4);
b4.addActionListener(this);
b5 = new Button("%");
add(b5);
b5.addActionListener(this);
multiplylabel = new Label("Resultado");
add(multiplylabel);
text3 = new TextField(10);
add(text3);
}
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==b1)
{
double product = Double.parseDouble(text1.getText()) + Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else if (event.getSource()==b2)
{
double product = Double.parseDouble(text1.getText()) - Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else if (event.getSource()==b3)
{
double product = Double.parseDouble(text1.getText()) * Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else if (event.getSource()==b4)
{
double product = Double.parseDouble(text1.getText()) / Double.parseDouble(text2.getText());
text3.setText(String.valueOf(product));}
else
{
double product = Double.parseDouble(text1.getText()) * Double.parseDouble(text2.getText())/100;
text3.setText(String.valueOf(product));}
}
}
1 respuesta
Respuesta de lusko
1