Java - ayuda con JInternalFrame

 
Vista:

ayuda con JInternalFrame

Publicado por ROBERTO (2 intervenciones) el 21/09/2005 16:42:12
tengo un problema con jinternalframes no se como agregar textfield y label a estos he logrado agregar un Jbuton pero aparece en todo en jinternal frame y no en una posicion especifica aqui esta mi codigo:

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Centros extends JFrame {

static JDesktopPane desktop = null; //ESTE OBJETO CONTIENE A LOS JInternalFrame
JPanel principal = new JPanel(new BorderLayout());
JPanel boton = new JPanel(new FlowLayout());
JMenuBar barra = new JMenuBar();

JMenu prin = new JMenu("MENU PRINCIPAL");
JCheckBoxMenuItem prin1 = new JCheckBoxMenuItem("Ingreso de Parametros");
JCheckBoxMenuItem prin2 = new JCheckBoxMenuItem("Mantencion de Tablas");
JMenuItem prin3 = new JMenuItem("Salir");

JMenu ingresos = new JMenu("INGRESOS y POSTULACIONES");
JCheckBoxMenuItem socios = new JCheckBoxMenuItem("Ingresar Nuevo Socio");
JMenu postulaciones = new JMenu("Postulacion a Centros");

JMenu ayu = new JMenu("AYUDA");
JCheckBoxMenuItem ayud = new JCheckBoxMenuItem("Ayuda General");
JCheckBoxMenuItem ayud2 = new JCheckBoxMenuItem("Acerca de...");

JMenu reservas = new JMenu("RESERVAS");
JMenu res = new JMenu("Reservar Hotel");

public Centros() {

super(" SISTEMA DE CENTROS RECREACIONALES");
prin1.setToolTipText("Carga el Formulario de Ingreso de Parametros");
prin2.setToolTipText("Carga el Formulario de Mantencion de Tablas");
prin3.setToolTipText("Sale del Sistema");

socios.setToolTipText("Carga el Formulario de Ingreso de Socios");
postulaciones.setToolTipText("Donde Desea Postular");

ayud.setToolTipText("Muestra la Ayuda del Sistema");
ayud2.setToolTipText("Muestra la Informacion del Sistema");

res.setToolTipText("Donde Desea Reservar");

desktop = new JDesktopPane();//INSTANCIAMOS EL OBJETO

principal.add(boton, BorderLayout.NORTH);
principal.add(desktop, BorderLayout.CENTER);

getContentPane().add(principal);
prin1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
crearVentana();
}
});


prin2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
crearVentana2();
}
});

socios.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
crearVentana3();
}
});

this.setSize(800, 600);
setResizable(false);
setJMenuBar(barra);

barra.add(prin);
barra.add(ingresos);
barra.add(reservas);
barra.add(ayu);

prin.add(prin1);
prin.addSeparator();
prin.add(prin2);
prin.addSeparator();
prin.add(prin3);

ingresos.add(socios);
ingresos.addSeparator();
ingresos.add(postulaciones);

postulaciones.add("Quisco");
postulaciones.addSeparator();
postulaciones.add("Maitencillo");
postulaciones.addSeparator();
postulaciones.add("Loncura");
postulaciones.addSeparator();
postulaciones.add("Rapel");

reservas.add(res);
res.add("Manutara");
res.addSeparator();
res.add("Tantauco");

ayu.add(ayud);
ayu.addSeparator();
ayu.add(ayud2);

prin3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});



}

public void crearVentana(){
Ventana frame = new Ventana();
frame.setVisible(true); //NECESARIO PARA QUE SE MUESTRE
desktop.add(frame);//AGREGO LA NUEVA VENTANA AL CONTENEDOR DE VENTANAS INTERNAS
try{
frame.setSelected(true);
}catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.OK_OPTION);
}
}



public void crearVentana2(){
Ventana2 frame = new Ventana2();
frame.setVisible(true); //NECESARIO PARA QUE SE MUESTRE
desktop.add(frame);//AGREGO LA NUEVA VENTANA AL CONTENEDOR DE VENTANAS INTERNAS
try{
frame.setSelected(true);
}catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.OK_OPTION);
}
}



public void crearVentana3(){
Ventana3 frame = new Ventana3();
frame.setVisible(true); //NECESARIO PARA QUE SE MUESTRE
desktop.add(frame);//AGREGO LA NUEVA VENTANA AL CONTENEDOR DE VENTANAS INTERNAS
try{
frame.setSelected(true);
}catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.OK_OPTION);
}
}



public static void main(String args[]) {
Centros c = new Centros();
c.show();
c.setLocationRelativeTo(null);

}
public boolean handleEvent(Event evt) {
if (evt.id == Event.WINDOW_DESTROY) {
System.exit(0);
}
return super.handleEvent(evt);

}
}
class Ventana extends JInternalFrame{


JPanel momo=null;

JButton bo = new JButton("INGRESAR");


public Ventana(){
super("Ingreso de Parametros");

setContentPane(bo);



setResizable(true);//resizable
setClosable(true); //closable
setMaximizable(true); //maximizable
setIconifiable(true);


setSize(800, 510);

}

}


class Ventana2 extends JInternalFrame{


public Ventana2(){
super("Mantencion de Tablas");

setResizable(true);//resizable
setClosable(true); //closable
setMaximizable(true); //maximizable
setIconifiable(true);//iconifiable


setSize(800, 510);

}

}



class Ventana3 extends JInternalFrame{


public Ventana3(){
super("Ingreso de Socios");

setResizable(true);//resizable
setClosable(true); //closable
setMaximizable(true); //maximizable
setIconifiable(true);//iconifiable


setSize(800, 510);

}

}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:ayuda con JInternalFrame

Publicado por Wilfredo Vargas Almendras (314 intervenciones) el 21/09/2005 21:13:39
Hola, el error que cometiste es establecer el contenedor principal a tu boton, lo que debes hacer es lo siguiente...

class Ventana extends JInternalFrame{

JPanel momo=null;

JButton bo = new JButton("INGRESAR");

public Ventana(){
super("Ingreso de Parametros");

//setContentPane(bo); Esto no es correcto

getContentPane().setLayout(null); /// puedes utiliozar cualquier layout
bo.setBounds(50,50,100,25);

getContentPane().add(bo); // y añadirlo de esta forma....

setResizable(true);//resizable
setClosable(true); //closable
setMaximizable(true); //maximizable
setIconifiable(true);

setSize(800, 510);

}

}

SALUDOS Wilfredo Vargas Almendras
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar