Foros del Web » Programación para mayores de 30 ;) » Java »

Ayuda con botones de seleccion en applet D:

Estas en el tema de Ayuda con botones de seleccion en applet D: en el foro de Java en Foros del Web. kien me puede echar la mano porfa en este programa lo unico q kiero esq me imprima los botones de seleccion multimple (checkbox ) y ...
  #1 (permalink)  
Antiguo 26/09/2010, 19:50
 
Fecha de Ingreso: septiembre-2010
Mensajes: 2
Antigüedad: 13 años, 6 meses
Puntos: 0
Ayuda con botones de seleccion en applet D:

kien me puede echar la mano porfa en este programa lo unico q kiero esq me imprima los botones de seleccion multimple (checkbox ) y los de radio (choice)
aa y no se como hacer q asta q le ponga al boton aceptar me depliegue el contenido D:


import java.awt.*;
import java.applet.*;

import javax.swing.JOptionPane;

public class bottones1 extends Applet{

TextField tfno,tfnom,tfdir,tfcarr, text1;
Label lno,lnom, ldir, lcarr,mate,act,sexo, tec;
Checkbox tareas, exposiciones,investigaciones,examen;
String no,nom,dir,carr,Carrera,Materia;

Choice Selector ,carrera;


CheckboxGroup Radio;
Checkbox m, f;

Button b1,b2,b3,b4,b5;

String[] vec =new String[5];

int x;

public void init(){

// Color colorRosa=new Color(0, 0, 175);

tec=new Label("INSTITUTO TECNOLOGICO SUPERIOR DE PANUCO");
//-----------------------------------
lno=new Label("No Control");
tfno=new TextField (10);
add(tec);
add(lno);
add(tfno);
//------------------
lnom= new Label ("nombre");
tfnom=new TextField(10);
add(lnom);
add(tfnom);
//------------------------------
ldir=new Label ("Dirección");
tfdir=new TextField(10);
add(ldir);
add(tfdir);


//------------------------------
carrera = new Choice();
lcarr =new Label ("carrera");
carrera.addItem("ISC");
carrera.addItem("IE");
carrera.addItem("II");
carrera.addItem("CP");
carrera.addItem("LIC.INFO");
add(lcarr);
add(carrera);


//---------------------------

Selector = new Choice();
mate=new Label("Materia");
Selector.addItem( "Topicos" );
Selector.addItem( "Matematicas " );
Selector.addItem( "Estructura de datps" );
add(mate);
add( Selector );

//-------------------------------

act= new Label("Actividades");

tareas = new Checkbox( "tareas");

exposiciones=new Checkbox("EXposiciones");
investigaciones =new Checkbox("Investigaciones");
examen=new Checkbox("Examen");

add(act);
add(tareas);

add(exposiciones);
add(examen);
add(investigaciones);


//------------------------------------------------------

Radio = new CheckboxGroup();
sexo=new Label("Sexo");
m=new Checkbox( "Masculino",Radio,false) ;
f=new Checkbox( "Femenino",Radio,false) ;
add(m);
add(f);
add(sexo);

//----------------------------------------------------------

b1 = new Button( "Aceptar");
add( b1 );
b2=new Button("Cancelar");
add(b2);
b3=new Button("Salir");
add(b3);
b4=new Button("Nuevo");
add(b4);
b5=new Button("Imprimir datos");
add(b5);
text1=new TextField(30);


setSize(800, 600);


}
public boolean action( Event evt,Object obj ) {


if(evt.target ==b1){

no = tfno.getText();
nom = tfnom.getText();
dir = tfdir.getText();
Carrera=carrera.getSelectedItem();
Materia=Selector.getSelectedItem();

if(x<5){

vec[x]=no+" "+nom+" "+dir+" "+Carrera+" "+Materia+" "+m+" "+f;
x++;

}
else{

JOptionPane.showMessageDialog(null,"Has llegado al limite de inserciones","Mensaje", 1);

}


repaint();

}

if(evt.target ==b2){

tfno.setText("");
tfnom.setText("");
tfdir.setText("");
carrera.select(0);
Selector.select(0);
no ="";
nom = "";
dir = "";
Carrera="";
Materia="";

}

if(evt.target ==b3){
System.exit(0);

}

if(evt.target ==b4){

vec[0]="";
vec[1]="";
vec[2]="";
vec[3]="";
vec[4]="";

tfno.setText("");
tfnom.setText("");
tfdir.setText("");
carrera.select(0);
Selector.select(0);

no ="";
nom = "";
dir = "";
Carrera="";
Materia="";
x=0;

}

if(evt.target==b5){
String r="";
for(int i=0;i<5;i++){

r=r+(i+1)+".- "+vec[i]+"\n";

}
JOptionPane.showMessageDialog(null,r,"Datos insertados", 1);
}

return true;
}

public void paint( Graphics g){
g.setColor(Color.red);
this.setBackground(Color.black);



lno.setLocation(50, 50);
tfno.setLocation(130, 50);

lnom.setLocation(230, 50);
tfnom.setLocation(290, 50);

ldir.setLocation(50, 120);
tfdir.setLocation(120, 120);

carrera.setLocation(290, 120);
lcarr.setLocation(230, 120);

Selector.setLocation(110, 200);
mate.setLocation(50, 200);

sexo.setLocation(400, 50);
m.setLocation(450,50);
f.setLocation(530,50);


act.setLocation(290,200);
tareas.setLocation(290, 220);

exposiciones.setLocation(290,250);
investigaciones.setLocation(290, 280);
examen.setLocation(290,310);

b1.setLocation(570,90);
b2.setLocation(570,120);
b3.setLocation(570,150);
b4.setLocation(570,180);
b5.setLocation(570,210);

g.drawString("Numero de control : "+no ,50, 280);
g.drawString("Nombre : "+nom ,50,310);
g.drawString("Direccion : "+dir ,50, 350);
g.drawString("Carrera : "+Carrera ,50,380);
g.drawString("Materia : "+Materia ,50,410);

}

}

Etiquetas: applet
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:30.