Popupmenu & JComboBox shows up behind JInternalFrame on glasspane

Till Java 6 update 12 we used setLightWeightPopupEnabled on the popupmenus and JComboBoxes to make them appear on the toplevel when showing the glasspane. The situation is as followed:
- A Swing application
- Over the Swing application is a glasspane (extends JPanel)
- Added on the glasspane is a JInternalFrame (with on it components like a JPanel)
- When clicking with right mouse button, a popupmenu shows up. When using setLightWeightPopupEnabled it works perfectly
But when Java 6 update 12 was released, the popupmenu and JComboBox popup are shown behind the JInternalFrame (but above the glasspane).
SUN made some adjustments in the system. Does anyone knows how I can solve the problem as described above?

I made a simple code example which simulates the problem. The combobox popup falls behind the JInternalFrame. Another strange effect is when you try to resize the JInternalFrame, the JInternalFrame is closed.
import java.awt.BorderLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
public class PopupBehindInternalFrame
     public static void main (String args[]){
          JFrame frame = new JFrame();
          JPanel panel = new JPanel();
          frame.getContentPane().add(panel);
          frame.setSize(800, 600);
          frame.setVisible(true);
          JInternalFrame jif = new JInternalFrame();
          jif.setSize(400, 300);
          jif.setResizable(true);
          JPanel panelJif = new JPanel();
          jif.add(panelJif, BorderLayout.SOUTH);
          JComboBox cb = new JComboBox();
          cb.setSize(100, 10);
          cb.addItem("Test 1");
          cb.addItem("Test 2");
          cb.addItem("Test 3");
          cb.addItem("Test 4");
          cb.setLightWeightPopupEnabled(false);
          panelJif.add(cb);
          panel.getRootPane().setGlassPane(GlassPane.getInstance());
          GlassPane.getInstance().setVisible(true);
          GlassPane.getInstance().add(jif);
          jif.setVisible(true);
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JPanel;
public class GlassPane extends JPanel
     private static final long serialVersionUID = 1L;
     private static GlassPane glassPane = null;
     private Color color = new Color(0, 128, 128, 128);
     public GlassPane()
          setOpaque(false);
          setLayout(null);
          addMouseListener(new MouseAdapter()
          setInputVerifier(new InputVerifier()
               public boolean verify(JComponent input)
                    return !isVisible();
     protected void paintComponent(Graphics g)
          if (getComponents().length > 0)
               Graphics2D g2 = (Graphics2D) g.create();
               g2.setColor(color);
               g2.fillRect(0, 0, getWidth(), getHeight());
               g2.dispose();
          else
               super.paintComponent(g);
     public static GlassPane getInstance()
          if (glassPane == null)
               glassPane = new GlassPane();
          return glassPane;
}

Similar Messages

  • AWT PopupMenu not showing Chinese Characters

    Hi all.
    I have a mostly Swing application that must display English and Chinese characters. Changing the Swing components has been easy, however I am having problems changing an AWT PopupMenu that i use in combination with the new TrayIcon features of Java 6. TrayIcon requires an awt PopupMenu, so i cannot use a Swing JPopupMenu even if i wanted to.
    The problem is that instead of the correct words i am getting just empty squares, which seem to indicate a problem. I have tried setting the font to "SimSun" but this made no difference.
    I also tried this hack to use a JPopupMenu with Trayicon
    http://weblogs.java.net/blog/ixmal/archive/2006/05/using_jpopupmen.html
    This correctly showed the Chinese characters but it threw up lots of 'class cast' exceptions.
    My ideal solution would be to fix the problems with PopupMenu as apposed to fixing the class cast exception errors with the JPopMenu hack.
    Would anyone know why i cannot display Chinese characters in a AWT PopupMenu? have i missed something?
    Thanks
    Steven

    hi!
    check this out
    package com.ani;
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.Graphics;
    import java.awt.Label;
    import java.awt.Panel;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JLabel;
    public class showHindi extends Panel
         public showHindi()
              setLayout(new BorderLayout());
              String unicodeText = "\u0928\u092e\u0938\u094D\u0924\u0947";
              Font fn = new Font("Arial Unicode MS", Font.PLAIN, 32);
              Label lblText = new Label(unicodeText) {
                   @Override
                   public void paint(Graphics g)
                        //super.paint(g);
                        g.clearRect(0, 0, getWidth(), getHeight());
                        String str = getText();
                        g.drawChars(str.toCharArray(), 0, str.length(), 0, 30);
                        //System.out.println(getText());
              lblText.setFont(fn);
              JLabel lblText1 = new JLabel(unicodeText);
              lblText1.setFont(fn);
              add(lblText, BorderLayout.NORTH);
              add(lblText1, BorderLayout.SOUTH);
         public static void main(String[] args)
              Frame frm = new Frame("Test Hindi");
              frm.add(new showHindi());
              frm.setSize(600, 400);
              frm.addWindowListener(new WindowAdapter() {
                   @Override
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
              frm.setVisible(true);
    }this is working in my machine. i have used JLabel and Label both to just show you the difference. there is a flickering bug because of rendering, i hope you can manage that.
    regards
    Aniruddha

  • JComboBox shows "Java Applet Window" as last element

    Hey all,
    I am having a problem with using JComboBox. When I use JComboBox and show it in a JDialog (popup window), the last element of the drop down (JComboBox) is "Java Applet Window". This element is, however, not selectable. I want to get rid fo the "Java Applet Window" in my dropdown.
    This problem only happens when my applet opens up a JDialog that has the JComboBox, but does not happen when I add the JComboBox directly to the applet.
    I've read around in other forums that this has to do with security. I understand the need to show that a popup window (JDialog) is an applet window so the user doesn't mistake it as one of the native windows. But, the JComboBox is not a whole 'nother window, so why does it feel the needs to add that last line to designate it as a "Java Applet Window?"
    Thanks.
    Nina.

    My apologies, I did not clarify myself in my question. Sorry that I created misunderstandings of the problem - as evident in the response in the previous post from himanshug.
    I am using JDK 1.3.1
    I must use an applet, but all my components are standalone. They can be ran as a standalone application. But for deployment, we are using applets. It's easier to do applets so clients can access via browser than deploy a whole application installation on 50 machines halfway across the world.
    And no, there is no element in my list that says "Java Applet Window". When running my application standalone, the "Java Applet Window" does not appear as the last element in my drop down.
    The "Java Applet Window" also does NOT appear when I add the drop down directly to the applet. It only appears when the drop down is in a JDialog that gets launched by an applet.
    My problem: How to get rid of the "Java Applet Window" as it seems something is adding this to my dropdown. And it's not my code that is adding it.
    Thanks. I am also up'ing the duke dollars for a solution to this to 15.

  • Video on background layer is not showing up behind motion graphic.

    Hello Premiere experts,
    I'm using Premiere 6 on Windows machine and in the last few days I created a motion graphic that has an alpha channel for background transparency and it is placed on video track 2 and it works when I put a static image underneath it... that is, it shows the background image behind my motion graphic properly in the preview and the rendered video.
    But now I've put in an AVI video file behind my motion graphic, and I've tried putting this AVI file on video track 1A and 1B and rendering my movie, but I'm only getting my moving motion graphic on a black background in the preview and the rendered movie... no video from my video track 1A nor 1B is showing up in the background of my motion graphic... but when I put a static image, like a JPEG or a PSD behind my motion graphic, that does show up in the preview and in the final rendered movie.
    Shouldn't video be able to be seen behind a motion graphic?
    Thanks for any help,
    numetro

    Hello again Bill,
    My motion graphic creation has been successfull, like I said, when I place a static JPEG or PSD behind it... in that case, it shows my moving graphic and the still background image behind it, with successful transparency.
    The motion graphic creation is chronicled in the thread that you posted some replies to at this link...
    http://forums.adobe.com/thread/842405?tstart=0
    The workflow is...
    1) Import File: Bring in the graphic intended for motion - a PSD with a straight Alpha Channel for the graphic clip to be outlined for transparency... appears in the Project palette.
    2) Move that PSD graphic from the Project palette to the Video 2 slot in the Timeline... click to active that graphic in the Timeline... shows "crawling ants" around perimeter.
    3) Drag that graphic from the Video 2 slot in the Timeline palette to the Effects Control Palette... Motion Setup and Transparency Setup choices now appear in Effects Control palette for that graphic clip intended for motion.
    4) Create motion path in Motion Settings dialog box, select "Alpha: Use Clip's" and save settings... click OK and close dialog box.
    5) Select "Keytype: Alpha Channel" in Transparency Settings Dialog box... click OK and close dialog box.
    6) Import File: Bring in the AVI video intended for the background of the motion graphic - an AVI file that plays properly in Windows Media Player and IrfanView that was converted from a created WMV file to AVI format... AVI video file appears in the Project palette.
    7) Drag that AVI video clip to the Video 1A (or Video 1B) slot in the Timeline.
    8) Save the Project.
    9) Click enter for previewing  and/or  "Export Clip>Movie" to render movie.
    10) I just get an AVI file exported from Premiere 6 that is my moving motion graphic on a black backgroundl... showing NO video background as intended.
    As I said, when I'm using a still, static image as the background for my successful motion graphic, I get my motion graphic moving on the intended background... this is only a problem showing and rendering the motion graphic on top of the AVI video background.
    PS: I found that I need to double log-in each time I come to this forum now... logging in first from the "Sign In" link at the top right corner of the forums page, then it says I'm logged in, but will not give me the reply and actions options... then I finally figured out after multiple tries that I now need to additionally click the "Login/Register" link near the top of the page on the left... this has changed in the last few day.  I'm still not able to recieve email alerts of forum replies in spite of all three email alert pages being set to "YES" and "RECEIVE".
    Careful examination of my information above should make my workflow and prior actions clear.
    Thanks again,
    numetro

  • Fill in Illustrator is transparent and showing object behind. How do I make it a solid opaque fill?

    The fill here keeps showing the object behind (the stright line). How do I make it opaque and not show any object or lines behind it? Thanks!

    I may help to see the layers panel and the appearence panel. My guess is the line object has no fill and therefore you can see the red fill of the object behind it. In other words, if the red fill is to be on top of that line, then that object must be moved to the front or atleast one higher than the line object. The easiest way to do that is drag the object in the layers panel. Moving up the layers brings it forward and moving down the layers moves it towards the back. So the red layer should be above the line layer.
    But thats a guess since I can not see your layers or appearance panels.

  • Menu showing up behind component list

    I have created a file menu which has sub options.
    file
    -edit
    -view
    so i now create a List test = new List(10, false);
    and i add this into the gui (Container test1 = getContentPane();)
    now the problem is that when i click the file menu, it appears behind the list component..
    this problem only happens with the list component but if i replace this with jtextarea it works normally.
    how do i make the menu appear at the front?

    or call
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    at app start...
    Of course, it's still not a good idea to mix AWT and
    Swing components. But that default setting is useful
    if you are stuck using old 3rd party libraries built
    on AWT.Thanks, that's a good point.

  • Problem with: Show video behind the title

    In the editing window titles, the actualized image of the video behind the title is not the one that is displayed at this moment. Is the one I used just before and then i actualized it with photoshop. In the video the image is correctly displayed but in the editing window isn't it.
    Thank you,

    You need to postition the playhead over that particular clip in the timeline in order to see the video.

  • Popup of JComboBox shows on mouseclick but disappears on tab-key

    Hi everybody, I have a DefaultCellEditor with a ComboBox and I want the popup to be visible on focus, so I overwrite the changeSelection method of the JTable as follows:
    public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
                super.changeSelection(rowIndex, columnIndex, toggle, extend);
                super.editCellAt(rowIndex, columnIndex);
    } else if (getEditorComponent() instanceof JComboBox) {
                    JComboBox editor = (JComboBox)(getEditorComponent());
                    editor.requestFocusInWindow();
                    editor.showPopup();
                }This behaves like I want it to on mouseclicks. On Tab focus the popup is shown as long as I hold the tab key but disappears again after. What does the release of the Tab key does what the mouse button doesn't and can I change it?
    thanks for aswers

    Classic case of file naming.
    iOS is case-sensitive and requires the name of the file be exactly the same as that used in your code.
    MyImage01.png is not the same as myIMAGE01.PNG
    OS X, and thus the simulator, is not case-sensitive.

  • Is it possibe to place a slide show background behind a spry accordion

    i have found a background image transition slideshow on
    http://www.willmaster.com/library/features/background-image-transition-slide-show.php
    i cant get it to work yet - but am hoping to use it in my website
    http://mandyevansartist.com
    and was hoping someone could tell me if it will work or not - or if there is something i need to research for it to be possible ( gramps mentioned an "event listener" to load the javascript after the spry - is this one of those moments)
    kind regards
    mandy evans

    Try the jQuery Accordion instead http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=2174022
    Gramps

  • Showing HTML behind a flash movie

    Hi,
    I have a div layer containing a flash file which sits on top of some HTML. When the flash file is clicked, an animation is played. After this animation i want the flash file to disapear and the HTML behind the flash file to become clickable.
    The flash is an animation of a door opening, to reveal the HTML below it.
    I can make a flash file with a transparent background but the HTML below the flash layer is unclickable.
    Any ideas how i can make this clickable without refreshing the page? I have attached an example of my situation.
    Thanks,
    Tony

    >> P.S. Someone mentioned the "SWFObject method" but I
    was curious if there
    >> was
    another way to do this. Remember the main concern here is
    that search
    engines
    can pick up the text.
    That's the way to go if you want search engines to spider a
    Flash site.
    SWFObject writes the Flash content to a <DIV> on your
    page. Inside that div
    element, you place your HTML page... you can do dynamic stuff
    with PHP,
    whatever. If your user doesn't have Flash, or if a spider
    hits the page,
    they will see the HTML content within the div. If they do
    have Flash, then
    SWFObject overwrites the div with the Flash, and your user
    sees the Flash.
    Works a treat...
    If you want an example: www.arandell.com
    Turn off JavaScript and refresh, and you'll see the HTML
    version. Google
    spiders this site perfectly.
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Cannot paint over a jpeg suddenly, paint shows up behind on same layer

    When i place an image (jpeg) into photoshop and try to paint over it it will not let me. instead it paints behind the jpeg on that layer. Also, if I create a layer mask on the jpeg it will not paint over it to paint out areas.
    It always worked fine, this issue has come up within the last couple weeks.
    Help would be greatly appreciated, thank you.

    Hi artvector99,
    The first thing that comes to mind is that the mode of the Brush Tool is set to something other than Normal in the tool options bar.

  • My computer starts turning on with a black screen and the sleep light flashes, then the old screen from when my battery died shows up behind like a blue screen, then it dies again and wont restart? And yes my computer is fully charged now, HELP!

    So the problem now is in the question, but just before this problem the initial issue was my computer would start and turn on but the backlight appeared to be on its dimmest setting I could barely make out icons and the last page I viewed. Please help I'm in college and did not back up everything plus I desparately need my microsoft office for these classes!  Thank you!!!

    Hi kmdmsu08,
    If your computer's not turning completely on, I would try the steps in this article, especially step 4:
    Troubleshooting: My computer won't turn on
    http://support.apple.com/kb/TS1367
    Take care!
    - Ari

  • JMenuItem showing but behind a text area

    Hello, one of my JMenuItems is not able to be viewed correctly because it overlaps a text area and the text area is I guess shown over the top of it. Is there a way to have the JMenuItem be shown on top of the text area? This seems simple but I looked at the API's and couldn't find a method that would work.

    Okay, here is the code:
    JPanel right;
    JTextArea results;
    JScrollPanel scroll;
    right = new JPanel();
    results = new JTextArea();
    results.setSize(500, 500);
    results.setEditable(false);
    scroll = new JScrollPane(results);
    scroll.setWheelScrollingEnabled(true);
    scroll.add(results);
    right.add(scroll);Now I have all swing but the JScrollPane and JTextArea are like one white dot on my gui.

  • How to remove Wallpaper showing behind apps?

    Hi
    Just updated to OS 4 and the wallpaper now shows up behind the apps continually.
    Any ideas how to get rid of and get back to a plain black background?
    Thanks for any help....

    Sarge93 wrote:
    By doing this will you also lose the picture that you have at start up or just behind the icons? I'd like to leave my picture when the phone is locked, I just prefer the icon background be black.
    No, you can have a separate background for your front picture and behind your icons. Go to Settings->Wallpaper and when you select one and save it, it will ask you where you want it to go.

  • JInternalFrame not showing

    Hi guys,
    I have written a code that is supposed to show me a JInternalFrame on each button click, but it doesn't show.
    anybody can understand????
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class internalframe extends JFrame implements ActionListener{
         JDesktopPane pane = new JDesktopPane();
         JButton b1;
         public internalframe()
              Container surface = getContentPane();
              surface.setLayout(new FlowLayout());
              b1 = new JButton("new frame");
              surface.add(b1); b1.addActionListener(this);
              surface.add(pane);
         public static void main(String[] args)
              JFrame f = new internalframe();
              f.setSize(1024,768);
              f.setDefaultCloseOperation(EXIT_ON_CLOSE);
              f.setVisible(true);
         public void actionPerformed(ActionEvent ae)
              JInternalFrame frame = new JInternalFrame("internal frame",true,true,true,true);
              frame.setSize(100,100);
              frame.setLocation(50,100);
              frame.setVisible(true);
              frame.pack();
              pane.add(frame);          
    }also wanted to say that can i set the layout of the JInternalFrame to null ?? if yes then how can i used setBounds() to precisely located my components on JInternalFrame??????
    thanks

    Follow coding conventions. A class name should start with an uppercase letter.
    Add this line in your actionPerformed method:System.out.println(pane.getSize());Components added to a FlowLayout must have a preferredSize set directly or indirectly. The JButton's preferredSize will be computed from its text, but the JDesktopPane won't have a preferredSize unless you assign one.
    db
    edit There are other mistakes in the code, like setting the size of the newly constructed JInternalFrame and then calling pack(), which in the absence of any added components, will shrink the JInternalFrame to a title bar.
    Edited by: DarrylBurke

Maybe you are looking for

  • Creating a home and mobile iTunes library

    I'm trying to figure out how to manage the chaos of my home media.  I currently have the following equipment: Desktop Laptop WD Network HD WD Portable USB HD iPhone 4 iPod Nano I would like to make it so that my Network HD is the primary location of

  • Palm Desktop Conflict with Vista

    I use Windows Vista Home Premium, and I have installed Palm Desktop 6.2 to be used with a Tungsten E2.  Problem is that I get an AppCrash error message for the program Windows Media Player when the Palm Desktop software is installed on my computer. 

  • How do i watch tv shows after i purchase them, i can only view 30 second videos

    how do i watch tv shows after i purchase them on itunes, i can only view 30 second video?

  • How do I call a function from another file?

    In MainView.m I have one function -(void)goTell; I want to be able to call the function from SecondView.m. How do I do this? I have declared the function in the MainView.h and added #include MainView.h to SecondView.m, but it still doesn't work. This

  • Can't open file with keyboard!

    Hello, I just switched from windows and would like to open a file or application in finder just by hitting the return key. Is there any way to do this outside double clicking on the file?