
Ayuda con arreglos de objetos
Publicado por Alan (1 intervención) el 12/05/2014 04:09:05
Saludos esta es mi priemera vez posteando pero esque no tengo idea se supone que tengo que crear un arreglo de JFrames que me despliegue 4 ventanas cada una con diferente color, lo que tengo es una pequeña ventana con un boton que despliega las otras 4 ventanas pero no logro hacer que cada una tenga un color diferente siquiera logro hacer que una tenga un color diferente a las demas, les pido ayuda aqui les adjunto mi codigo Gracias por adelantado
public class SerializacionDeVentanas extends JFrame implements ActionListener
{
JButton boton;
int op;
JFrame Frames[] = new JFrame[4];
Container frame = getContentPane();
public static void main(String[] args)
{
SerializacionDeVentanas nue = new SerializacionDeVentanas();
nue.crearGUI();
nue.setSize(400,200);
nue.setVisible(true);
}
public void crearGUI()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
frame.setLayout(new FlowLayout());
boton = new JButton("Presiona");
frame.add(boton);
boton.addActionListener(this);
frame.setBackground(Color.red);
}
public void actionPerformed(ActionEvent arg0)
{
ejecucion();
}
public void ejecucion()
{
for(int i = 0; i < 4; i++)
{
Frames[i] = new JFrame();
Frames[i].setTitle("Ventana "+(i+1));
Frames[i].setSize(300,100);
Frames[i].setVisible(true);
}
}
}
public class SerializacionDeVentanas extends JFrame implements ActionListener
{
JButton boton;
int op;
JFrame Frames[] = new JFrame[4];
Container frame = getContentPane();
public static void main(String[] args)
{
SerializacionDeVentanas nue = new SerializacionDeVentanas();
nue.crearGUI();
nue.setSize(400,200);
nue.setVisible(true);
}
public void crearGUI()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
frame.setLayout(new FlowLayout());
boton = new JButton("Presiona");
frame.add(boton);
boton.addActionListener(this);
frame.setBackground(Color.red);
}
public void actionPerformed(ActionEvent arg0)
{
ejecucion();
}
public void ejecucion()
{
for(int i = 0; i < 4; i++)
{
Frames[i] = new JFrame();
Frames[i].setTitle("Ventana "+(i+1));
Frames[i].setSize(300,100);
Frames[i].setVisible(true);
}
}
}
Valora esta pregunta


0