Why Glass Pane becomes visible when resizing JInternalFrame?

This qustion has been asked _*here*_ but got no response.
Hello,
I've created a JFrame with JDesktop and one JInternalFrame on it. I've also added a glasspane (which draws a black circle only) to JFrame - it's invisible by default but when I resize JInternalFrame it shows up.. is this correct behavior? Why it is visible only when I resize and diappears when I release mouse button after resize? How I can make it invisible when resizing JInternalFrame? (Is removing JFrame's glasspane only solution?)import java.awt.Graphics;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
public class RunMe extends JFrame {
     public RunMe() {
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setBounds(10, 10, 800, 600);
          JDesktopPane desktop = new JDesktopPane();
          JInternalFrame testJIF = new JInternalFrame("test", true, true, true, true);
          testJIF.setBounds(10, 10, 100, 100);
          desktop.add(testJIF);
          testJIF.setVisible(true);
          this.add(desktop);
          this.setGlassPane(new MyGlassPane());
          this.setVisible(true);
     private class MyGlassPane extends JPanel {
          public MyGlassPane() {
               this.setOpaque(false);
          @Override
          protected void paintComponent(Graphics g) {
               g.fillOval(0, 0, 100, 100);
               super.paintComponent(g);
     public static void main(String[] args) {
          new RunMe();
}

First of all, thank you for being upfront about cross posting.
Whether this is "correct" behavior or not may be debatable, but it's certainly expected behavior. From the source of javax.swing.plaf.basic.BasicInternalFrameUI.BorderListener.mousePressed (towards the end of the method)Container c = frame.getTopLevelAncestor();
if (c instanceof RootPaneContainer) {
   Component glassPane = ((RootPaneContainer)c).getGlassPane();
   glassPane.setVisible(true);
   glassPane.setCursor(s);
}The glass pane is made visible to show the resize cursor.
It's set back to visible(false) in finishMouseReleased() which is invoked from mouseRelease and elsewhere (e;g; from cancelResize which is invoked from windowLostFocus)
Looks like you can't use the glass pane for whatever you had planned, the Swing designers have already used it for something else. Or this could be a workaround, depending on exactly what it is you're trying to do.@Override
protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (this.isOpaque()) {
      g.fillOval(0, 0, 100, 100);
}You could also declare and use a boolean flag, rather than using isOpaque (which may happen to be set/reset somewhere else in the Swing code ;-)
db

Similar Messages

  • How can I force an "invisible" object to become "visible" when a numeric value is entered?

    So I’m trying to force an “invisible” subform to switch to “visible” when a numeric value greater than or equal to 22 is input into a numeric field.
    I can’t get the following javascript code to work properly with any event. I’ve tried the change, calculate, validate, events and a few more to no avail. The only event that kind of works with the javascript code I’m using is the validate event. When I input the code into the validateevent, the invisible subform becomes visible when an amount equal to or greater than 22 is entered, but when ANY amount is input into this field, an error message pops up that says “NumericField4 validation failed” and the user has to click “Ok” to get rid of the pop up box.
    if (this.rawValue <= 22) {
            Approval23.presence = "hidden";
    if (this.rawValue >= 23) {
                Approval23.presence ="visible";
     Here’s a link to my .pdf: http://www.filedropper.com/salgovform
    The object field that the javascript code is contained in is called: NumericField4 (a.k.a. New Job Grade)
    The subform that I want to become visible when a number greater than 22 is input into NumericField4, is called Approval23.
    I’ve based the javascript code I used on information I gathered from the following thread and associated .pdf . . .
    Thread:
    http://forums.adobe.com/message/1982919
    PDF in thread with the javascript code:
    http://forums.adobe.com/servlet/JiveServlet/download/1981437-8059/Sample_SW.pdf
    I’m pretty sure I’m just missing one little thing that’s throwing everything off!
    Any help would be GREATLY appreciated.

    Hi,
    The following works in the exit event of the numeric field, where the language is set to JavaScript:
    if (this.rawValue <= 22) {
         Approval23.presence = "hidden";
    else {
         Approval23.presence = "visible";
    Here is your form: https://acrobat.com/#d=3gRNt6WBY2bE0K7en4CnSA
    Hope that helps,
    Niall

  • Why glass pane requires setLightWeightPopupEnabled(false)?

    In the code below, the glass pane is a JPanel which everybody knows is a Swing lightweight component. Then why JComboBox requires setLightWeightPopupEnabled(false) for its proper functioning? What on earth does the method, in the first place? Why glass pane? What oddity in the hell does the glass pane have that other Swing component doesn't, never?
    import javax.swing.*;
    import java.awt.*;
    public class GlassPaneOddity{
      public static void main(String[] args){
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel gp = new JPanel(new BorderLayout());
        frame.setGlassPane(gp);
        JComboBox cb
          = new JComboBox(new String[]{"alpha", "beta", "gamma", "delta"});
        cb.setLightWeightPopupEnabled(false); // why this line is so critical?
        gp.add(cb, BorderLayout.NORTH);
        frame.setSize(300, 300);
        frame.setVisible(true);
        gp.setVisible(true);
    }

    This is a quite interesting subject:
    The JRootPane has basically 2 components (although its layout is managing a few more):
    - the glasspane
    - the layered pane
    The z-order of components inside containers (so also for JRootPane) is defined to be:
    - index 0 is highest
    - index 1 is lower but higher than 2 etc...
    The glasspane is added always on index 0 (meaning highest)
    The layered pane is added after (meaning lower)
    Inside the layered pane are added:
    - the content pane
    - the menubar
    And the layout of the rootpane (RootLayout) takes care of the positioning of the glasspane, layered pane, content pane and the menubar.
    The layered pane has a layer for content (containing contentpane and menubar) but also for popups. The popups are shown on top of the content pane, but always under the glasspane.
    As far as I can see this seems to be in line with the explanation under the rootpane tutorial. And in line with Michael's observation.
    Hope it helps,
    Marcel

  • Why do images become blurry after resizing in lightroom?

    Please help.
    I do not know why the images are becoming blurry after resizing them in lightroom and exporting them?
    Any advice?
    Thanks.

    What pixel dimensions are you resizing them down to and what quality setting and sharpening settings are you specifying in the Export panel?

  • Why a MOS (Hiden before playing) becomes visible when I pass my finger over for scrolling the page?

    What could I do for activate it just with the button? I'd really appreciate your help. I need to publish the magazine this week

    I seem to have fixed it by putting <div  class="clearfloat"></div> after the navigation bar?

  • Why are objects becoming distorted when zoomed in?

    Lets say for example that I create a target shape at a relatively large size. I will then shrink it down to a more appropriate size and proceed to zoom in on the object. When I zoom in, the target becomes completely distorted. This is a problem that I came across recently as I have just upgraded from cs4 to cs5.1. Since Illustrator is vector based, objects should be crisp and look the same whether they are scaled to the size of the full artboard or down to just 1% of it, correct?
    I have posted a screen shot of the issue that I am running into below. The larger shape on the left is normal, and the shape on the right is that same shape just scaled down. Note: this shape does not have strokes, it is a solid fill. Thanks for any help in advance!

    This is what I had originally thought was the issue, so I created a new doument making sure to uncheck the box for the pixel grid. I then dragged the above shape into the new document and the problem persisted. However, when I recreated a similar shape in the new document, there was no distortion (as expected). It seems that for some reason an object created in a document with the pixel grid option turned on keeps those settings when carried into the new document.
    Is there a way around this or am I going to have to recreate everything in the new document?
    Thanks for tee response, btw!

  • SSIS: Why do columns become misaligned when importing flat files?

    Hi All
    I am stumped with the following.
    When I try to load a fixed length flat file into a table, the first few thousand records load correctly but then the columns start going out of sync.
    Visually it looks like the data is drifting off to the right. Below is what the table looks like when the load completes:
    Col1    Col2    Col3    Col4
    1        1         1         1
    1        1         1         1
      1        1         1         1
       1        1         1         1
        1        1         1         1
          1        1         1         1
            1        1         1         1
    Additional info:
    1. The file has 400 000 records.
    2. The first few thousand records load OK.
    3. Source file is a flat file, fixed length, no delimeters.
    4. All rows are same length, with LFCR.
    I tried using a script task to check with C# if all rows are the same length and has the same line terminator, and could  not pick up anything out of the ordinary.
    What could be the cause?

    Thank you for the reply.
    I discovered the source of the problem, but still don't understand how to solve it.
    There is one extra character in one of the columns every few thousand lines. This is the character: �
    I don't understand why all the rows following a corrupt row is shifted by one character and not just the effected row?
    Secondly, via a script task, SSIS indicates that the length of the row is still the same, despite the extra character. Is it possible that SSIS does not recognize this character and this is what is causing all columns to shift / mis-align?

  • Issue with hidden subforms and fields becoming visible when scrolling

    Hi all:
    Was testing an XFA form on a 13" macbook air when I noticed something odd: Page 1 (which had a presence of "hidden") became visible on-screen when scrolling down Page 2, which was set to visible.  For lack of a better description, Page 1 "bled through" the currently visible page but then disappeared after the scrolling action was complete.
    Here was the sequence:
    - FYI: 4 pages in the form; only one page is visible at a time. When the document opens, Page 1 is visible and all the others are hidden.
    - Opened on a MAC with Reader XI
    - Answered questions on Page 1 and clicked a "next" button which set Page1 to hidden and Page 2 to visible;
    - I zoomed in for a better view on Page 2 (again Pages 1, 3,4 are all "hidden" at this point)
    - When I placed two-fingers on the track pad and scrolled down, the bottom of hidden PAGE 1 was revealed during the scroll, not the bottom of Page 2.
    - When I lifted my fingers OFF the track pad, the bottom portion of Page 1 that became visible while scrolling disappeared and was replaced by the bottom of Page 2.
    Same thing happened with pages 3 & 4.  If I zoom in and scroll up, down, left or right using the track pad, Page 1 (even though it is set to hidden) "bleeds through" during the scroll and then disappears when fingers are lifted off the track pad.
    I've done some testing and it happens on Macs running Reader.  Mac with Acrobat and PCs with either Acrobat or Reader appear to be fine but not finished testing.
    Made a simple working example.  Again, be sure to open on a Mac with Reader if you want to see it happen. https://www.dropbox.com/s/jnf4uxntuzvrk7p/bleed%20through%20tests.pdf?dl=0
    Has anyone else experienced this?? How can we stop it from happening as it is extremely confusing to the end-user to have two different pages mixing together when scrolling.
    Thanks much.
    Brian

    Just reaching out to the community again on this.  Any thoughts or similar experiences?
    FYI, I tested the new Reader DC for this issue yesterday and it's still there.  Hidden pages still bleed through.

  • Why my iPhone becomes hot when using 3G

    I noticed recently that my iPhone becomes really hot specially when I'm on 3G. Is thar normal?

    It is normal for the phone to get hot when your using data such as YouTube videos, streaming music etc.. And as for the left speaker not working, the left speaker is a microphone, the right one is for sound. Don't worry, everything your iPhone is doing is normal.

  • Why do buttons become wider when switch Look & Feel

    When changed look and feel, all JToggleButtons become wider. I looked up
    this forum, but failed to get a solution. Please help me. Thank you in advance.

    Exactly!
    This question was asked just a few days ago.
    DB

  • Is it possible to insert a form in a image that only becomes visible when it is clicked?

    I am trying to add a basic subscription form to my landing page in dreamweaver. I have an example of it below, and so I am wondering how do I add a submission form to an image that isn't visable half the time?
    landing page example:  www.kandied.co
    Thank you,
    Kyle

    Hi
    The example you provided was created using Edge Animate.
    It could also be created in Dw using html and css. The two possibilities using html and css are -
    Use css transforms, transitions and animations, (this would give you the same result as when using Edge Animate, but with much less code) this would only work in modern browsers.
    Use absolute positioning, z-index and if required a little javascript. This would work across all browsers.
    PZ

  • Why does Safari become unresponsive when more than 20 windows are open

    Does 3.0.3 fix this?
    It is extremely annoying to wait for the beachball for minutes on end after a certain number of windows( 15 to 25) are open. You can't open a new one , you can't close old ones, you can't scroll, you can't use the back arrow, you can't bookmark.
    I have tried iFreeMem to clear memeory, Empty cache, Clear History, keeping desktop clear of icons, nothing works.
    Mi compadres in the Photoshop Forum believe it is a file swap issue and the disk is being accessed repeatedly, but I don't think so. Fire Fox does the same thing but allows more windows to be open.
    I don't have any unresponsive or slow issues with anything else. Safari has always done this since at least 10.4

    It's not that I'm unfamiliar with tabbed browsing, I use it three times a day in Firefox for work purposes. Firefox has a less awkward tabbing scheme, for one thing.
    I't just that I never thought there would be a problem following links and leaving the previous windows open.
    Moving 25 gigs of files off my hard disk showed a temporary improvement in the number of windows I could have open in both FF and Safari, but it seems to have reverted to about 20 in S and 40 in FF. This , I thought, indicated that it was indeed a swap file slowdown, but now I don't think so. The next time I start linking, I'll use Open in Tab and see what happens. Not tonight, too tired.

  • How can I block the keyboard using the glass pane ?

    I have a problem with the GlassPaneDemo from the Java Tutorial in
    the
    uiswing/components/example-swing
    folder.
    When the glass pane is visible it blocks the mouse input but the
    keyboard input doesn't. For example if the glass pane is visible and
    you press the F10 key, the menu will be activated. So the keyboard is
    not at all blocked.
    Can this problem be fixed ? I mean, to really block the keyboard
    when the glass pane is visible.
    Here I wrote down the specification written in the
    Java Documentation at the setGlassPane method from the
    RootPaneContainer interface:
    The glassPane is always the first child of the rootPane and the
    rootPanes layout manager ensures that it's always as big as the
    rootPane. By default it's transparent and not visible. It can be
    used to temporarily grab all keyboard and mouse input by adding
    listeners and the making it visible. by default it's not visible.
    As it may be seen, one says that the keyboard input can be blocked.
    HOW ?
    In hope that I resolve the problem, I have made some changes such as,
    adding a key listener to the glass pane add listening to the keyboard events,
    but I failed to fix the problem.
    Faithfully yours,
    Sarmis

    Here is an example that I think will work for you.
    Note the consume() call on the event object. I think that is what you're after.
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    public class Comparer extends JFrame implements ActionListener
        private GlassComponent myGlassPane;
        private JTextField myField;
        public Comparer()
            getContentPane().setLayout(new FlowLayout());
            getContentPane().add(myField = new JTextField(20));
            setGlassPane(myGlassPane = new GlassComponent());
            JButton theButton = new JButton("Glass");
            theButton.addActionListener(this);
            getContentPane().add(theButton);
            pack();
        public void actionPerformed(ActionEvent anEvent)
            myGlassPane.setVisible(true);       
        public static void main(String[] args)
            new Comparer().setVisible(true);       
    class GlassComponent extends JComponent implements AWTEventListener
        Window myParentWindow;
        public GlassComponent()
            super();
            this.setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) );
            setOpaque(false);
            addMouseListener( new MouseAdapter() {} );
        public void setVisible(boolean aVisibleBoolean)
            if(aVisibleBoolean)
                if(this.myParentWindow == null)
                    this.myParentWindow = SwingUtilities.windowForComponent(this);
                Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
            else
                Toolkit.getDefaultToolkit().removeAWTEventListener(this);
            super.setVisible(aVisibleBoolean);
        public void eventDispatched(AWTEvent anEvent)
            if(anEvent instanceof KeyEvent && anEvent.getSource() instanceof Component)
                if(SwingUtilities.windowForComponent( (Component)anEvent.getSource()) == this.myParentWindow )
                    ((KeyEvent)anEvent).consume();
    } HTH,
    Fredrik

  • Resizing glass pane

    Disabling GUI controlls causing the loose of the controls beauty.
    However, sometimes it is neccessary, to display the control in
    a uneditable mode, especially when the input can not be consumed.
    The perfect idea to maintain the beauty of the GUI contorls and
    make them uneditable, is to put a glass infront of them, so you just
    look from pattern :).
    This is a greate idea provided through GlassPane in the Swing API.
    But, still there is a limitation, why?
    The glass pane should be as large as the JRootPane, which means
    that you have to cover the whole top-level container :(.
    Take this example:
    I have a TabbedPane that consists of multiple tabs and the tabbed pane is loacted in a JApplet. I need to move between the tabs while making the controls in side the tabbs uneditable. Here I was constrained by the
    Glass Pane since it covers the whole applet's area, and no more accessability to the tabbs.
    Some one said: redispatch the event to the TabbedPane, I said: Ok, but
    no method in the TabbedPane tells me which tab has the x,y point.
    I suggest to make the GlassPane resizable, and to provide a method in
    the TabbedPane which takes the x,y a returns the index of the selected
    tab.
    Please what do you think ? :-)

    I think it is not useful because you can create your own glasspane for any component you want !
    Look at this thread :
    http://forum.java.sun.com/thread.jsp?forum=57&thread=268566
    I hope this helps,
    Denis

  • Did the update to OS 5...synched all my apps..then only 11 pages of apps are visible..the others are invisible..If I move an appfrom the 12 plus pages in itunes to a lower page...It becomes visible....WHY?..How can I get all 20 plus pages visible?

    Did the update to OS 5...synched all my apps..then only 11 pages of apps are visible..the others are invisible..If I move an appfrom the 12 plus pages in itunes to a lower page...It becomes visible....WHY?..How can I get all 20 plus pages visible?

    OK....First,you are right, OS 5 has the 11 page limit....you must create folders of Apps until you get below 11 pages of combined folders and apps...NOTE.....the upgrade to OS 5 killed all of my old folders and folder organizations...this may be an issue for all????.....I have over 300 apps so when the old folders went away...I was left with 20 plus pages....only 11 visible....It took me awhile to find out what happened....Since I have 64G it seems that 11 visible pages is a silly limit since the apps are on the machine...

Maybe you are looking for

  • How to Define Internal Table in Smartform

    Hello, I have some problem on define Internal Table in Smartform I define a Temp_IT_Gen Type LBBIL_IT_GEN in Global Definiations but i find that it is not available for me to append data into it, the error message is Temp_IT_Gen is not a Internal Tab

  • Can I install iLife '09 on a early 2006 model macbook?

    Does anybody know if a early 2006 model macbook can install iLife '09 or iLife '11? I just got my hard drive replaced and was able to upgrade from Tiger to Snow Leopard (I'm a little behind the times). I look at the requirements for iLife, and I thin

  • How to view System.out.print() messages for adapters in OIM 9.0.3

    I have created an adaptor for OIM from a java jar file. When that adaptor executes after some updates on tables it produces some execptions/error. I can not see the details of these exceptions as I do not know where is the standard output located whe

  • How can I add titles to a slideshow?

    When I do a slide shows using iPhoto 6 I would like to find a way of adding titles to the individual slides as it can be easy done in iMovie. Thus far I wasn't be able to find an intelligent way to do it. In the slideshow settings titles can be added

  • BUG?: Cannot rename email account with a case-chan...

    On my Lumia 820, I set up a mail account called: Blahblah Then I wanted to rename it to: BlahBlah The only difference was a change in case, not letters The phone said "You already have an account called "BlahBlah" " and didnt make the change Note, th