Hi there:
There is a simple but a little dirty solution (at least it's working
for me).
I add a JPopupMenu to a JMenu or a JMenuItem and all the menu
inherits the heavyweight caracteristic.
If you have read Sun's advices for using Swing components with
heavyweight components (awt, Canvas3D, etc.) you could see that you could
make Swing's JPopuMenu heavyweight.
I was trying to make a menu using JpopuMenu-s and when I added it to
a JMenu and JMenuItem component based menu I noticed that they worked like
heavyweight.
Just add it and tell me if it works in other codes.
// COMPONENT DECLARATION
// Menu
JMenuBar menu = new JMenuBar();
JMenu menuPanel = new JMenu();
JMenuItem smNuevo = new JMenuItem();
JMenu smAbrir = new JMenu();
// ADD THIS ONE ONLY FOR PASSING THE HEAVYWEIGHT CARACTERISTIC
JPopupMenu pmAbrir = new JPopupMenu();
JMenuItem smAbrirPlan = new JMenuItem();
JMenuItem smAbrirBodega = new JMenuItem();
JMenuItem smSalvar = new JMenuItem();
JMenuItem smSalvar_como = new JMenuItem();
// RE-IMPLEMENTING getMenu METHOD
public JMenuBar getMenu()
{
// Creamos las clases de eventos
eventosOrg_Op = new CEventosOrg_Op(this);
eventosDB = new CEventosDB(this);
// Creamos el menu
menu = new JMenuBar();
menuPanel = new JMenu();
menuPanel.setText("Panel");
menuPanel.setName(CIhmBASE.MENU_PANEL);
menuPanel.setActionCommand("Panel");
// Opcion de nuevo
smNuevo = new JMenuItem();
smNuevo.setText("Nuevo");
smNuevo.setName("Nuevo");
smNuevo.setToolTipText("Comenzar un nuevo planeamiento.");
ImageIcon iconoNuevo = null;
URL urlNuevo =
this.getClass().getClassLoader().getResource("es/indra/ihm/utiles/imagenes/n
uevo.gif");
if(urlNuevo != null)
{
iconoNuevo = new ImageIcon(urlNuevo,getTexto("Nuevo"));
}
smNuevo.setIcon(iconoNuevo);
smNuevo.setActionCommand("Nuevo");
smNuevo.addActionListener(eventosOrg_Op);
menuPanel.add(smNuevo);
// Opcion de abrir
smAbrir = new JMenu();
smAbrir.setText("Abrir");
smAbrir.setName("Abrir");
smAbrir.setToolTipText("Abrir un cuadro.");
ImageIcon iconoAbrir = null;
URL urlAbrir =
this.getClass().getClassLoader().getResource("es/indra/ihm/utiles/imagenes/o
pen.gif");
if(urlAbrir != null)
{
iconoAbrir = new ImageIcon(urlAbrir,getTexto("Abrir"));
}
smAbrir.setIcon(iconoAbrir);
smAbrir.setActionCommand("Abrir");
//smAbrir.addActionListener(eventosDB);
menuPanel.add(smAbrir);
// I ADD HERE A JPOPUP MENU -- ONLY SET IT TO HEAVYWEIGHT NOT SET ANY
EVENT AND IT DOESN´T APPEAR, IT´S ONLY
// TO PASS IT'S HEAVYWEIGHT CARACTERISTIC TO THE MENU
// Menu Popup
pmAbrir = new JPopupMenu("Tipos de documento");
//pmAbrir.setLabel("Tipos de documento");
pmAbrir.setDefaultLightWeightPopupEnabled(false);
pmAbrir.setLightWeightPopupEnabled(false);
pmAbrir.setName("Abrir popup");
smAbrir.add(pmAbrir);
// Abrir Plan
smAbrirPlan = new JMenuItem();
smAbrirPlan.setText("Abrir plan");
smAbrirPlan.setName("Abrir plan");
smAbrirPlan.setToolTipText("Abrir un planeamiento.");
smAbrirPlan.setActionCommand("Abrir_Plan");
smAbrirPlan.addActionListener(eventosDB);
smAbrir.add(smAbrirPlan);
// Abrir bodega
smAbrirBodega = new JMenuItem();
smAbrirBodega.setText("Abrir repositorio.");
smAbrirBodega.setName("Abrir repo.");
smAbrirBodega.setToolTipText("Abrir un repositorio.");
smAbrirBodega.setActionCommand("Abrir_Bodega");
smAbrirBodega.addActionListener(eventosDB);
smAbrir.add(smAbrirBodega);
// Opcion de salvar
smSalvar = new JMenuItem();
smSalvar.setText("Salvar");
smSalvar.setName("Salvar");
smSalvar.setToolTipText("Salvar un planeamiento.");
ImageIcon iconoSalvar = null;
URL urlSalvar =
this.getClass().getClassLoader().getResource("es/indra/ihm/utiles/imagenes/s
ave.gif");
if(urlSalvar != null)
{
iconoSalvar = new ImageIcon(urlSalvar,getTexto("Salvar"));
}
smSalvar.setIcon(iconoSalvar);
smSalvar.setActionCommand("Salvar");
smSalvar.addActionListener(eventosDB);
menuPanel.add(smSalvar);
// Opcion de salvar_como
smSalvar_como = new JMenuItem();
smSalvar_como.setText("Salvar_como");
smSalvar_como.setName("Salvar_como");
smSalvar_como.setToolTipText("Salvar un planeamiento con un nombre");
ImageIcon iconoSalvar_como = null;
URL urlSalvar_como =
this.getClass().getClassLoader().getResource("es/indra/ihm/utiles/imagenes/s
ave.gif");
if(urlSalvar_como != null)
{
iconoSalvar_como = new
ImageIcon(urlSalvar_como,getTexto("Salvar_como"));
}
smSalvar_como.setIcon(iconoSalvar_como);
smSalvar_como.setActionCommand("Salvar_como");
smSalvar_como.addActionListener(eventosDB);
menuPanel.add(smSalvar_como);
menu.add(menuPanel);
System.out.println("(CPanel) Estableciendo permisos para: " +
getPerfilUsuario().getDescripcion() + " --->Comparando: " +
getPerfilUsuario().getGrupo() + " con: " + CPerfilUsuario.LOGCOMLF);
switch(getPerfilUsuario().getGrupo())
{
case CPerfilUsuario.LOGCOMLF:
smNuevo.setEnabled(true);
smAbrir.setEnabled(true);
if(CManejadorDominio.getInstancia().getEstado()==CManejadorDominio.PLAN_CARG
ADO)
smSalvar.setEnabled(true);
else
smSalvar.setEnabled(false);
break;
default:
smNuevo.setEnabled(false);
smAbrir.setEnabled(false);
smSalvar.setEnabled(false);
break;
}
return menu;
}
When I add the JMenuBar to my application's applet I notice that all the
menu becomes heavyweight and works well over Canvas3D.
Let me know if it works.
Regards.
-----Original Message-----
From: Crossley, Allistair [mailto:[EMAIL PROTECTED]]
Sent: jueves 24 de mayo de 2001 17:17
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Java3D and Swing..
The only issue I have come up against is with the SWING JMenu. Because the
SWING components are lightweight and the Canvas3D inherits from the
heavyweight AWT Canvas, the lightweight menu will appear underneath the
Canvas3D...is this what you mean? I believe the team are trying to find a
resolution last time I heard.
Cheers,
Allistair Crossley
Web/New Media Consultant
Logica UK Ltd
Tel: 02074 463267
Mob: 07884 056274
-----Original Message-----
From: simone [mailto:[EMAIL PROTECTED]]
Sent: 24 May 2001 15:34
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Java3D and Swing..
Hi All,
I am programming an application where I have a menu built with Swing. In
my
menu option "New world", I include a functionality to generate a
Universe in
Java3D. However this Universe always open outside my application instead
of openning inside the screen.
I would like to ask you if it is really possible to use Java3D
associated
with Swing or does it work only with AWT?
Thank you for your attention.
[]s Simone.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".