package armonico1; import java.awt.*; import java.awt.event.*; import java.applet.*; public class ArmonicoApplet1 extends Applet { Panel bevelPanel1 = new Panel(); Panel bevelPanel2 = new Panel(); Panel bevelPanel3 = new Panel(); Button btnDibuja = new Button(); Label label1 = new Label(); Choice chEstado = new Choice(); FlowLayout flowLayout1 = new FlowLayout(); FlowLayout flowLayout2 = new FlowLayout(); BorderLayout borderLayout1 = new BorderLayout(); BorderLayout borderLayout2 = new BorderLayout(); MiCanvas canvas; //Initialize the applet public void init() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } //Component initialization private 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(); bevelPanel1.setBackground(Color.lightGray); btnDibuja.setLabel("Dibuja"); btnDibuja.addActionListener(new ArmonicoApplet1_btnDibuja_actionAdapter(this)); label1.setText("Estado"); flowLayout1.setAlignment(0); flowLayout1.setVgap(1); flowLayout2.setVgap(1); for(int i=0; i<6; i++){ chEstado.addItem(String.valueOf(i)); } bevelPanel1.setLayout(borderLayout1); bevelPanel2.setBackground(Color.gray); bevelPanel2.setLayout(flowLayout2); bevelPanel3.setLayout(flowLayout1); this.setLayout(borderLayout2); this.add(bevelPanel1, BorderLayout.SOUTH); this.add(canvas, BorderLayout.CENTER); bevelPanel1.add(bevelPanel2, BorderLayout.EAST); bevelPanel2.add(btnDibuja, null); bevelPanel1.add(bevelPanel3, BorderLayout.CENTER); bevelPanel3.add(label1, null); bevelPanel3.add(chEstado, null); } void btnDibuja_actionPerformed(ActionEvent e) { int nEstado=chEstado.getSelectedIndex(); canvas.setNuevo(nEstado); } //Get Applet information public String getAppletInfo() { return "(C) Angel Franco García. Universidad del País Vasco (España)"; } } class ArmonicoApplet1_btnDibuja_actionAdapter implements java.awt.event.ActionListener { ArmonicoApplet1 adaptee; ArmonicoApplet1_btnDibuja_actionAdapter(ArmonicoApplet1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.btnDibuja_actionPerformed(e); } }