package masterdavidjavabasico;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<APPLET
CODE=reemplazar.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
public class reemplazar extends Applet implements ActionListener
{
TextArea textarea1;
Button button1;
public void init()
{
textarea1 = new TextArea("Ya es la hora.", 5, 20,
TextArea.SCROLLBARS_BOTH);
add(textarea1);
button1 = new Button("Cambiar el texto seleccionado");
add(button1);
button1.addActionListener(this);
}
public void actionPerformed (ActionEvent e){
if(e.getSource() == button1){
textarea1.replaceRange("Hola desde Java!",
textarea1.getSelectionStart(),
textarea1.getSelectionEnd()) ;
}
}
}
Mostrando las entradas con la etiqueta boton. Mostrar todas las entradas
Mostrando las entradas con la etiqueta boton. Mostrar todas las entradas
multiplicadora usando cuadros de texto y un boton en un applet de java
package masterdavidjavabasico;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<APPLET
CODE=multiplicadora.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
public class multiplicadora extends Applet implements ActionListener {
TextField text1, text2, answertext;
Label multiplylabel;
Button button1;
public void init()
{
text1 = new TextField(10);
add(text1);
multiplylabel = new Label("*");
add(multiplylabel);
text2 = new TextField(10);
add(text2);
button1 = new Button("=");
add(button1);
button1.addActionListener(this);
answertext = new TextField(10);
add(answertext);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button1){
//int sum = Integer.parseInt(text1.getText()) + Integer.parseInt(text2.getText());
//answertext.setText(String.valueOf(sum));
int product = Integer.parseInt(text1.getText()) * Integer.parseInt(text2.getText());
answertext.setText(String.valueOf(product));
}
}
}
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<APPLET
CODE=multiplicadora.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
public class multiplicadora extends Applet implements ActionListener {
TextField text1, text2, answertext;
Label multiplylabel;
Button button1;
public void init()
{
text1 = new TextField(10);
add(text1);
multiplylabel = new Label("*");
add(multiplylabel);
text2 = new TextField(10);
add(text2);
button1 = new Button("=");
add(button1);
button1.addActionListener(this);
answertext = new TextField(10);
add(answertext);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button1){
//int sum = Integer.parseInt(text1.getText()) + Integer.parseInt(text2.getText());
//answertext.setText(String.valueOf(sum));
int product = Integer.parseInt(text1.getText()) * Integer.parseInt(text2.getText());
answertext.setText(String.valueOf(product));
}
}
}
Poner Un boton con accion en un applet de Java 2da Opcion
package masterdavidjavabasico;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<APPLET
CODE=boton2.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
public class boton2 extends Applet implements ActionListener {
TextField text1;
Button button1;
public void init()
{
text1 = new TextField(20);
add(text1);
button1 = new Button("Haga clic aqui!");
add(button1);
button1.setActionCommand("Boton apretado");
button1.addActionListener(this);
}
public void actionPerformed(ActionEvent event)
{
String msg = new String ("Hola desde Java!");
String command = event.getActionCommand();
if(command.equals("Boton apretado")){
text1.setText(msg);
}
}
}
Video Actualmente no Subido...
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<APPLET
CODE=boton2.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
public class boton2 extends Applet implements ActionListener {
TextField text1;
Button button1;
public void init()
{
text1 = new TextField(20);
add(text1);
button1 = new Button("Haga clic aqui!");
add(button1);
button1.setActionCommand("Boton apretado");
button1.addActionListener(this);
}
public void actionPerformed(ActionEvent event)
{
String msg = new String ("Hola desde Java!");
String command = event.getActionCommand();
if(command.equals("Boton apretado")){
text1.setText(msg);
}
}
}
Video Actualmente no Subido...
Poner Un boton con accion en un applet de Java
package masterdavidjavabasico;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class boton extends Applet implements ActionListener {
/*
<APPLET
CODE=boton.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
TextField text1;
Button button1;
public void init()
{
text1 = new TextField(20);
add(text1);
button1 = new Button("Haga clic aqui!");
add(button1);
button1.addActionListener(this);
}
public void actionPerformed(ActionEvent event)
{
String msg = new String ("Hola desde Java!");
if(event.getSource() == button1){
text1.setText(msg);
}
}
}
Video Actualmente no Subido....
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class boton extends Applet implements ActionListener {
/*
<APPLET
CODE=boton.class
WIDTH=200
HEIGHT=200 >
</APPLET>
*/
TextField text1;
Button button1;
public void init()
{
text1 = new TextField(20);
add(text1);
button1 = new Button("Haga clic aqui!");
add(button1);
button1.addActionListener(this);
}
public void actionPerformed(ActionEvent event)
{
String msg = new String ("Hola desde Java!");
if(event.getSource() == button1){
text1.setText(msg);
}
}
}
Video Actualmente no Subido....
Suscribirse a:
Entradas (Atom)