Hola, les cuento. Tengo una ventana principal, que llama a una secundaria.
El código que tengo es el siguiente: (no es muy complejo porque estoy haciendo pruebas)
Código:
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPanel;
public class Ventana1 extends JFrame implements ActionListener{
private JButton BotonAuto;
public static void main(String[] args)
{
Ventana1 ventana = new Ventana1();
ventana.setVisible(true);
}
public Ventana1 ()
{
inicializar();
}
private void inicializar() {
setTitle("MiPrograma");
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout(FlowLayout.CENTER, 3000, 50 ));
add("North", new JLabel("INDIQUE EL TIPO DE DATOS DE ENTRADA"));
BotonAuto = new JButton("AUTOMÁTICAMENTE");
add(BotonAuto);
BotonAuto.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();
if(source == BotonAuto)
{
Ventana2 ventana2 = new Ventana2(TipoVentana);
}
class Ventana2 extends JFrame {
private int TipoVentana;
public Ventana2 (int TipoVentana)
{
this.TipoVentana = TipoVentana;
inicializar();
}
private void inicializar() {
this.setTitle("Automáticamente");
this.setSize(800, 600);
this.setVisible(true);
this.setLayout(new FlowLayout(FlowLayout.CENTER, 3000, 50 ));
add("North", new JLabel("esto es una prueba"));
}
}
}
Mi problema es que necesito ponerle un botón a la ventana secundaria (para que luego al darle me imprima en la ventana un texto). Y al modificar esta parte para que me funcione el botón de la segunda ventana:
Código:
class Ventana2 extends JFrame implement ActionListener {
me da el siguiente error:
ventana1.Ventana1.Ventana2 is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener.
Y no se a qué se puede deber.
¿Alguna sugerencia?