package grafico1; import java.awt.*; import java.awt.event.*; import java.applet.*; public class GraficoApplet1 extends Applet { MiCanvas canvas; boolean isStandalone = false; Panel Panel3 = new Panel(); Panel Panel2 = new Panel(); Panel Panel5 = new Panel(); Panel Panel6 = new Panel(); BorderLayout borderLayout2 = new BorderLayout(); FlowLayout flowLayout1 = new FlowLayout(); FlowLayout flowLayout2 = new FlowLayout(); FlowLayout flowLayout5 = new FlowLayout(); FlowLayout flowLayout6 = new FlowLayout(); BorderLayout borderLayout8 = new BorderLayout(); BorderLayout borderLayout4 = new BorderLayout(); TextArea tDatos = new TextArea(); Button btnGrafica = new Button(); Button btnBorrar = new Button(); Checkbox chkBarra = new Checkbox(); Checkbox chkTarta = new Checkbox(); CheckboxGroup chkGrupo=new CheckboxGroup(); //Construct the applet public GraficoApplet1() { } //Initialize the applet public void init() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } //Component initialization public void jbInit() throws Exception{ int ancho = Integer.parseInt(this.getParameter("WIDTH")); int alto = Integer.parseInt(this.getParameter("HEIGHT")); this.setSize(new Dimension(ancho, alto)); canvas=new MiCanvas(); Panel3.setBackground(Color.lightGray); Panel2.setBackground(Color.gray); Panel3.setLayout(borderLayout2); Panel2.setLayout(borderLayout4); Panel5.setLayout(flowLayout5); Panel6.setLayout(flowLayout6); this.setLayout(borderLayout8); chkBarra.setLabel("Barras"); chkTarta.setLabel("Tarta"); chkTarta.setCheckboxGroup(chkGrupo); chkBarra.setCheckboxGroup(chkGrupo); chkGrupo.setSelectedCheckbox(chkBarra); tDatos.setColumns(10); tDatos.setRows(10); btnGrafica.setLabel("Gráfica"); btnGrafica.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnGrafica_actionPerformed(e); } }); btnBorrar.setLabel("Borrar"); btnBorrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnBorrar_actionPerformed(e); } }); this.add(Panel3, BorderLayout.WEST); this.add(canvas, BorderLayout.CENTER); Panel3.add(tDatos, BorderLayout.CENTER); Panel3.add(Panel2, BorderLayout.SOUTH); Panel2.add(Panel5, BorderLayout.NORTH); Panel2.add(Panel6, BorderLayout.CENTER); Panel5.add(btnGrafica, null); Panel5.add(btnBorrar, null); Panel6.add(chkBarra, null); Panel6.add(chkTarta, null); tDatos.requestFocus(); } void btnGrafica_actionPerformed(ActionEvent e) { String texto=tDatos.getText(); Checkbox radio=chkGrupo.getSelectedCheckbox(); int tipo=(radio.equals(chkBarra)) ? Grafico.BARRAS : Grafico.TARTA; canvas.setDatos(texto, tipo); } void btnBorrar_actionPerformed(ActionEvent e) { tDatos.setText(""); } }