Link to home
Start Free TrialLog in
Avatar of waffe
waffeFlag for United States of America

asked on

ZOrder problem with processing and eclipse

Hi,

I am using eclipse with another application called processing. Processing is a program that aids in the creation of java programs. You can find it here - http://processing.org/ However, I don't think my problem really matters whether or not you understand processing - basically my processing script is an applet(called PApplet) that is add to a JFrame container. The integration of code works very well except for a ZOrdering problem I am having. First, I create a JMenuBar with all the appropriate menu components. Second, I add my processing applet. When I run the code and use the meunBar which creates a pop up window, the window is always underneath the processing applet. WHY?!

Example code:
[code]
public class Frame extends JFrame {
      private static final long serialVersionUID = 1L;
      public static void main(String[] args) {
            new Frame();
      }
      public Frame() {
            super("Sequence Analyzer");
            WindowUtilities.setNativeLookAndFeel();
            addWindowListener(new ExitListener());
            Container content = getContentPane();
content.setBackground(Color.white);
            content.setPreferredSize(new Dimension(1250, 900));
            JMenuBar menuBar = new JMenuBar();
            menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
        
            JMenu menu = new JMenu("File");
            menuBar.add(menu);
             JMenuItem item = new JMenuItem("Item Label");
            JMenuItem item2 = new JMenuItem("Item Label");
            menu.add(item2);
            JMenuItem item3 = new JMenuItem("More Item Label");
            menu.add(item3);
            setJMenuBar(menuBar);

            //next I add the processing component
            System_Series_Analyzer ssa1 = new System_Series_Analyzer();
            ssa1.init();
content.add(ssa1,BorderLayout.CENTER);
pack();
setVisible(true);
      }
}
[\code]


I have tried putting the ssa1(processing component/applet) into other JPanels and JLayererd panes etc … nothing works, I have adjusted components with the command “setComponentZOrder” and nothing works.

I feel there is a way to do this, it is as if the processing code (ssa1) is missing something all the other components have that tell them to follow the rules of the components. Any Ideas?

Thanks,

Waffe
Avatar of Mick Barry
Mick Barry
Flag of Australia image

try:

JPopupMenu.setLightWeightPopupEnabled(false);
Avatar of waffe

ASKER

I do not get how you want me to implement this into my current code - can you please explain?

I have now looked into JPopupMenus and they will pop up above the PApplet! – Great, but how does that integrate into a JMenuBar?

Thanks,

waffe

          JPopupMenu.setLightWeightPopupEnabled(false);
          JMenuBar menuBar = new JMenuBar();
          menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));

> but how does that integrate into a JMenuBar?

menu bar uses a popup menu to display its menu.
Avatar of waffe

ASKER

This is the error I get in eclipse for this line - JPopupMenu.setLightWeightPopupEnabled(false);

"Cannot make a static reference to the non-static method setLightWeightPopupEnabled(boolean)
from the type JPopupMenu"

so JPopupMenu should know to point to the JMenuBar?

Thanks,

waffe
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of waffe

ASKER

Sweet! - Fantastic! - Assume! - I knew it was easy!

Thanks so much - I have been working on this for days trying ever combination I could think of and find. Next time, I'm asking you. LOL - thanks again!

waffe