Ver la Versión Completa : Ayuda con JInternalFrame
Diavlo
08-04-2007, 02:58:08
Holassssss, necesito ayuda sobre el JInternalFrame, lo q quiero hacer es como una pagina HTML con un IFRAME, lo mismo quiero hacer en JAVA, la ventana es un JFrame y quiero poner un JInternalFrame q seria como el iframe en HTML, pero ya busque en Google me lei tutoriale y no tengi todavia como lograrlo.
La idea es q en una ventana con varios botones al hacer click en uno de ellos q se cargue una subventana como en html con el iframe, espero haberme explicado bien.
juliangh75
10-04-2007, 01:12:35
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class FormaInterna extends JInternalFrame implements Client {
private JTextArea txtArea=new JTextArea();
/**
* Constructor
*/
public FormaInterna(){
super("Forma Interna", true, true, true, true);
//AQUI SE DEBE INICIALIZAR EL OBJETO MEDIATOR
JPanel panel=(JPanel)this.getContentPane();
panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
panel.setBorder(BorderFactory.createEmptyBorder(15,15,15,15));
JButton btnEnvioMensaje=new JButton("Interno");
btnEnvioMensaje.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event) {
//AÑADIR LA INVOCACION AL METODO DE ENVIO DE MENSAJES
//broadcastEvent();
}
});
JPanel panelBotones=new JPanel();
panelBotones.setLayout(new BoxLayout(panelBotones,BoxLayout.LINE_AXIS));
panelBotones.add(btnEnvioMensaje);
panel.add(panelBotones);
panel.add(Box.createRigidArea(new Dimension(0,10)));
panel.add(new JScrollPane(txtArea));
this.setSize(new Dimension(300,300));
this.setVisible(true);
}
public void handleEvent() {
// TODO Auto-generated method stub
txtArea.setText(txtArea.getText() + "Recibiendo Notificacion\r\n" );
}
public void broadcastEvent() {
// TODO Auto-generated method stub
txtArea.setText(txtArea.getText() + "Enviando Notificacion\r\n");
mediator.broadcastEvent();
}
}
Genera esta clase.
y al boton del Frame ponle el siguiente codigo
FormaInterna frame = new FormaInterna();
frame.setVisible(true);
desktop.add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
Saludos
vBulletin v3.6.8, Derechos ©2000-2024, Jelsoft Enterprises Ltd.