Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1140
  • Last Modified:

applet covering drop down menu

I have an application with an internal frame that opens just beneath the menu bar. when i open an applet in the internal frame and select a menu item the drop down menu dissapears behind the applet.
how do i solve this?
0
Samooramad
Asked:
Samooramad
  • 10
  • 5
  • 3
  • +2
1 Solution
 
CEHJCommented:
Make sure it's a JApplet - Swing and AWT don't mix well in this respect
0
 
maheshexpCommented:
disappears behnd the applet?????? :-?
0
 
SamooramadAuthor Commented:
i did.. it still doesn't work
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CEHJCommented:
Can you show how you add the JApplet?
0
 
maheshexpCommented:
can you show the code
0
 
SamooramadAuthor Commented:
package me;

import java.awt.*;
import java.lang.String;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.JApplet;
import java.applet.*;
import java.applet.AudioClip;
import dsvisualizer.node;
import java.text.*;
import me.*;
import java.awt.color.*;
import com.borland.jbcl.layout.*;

public class myFrame extends JFrame {
 JDesktopPane desktop = new JDesktopPane();
Applet Spots = new Spots();//Applet declaration

JMenuBar jMenuBar1 = new JMenuBar();
    .
    .
    .
menu items and border declarations
    .
    .
}
jMenuItem8.setText(" Sort");
    jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jMenuItem8_actionPerformed(e);
      }
    });

contentPane.setBorder(border2);
    contentPane.setBackground(Color.green);
    contentPane.setOpaque(true);
    contentPane.setLayout(borderLayout1);
    desktop.setBackground(Color.white);
    desktop.setOpaque(false);
    desktop.setLayout(borderLayout2);
     .
     .
     .
add menu items
    .
     .
contentPane.add(jMenuBar1, BorderLayout.NORTH);
    contentPane.add(desktop, BorderLayout.CENTER);
    contentPane.add(jToolBar1, BorderLayout.SOUTH);
}
void jMenuItem8_actionPerformed(ActionEvent e) {
      JInternalFrame[] openFrames = desktop.getAllFrames();
       for (int i = 0; i < openFrames.length; i++) {
        openFrames[i].dispose();
        }
        createspotsFrame();
}
//create internal frame for bubble sort
  protected void createspotsFrame() {
        MyInternalFrame frame = new MyInternalFrame();

        frame.getContentPane().add(bubble,null);
        frame.setTitle("spots");
        desktop.add(frame,BorderLayout.CENTER);
        frame.setOpaque(true);
        frame.setBackground(Color.white);
        frame.setSize(200,520);
        frame.setVisible(true);
        spots.init();
        }

/////////////////////////////
package me;

import javax.swing.JInternalFrame;
import java.awt.event.*;
import java.awt.*;

public class MyInternalFrame extends JInternalFrame {
    public MyInternalFrame() {
        super("",false, //resizable
              false, //closable
              false, //maximizable
              false);//iconifiable

       setSize(300,300);
       setLocation(100, 100);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    }
  private void jbInit() throws Exception {
  }
}

0
 
SamooramadAuthor Commented:
sorry
frame.getContentPane().add(bubble,null);
is actually:
frame.getContentPane().add(spots,null);
0
 
CEHJCommented:
Firstly, i can see from your code that the applet is an Applet, not a JApplet. Secondly i don't see where you're adding it to anything anyway
0
 
CEHJCommented:
I posted that before seeing your last. Don't you mean

frame.getContentPane().add(Spots,null);

?

If so, you must call init() on the applet before adding it
0
 
SamooramadAuthor Commented:
yes i do
0
 
SamooramadAuthor Commented:
>>If so, you must call init() on the applet before adding it
but the applet works anyway
the only problem is its hiding the drop down menus of the menubar
0
 
SamooramadAuthor Commented:
>>Firstly, i can see from your code that the applet is an Applet, not a JApplet
like i said ...i tried changing to JApplet but still had the same problem
0
 
CEHJCommented:
Hmm. What happens when you change

>>frame.getContentPane().add(spots,null);

to

frame.getContentPane().add(spots, BorderLayout.CENTER);

or something other than null?
0
 
SamooramadAuthor Commented:
still doesn't work :(
0
 
JavaInTheMorningCommented:
Well...
That's an ugly solution but you can try it:
Add a listener (if you don't already have one) to your menu, so that you'd know when the user is clicking it. When the user is clicking it, do the following:
spots.resize(0,0);

Then, when the user made his choice, resize spots back to the original size.

Itsik
0
 
objectsCommented:
add the following call before you create your menu:

JPoupMenu.setDefaultLightWeightPopupEnabled(false);
0
 
SamooramadAuthor Commented:
JavaInTheMorning,
would you mind giving me an example?
0
 
SamooramadAuthor Commented:
object,
add the following call before you create your menu:
do you mean before I add items to the menu bar or before adding the menubar to the contentPane?
0
 
SamooramadAuthor Commented:
never mind objects that worked!
thank you
0
 
objectsCommented:
u can add it to your main before you create your frame.
0
 
objectsCommented:
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 10
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now