Glass pane

Hello,
I have a question about the following program.
import java.awt.*;
import javax.swing.*;
public class Test extends JApplet {
public void init() {
JButton button = new JButton("CLICK!");
getContentPane().setLayout(new GridLayout(1, 1));
getContentPane().add(button);
GlassPane glassPane = new GlassPane();
setGlassPane(glassPane);
glassPane.setOpaque(false);
glassPane.setVisible(true);
class GlassPane extends JPanel {
public void paintComponent(Graphics g) {
g.fillRect(0, 0, 50, 50);
It works just like the way I want but, when rectangle is visible I don't want user to be able to click on the button. Is there a method that can help me do that or is there anything else you can think of?
Thanks for your time.
Berk Can Celebisoy

I don't want it clickable but I want visible as it
is.
Berk.'enabled' and 'visible' are too different animals.
.setEnabled(false) will leave it visible, but make it unclickable

Similar Messages

  • Different glass pane behaviour in Mac and Windows

    I have an application with a glass pane containing a panel that is set non-opaque. On this panel I do amouse drag and draw a transparent rectangle when the mouse is released. On the main frame below there is a picture. This works fine on a Mac, I end up with a transparent rectangle on top of the bottom frame. However, when I run the same program on a Windows machine, as soon as the mouse is released, the rectangle is drawn and the glass pane layer gets opaque, hiding the picture below.
    Any solutions?

    >
    I'd suggest you to post some code. ...>Some code is good, but an SSCCE is better. ;-)

  • Glass pane  how to use it?

    please i am new to Java i wanted toknow more about the glass pane component why cant it be use as the content pane .

    google is your friend
    http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html#glasspane

  • Glass Pane( preventUserInput when user clicks on Search button in af:query)

    Hi,
    We are using glass pane implementation on a search screen.
    When I click on Search button in af:query component (having selectInputDate (Date Picker) components)., glass pane is firing correctly,
    but second time when I am trying to select date using Date Picker (and Change the Month), glass pane is fired (entering into handleBusyState function) and calendar popup is not opening.
    I folled the below article for implementation.
    url: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf used for glassPane implementation.
    Can any one help me for this issue.

    Hi am using the following code (javascript) -- Jdev(11.1.1.3)
    function preventUserInput(evt){   
    var eventSource = evt.getSource();
    var popup1 = eventSource.findComponent("showGlassPanePopup");
    if (popup1 != null){
    AdfPage.PAGE.addBusyStateListener(popup1,handleBusyState);
    evt.preventUserInput();
    //JavaScript call back handler
    function handleBusyState(evt){ 
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('r3:0:r1:0:showGlassPanePopup');
    if(popup!=null){
    if (evt.isBusy()){
    popup.show();
    } else if (popup.isPopupVisible()) {
    popup.hide();
    AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState);
    ... End of Code..
    This line .. (popup.isPopupVisible()) removes the Popup , if popup is visible...
    If u want the view am using..
    SELECT EMPNO , DEPTNO , HIREDATE FROM EMPLOYEE (sample Application i have created), created a view criteria for this..
    ( (EMPNO = :empNum ) AND (DEPTNO = :deptNum ) AND (TO_CHAR( TO_TIMESTAMP(HIREDATE), 'yyyy-mm-dd hh24:mi:ss.ff') = :hireDts ) ) (View Criteria)
    .. <af:clientListener method="enforcePreventUserInput" type="query"/> (added for af:query)
    Popup Used: <af:popup id="showGlassPanePopup" contentDelivery="immediate">
    <af:dialog id="d2" type="none" closeIconVisible="false">
    <af:panelGroupLayout id="panelGroupLayout1" layout="vertical">
    <af:outputText value="Processing......Please Wait.." id="ot97"/>
    </af:panelGroupLayout>
    </af:dialog>
    </af:popup>
    1. When i click search for first time.. it is showing like -- Processing .. Please Wait'
    2. When i click select Date picker it is show -- Processing .. Please Wait'
    and show a calender popup window.. If we change the month ... it will again show like -- Processing .. Please Wait'
    and it will not open calender window.
    Please Help me on this..Am facing trouble due to this.
    Thanks in Advance.
    Edited by: user10115793 on Nov 15, 2011 12:58 AM

  • Splitpane under a glass pane

    I have a lot of components under a transparent glass pane.
    I dispatch mouse events captured by the topmost glasspane
    to underling components converting coordinates with
    SwingUtilities methods.
    Everything works fine except a splitpane. When a try to
    resize one of the components it contains, nothing happens.
    validate(), repaint() methods invoked on the split at event
    dispatching time are completely unusefull.
    The glasspane gets MouseListener and MouseMotionListener
    events.
    Whats the trik to get the split working?
    Thanks.

    Thanks for the response. The application I am writing has a split pane down the middle, with a glasspane on each side already over what are called View containers. However, a View in either of those containers may contain another splitpane.
    I was hoping for a simpler framework style solution such that the developers of a View would not be required to implement their own glasspane functionality and have to tie into the active View management.
    My current recourse is to utilize the KeyboardFocusManager to attempt to accomplish what I was trying to do with the GlassPane: set the active view based on selection in any portion of the View (component or empty Panel area). Got the first half working pretty easily, I expect the second have to be quite more challenging.
    Thanks again.

  • 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

  • Redrawing glass pane

    Hi, I have a program where I am storing information which takes up some time. I created a progressbar and put it in the glass pane and update it several times during this process. Below i posted a simplified example. In this example it works as it should and the progress bar gets redrawn every time I call pb.update().
    However the code I use in the application is complex and the progress bar does not get drawn onto the screen until the method finishes, which is too late. I have tried putting repaint() calls at the end of the update() method, but that does not work. Although the program enters the paint method, nothing gets drawn onto the screen. The only thing that helped was paintimmediately(), which painted the contentPane() on the screen, but did not paint the glassPane.
    My question is, how does java determine when to redraw the glass pane, since I don't have a repaint() call anywhere. Is there a way to force java to draw the glasspane on the screen? Or if you have any tips as to what could be the problem.
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class Main extends JFrame {
       public Main() {
         setSize(200,50);
         setVisible(true);
         ProgressBar pb = new ProgressBar();
         setGlassPane(pb);
         pb.setVisible(true);
         Thread t = new Thread();
         try {
             t.sleep(1000);
             pb.update();
             t.sleep(1000);
             pb.update();
             t.sleep(1000);
             pb.update();
             t.sleep(1000);
             pb.update();
             t.sleep(300);
         } catch ( Exception e ) {}
         pb.setVisible(false);
        public static void main(String[] args) {
         JFrame.setDefaultLookAndFeelDecorated(true);
         Main app = new Main();
         app.addWindowListener(
            new WindowAdapter() {
               public void windowClosing( WindowEvent e )
              System.exit( 0 );
    public class ProgressBar extends JComponent {
    JProgressBar jProg;
    int cur;
        public ProgressBar () {
         init();
         cur = 0;
         setOpaque(false);
        public void init() {
            jProg = new javax.swing.JProgressBar(0,100);
         jProg.setValue(0);
         jProg.setStringPainted(true);
         jProg.setSize(200,30);
         add(jProg);
       public void update() {
         cur += 25;
         jProg.setValue(cur);
    }

    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html]How to Use Progress Bars for a working example. You should also read the section from the tutorial on "How to Use Threads" since you are not using the Thread correctly in you simple demo.

  • 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

  • Glass pane in popup

    I have a button on click i will load a popup window. I want to show a glass pane and splash screen in the popup. How can I do that on click of parent screen command button ?
    <af:commandImageLink text="#{row.ProjectName}" id="cil1"
    action="dialog:callEditProject"
    useWindow="true"
    windowEmbedStyle="inlineDocument"
    windowModalityType="applicationModal"
    windowHeight="500" windowWidth="900"
    launchListener="#{EditProjectLaunchBean.launchEditProject}"/>
    I am able to do a glasspane splash screen on the same window using the example
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf
    Thanks
    Suneesh

    I got the same problem. Is there any solution yet??

  • Glass pane question.

    I want to put a glass pane to enable some document markup/line drawing. The application has a JEditorPane and some JPanels, and two JTextAreas.
    I would like to be able to draw a line from a fixed position (JTextArea) into a JEditorPane.
    Is this quite simple to do? Does anyone know where I can look for some ideas/examples?
    Thanks

    It isn't that hard to do, but I recommend using JLayeredPane instead of the glass pane. The glass pane has the unique property of being above all other container, but also has important functionality that relays events down through the content pane.
    You can create a subclass of JPanel that is transparent (setOpaque(false)) and insert this into a level of the JLayeredPane instance using a sufficiently high level (greater than POPUP_LAYER) and draw on the panel. Whatever you draw will overlay the content in all the lower layers of the content pane.
    Be forewarned - the layered pane uses coordinates that are relative to the root pane, so you will have to convert the coordinates of your component positions when you draw.
    Wish I had an example I could give you - any questions, feel free to e-mail me.
    Mitch Goldstein
    Author, HARDCORE JFC
    [email protected]

  • Glass Pane Effect in JDev.

    i experts,
    I am using JDev 11.1.1.5.0, I am using the following code for rendering messages.
                        FacesMessage fm = new FacesMessage("Thank you for Contacting us!!!");
                        fm.setSeverity(fm.SEVERITY_WARN);
                        FacesContext fc = FacesContext.getCurrentInstance();
                        fc.addMessage(null, fm);Now my problem is to make a glass pane effect behind the faces message. As same as the viewing popup. I should restrict my user from editing the form until I close my faces message. If this question sounds silly, kindly apologize me.
    Thanks,
    -Arun

    you mean
    <af:dialog modal="true">modal="true" means that the dialog does not allow the user to make changes on the base page until the dialog is closed. A non-modal dialog will allow the user to make changes on the base page; if the user navigates away from the base page, the dialog will close.
    Timo

  • Glass pane effect in faces message.

    Hi experts,
    I am using JDev 11.1.1.5.0, I am using the following code for rendering messages.
                        FacesMessage fm = new FacesMessage("Thank you for Contacting us!!!");
                        fm.setSeverity(fm.SEVERITY_WARN);
                        FacesContext fc = FacesContext.getCurrentInstance();
                        fc.addMessage(null, fm);Now my problem is to make a glass pane effect behind the faces message. As same as the viewing popup. I should restrict my user from editing the form until I close my faces message. If this question sounds silly, kindly apologize me.
    Thanks,
    -Arun

    duplicate of {thread:id=2534727}
    Timo

  • Glass Pane with ADF jsfx

    Hi,
    Does anybody know how to create a glass pane in a ADF-jsfx page?
    My problem is how to avoid the user to click in multiple checkboxes in a table that has a change listener in each row (checkbox).
    While the request is being submitted, after the user clicked on a checkbox, the user is still allowed to perform other actions on the form, mixing (messing) up...
    I would like a blocking="true" like behavior for other components besides buttons.
    A glass pane would do it...
    Thanks for any tips..

    Thanks Frank.
    I tried some things such as changing the cursor (wait) but it is not good enough because some components override this.
    A valueChangeListener wouldn't do it because my problem is the latency between request-response. After I get the response I have no problem.
    The problem is the time between the request and the response. It would have to be done on the client side with javascript after a page event (like onclick).

  • Mouse click position on Glass Pane

    Hi,
    I'm working on a program following this example about Glass Panes:
    http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
    I'm having a problem whith code to detect the component I click on:
    Point glassPanePoint = e.getPoint();
    Container container = contentPane;
    Point containerPoint = SwingUtilities.convertPoint(
                                    glassPane,
                                    glassPanePoint,
                                    contentPane);
    if (containerPoint.y < 0) { //we're not in the content pane
        //Could have special code to handle mouse events over
        //the menu bar or non-system window decorations, such as
        //the ones provided by the Java look and feel.
    } else {
        //The mouse event is probably over the content pane.
        //Find out exactly which component it's over.
        Component component =
            SwingUtilities.getDeepestComponentAt(
                                    container,
                                    containerPoint.x,
                                    containerPoint.y);
    }I don't know if is e.getPoint(), SwingUtilities.convertPoint or SwingUtilities.getDeepestComponentAt, but
    getDeepestComponentAt doesn't return the component I click on. It returns the component which is a little bit down
    on screen.
    Anyone has the same problem and knows how to avoit it?
    Thanks

    The problem was frame borders. With this adjustments works properly:
    final Window window = SwingUtilities.getWindowAncestor(this);
    final Container container = getRootPane().getContentPane();
    final Point pWindow = window.getLocationOnScreen();
    final Point pContainer = container.getLocationOnScreen();
    final int iAdjustmentX = (int)pContainer.getX() - (int)pWindow.getX();
    final int iAdjustmentY = (int)pContainer.getY() - (int)pWindow.getY();
    final MouseEvent mouseEvent = (MouseEvent)event;
    final Point pMouse = mouseEvent.getPoint();
    final Point glassPanePoint = new Point((int)pMouse.getX() - iAdjustmentX, (int)pMouse.getY() - iAdjustmentY);

  • Existing "Glass Panes" Open Template upscaled to HDV?

    My apologies if this has been answered before. Searched around but couldn't find anything similar. I'm editing a project in HDV (1080i60, 1440x1080). Want to export several clips into the various boxes of the Glass Panes Open template, which only seems to be available in NTSC DV format size. I exported the clips out of FCP 5 as NTSC DV clips into Motion (2.1.2) and they look fine in Motion, but I can't seem to find the right setting to upconvert to HDV for importing back into the FCP timeline. I tried opening a project with the HDV presets, but as soon as I open the Glass Panes template it reverts back to 4x3. Also tried various settings at the output stage, but still no joy.
    Any suggestions would be appreciated.
    Thanks

    Peter,
    Thanks for the reply. For point 1, when you say scale the clips in the new timeline I'm assuming you mean the FCP timeline? I already tried outputting from Motion in the Glass template's DV aspect ratio and then scaling it up in FCP, but there was significant aliasing, as you might imagine.
    I'll try setting up an HDV project in Motion and cutting and pasting as you suggested. It's worth a try.
    Thanks for your help.
    Dick

Maybe you are looking for

  • IPhone drop down menu not showing in iTunes

    whenever i connect my iphone to itunes it no longer shows the drop down menu anymore (music, movies, tones etc..) under my iphone on the left side of the screen, i have to click that little arrow, i prefer for it to be just there when i connect it. d

  • Best Way to call Dynamically an stored procedure

    Hi Guys, Here my question... I need to call dynamically to an stored procedure... - the stored procedure can change, the name , the number of parameters - the called stored procedure can contain output parameters. lv_sql := 'BEGIN '|| lv_program_name

  • I am having problem with using my Basic brush definition

    I am having problem with using the Basic brush definition. When I try to click on it will not allow me to use it and will automatically use the 5 pt. oval brush definition. The only way I can use the basic brush is after I have already drawn somethin

  • ThinkPad External DVD Reader / Writer USB 2.0??

    Hi, one of the largest online selling and buying website in New Zealand, trademe, has listed via a buyer a ThinkPad External DVD Reader / Writer USB 2.0. One of my friend bought it and found that it is shown on the computer hard drve as a Philips DVD

  • Coldfusion 9, Admin server won't start anymore...

    We have installed yesterday updates for Windows 2008 R2, but know Adobe Admin server doesn’t start anymore. The Macromedia JRun CFusion Server service could not be started.  Check the server "cfusion" log files for more information. What to do know?