Es extraño, me encontre con este codigo, y no funciona, me pregunto porque no sirve?
package javaapplication2;
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame
{
public void Window()
{
this.setSize(400,500);
this.setTitle("Primer Aplicacion Swing");
this.setVisible(true);
}
public static void main(String []args)
{
Window();
JFrame jFrameWindow = new JFrame();
jFrameWindow.setSize(400,500);
/* se puede sustituir por pack() para
* que java calcule automaticamente el tama\~no
* que necesita.
*/
jFrameWindow.setTitle("Segunda Aplicacion Swing");
jFrameWindow.setVisible(true);
}
}
Yo lo haria de esta forma ... para mantener un mejor orden.
import javax.swing.*;
public class Ventana{
public static void main(String[] args)
{
NuevoFrame1 ventana1=new NuevoFrame1();
NuevoFrame2 ventana2=new NuevoFrame2();
}
}
class NuevoFrame1 extends JFrame{
public NuevoFrame1()
{
this.setSize(400,500);
this.setTitle("Primera Aplicacion Swing");
this.setVisible(true);
}
}
class NuevoFrame2 extends JFrame{
public NuevoFrame2()
{
this.setSize(400,500);
this.setTitle("Segunda Aplicacion Swing");
this.setVisible(true);
}
}
O sino de esta otra manera:
import javax.swing.*;
public class Ventana{
private static JFrame NuevoFrame2=new JFrame();
public static void main(String[] args)
{
NuevoFrame1 ventana1=new NuevoFrame1();
NuevoFrame2.setSize(400,500);
NuevoFrame2.setTitle("Segunda Aplicacion Swing");
NuevoFrame2.setVisible(true);
}
}
class NuevoFrame1 extends JFrame{
public NuevoFrame1()
{
this.setSize(400,500);
this.setTitle("Primera Aplicacion Swing");
this.setVisible(true);
}
}
excelentes datos, muchas gracias, ambos funcionaron perfectamente.
Gracias