Problemas con ventanas
Publicado por eva (1 intervención) el 21/01/2003 13:41:02
Este programa lo compila bien, pero al ejecutarlo me dice \"error en la descarga del applet. y no se porque.
import java.awt.*;
import java.awt.event.*;
public class window
{
public static void main(String[]args)
{
AppFrame f=new AppFrame();
f.setSize(200,200);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);.
}
});
f.show();
}
}
class AppFrame extends Frame implements ActionListener
{
Button b1,b2;
labelWindow window;
AppFrame()
{
setLayout(new FlowLayout());
b1=new Button(\"Ver Ventana\");
add(b1);
b1.addActionListener(this);
b2=new Button(\"Ocultar Ventana\");
add(b2);
b2.addActionListener(this);
window=new labelWindow(this);
window.setSize(200,200);
window.setLocation(300,300);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==b1)
{
window.setVisible(true);
}
if (e.getSource()==b2)
{
window.setVisible(false);
}
}
class labelWindow extends Window
{
Label etiqueta;
labelWindow(AppFrame af)
{
super(af);
setLayout(new FlowLayout());
etiqueta=new Label(\"Prueba\");
add(etiqueta);
}
}
}
import java.awt.*;
import java.awt.event.*;
public class window
{
public static void main(String[]args)
{
AppFrame f=new AppFrame();
f.setSize(200,200);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);.
}
});
f.show();
}
}
class AppFrame extends Frame implements ActionListener
{
Button b1,b2;
labelWindow window;
AppFrame()
{
setLayout(new FlowLayout());
b1=new Button(\"Ver Ventana\");
add(b1);
b1.addActionListener(this);
b2=new Button(\"Ocultar Ventana\");
add(b2);
b2.addActionListener(this);
window=new labelWindow(this);
window.setSize(200,200);
window.setLocation(300,300);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==b1)
{
window.setVisible(true);
}
if (e.getSource()==b2)
{
window.setVisible(false);
}
}
class labelWindow extends Window
{
Label etiqueta;
labelWindow(AppFrame af)
{
super(af);
setLayout(new FlowLayout());
etiqueta=new Label(\"Prueba\");
add(etiqueta);
}
}
}
Valora esta pregunta


0