Package javax.swing

Examples of javax.swing.JRootPane


        this.add = add;
    }
    @SuppressWarnings("unchecked")
  public void performAction() {

        JRootPane root = ((JComponent)this._component).getRootPane();
      JComponent target = (JComponent)this._component;
        if (root!=null){
            HashSet<JComponent> selectedKids = (HashSet<JComponent>)root.getClientProperty("qq_selectedKids");
            if (selectedKids == null){
                selectedKids = new HashSet<JComponent>();
                root.putClientProperty("qq_selectedKids", selectedKids);
            }
            if (!add){
                // no shift key
                Iterator<JComponent> it = selectedKids.iterator();
                while (it.hasNext()){
View Full Code Here


    }

    public void performAction() {
        // TF:21/11/07: Refactored and commented this method for readability
        JButton newDefaultButton = (JButton)this._component;
        JRootPane rootPane = newDefaultButton.getRootPane();
        if (rootPane == null) {
            // If the button is not parented onto a Window, we cannot set the default button.
            return;
        }
        // Get the button that used to be the default button
        JButton oldDefaultButton = rootPane.getDefaultButton();

        if (this.setAsDefault) {
            if (oldDefaultButton == newDefaultButton) {
                // We're just resetting the default button to the same thing, do nothing.
                return;
            }
            // Make this button the default button
            newDefaultButton.setDefaultCapable(true);
            rootPane.setDefaultButton(newDefaultButton);
            // Set the old button not as the default if applicable
            if (oldDefaultButton != null) {
                oldDefaultButton.setDefaultCapable(false);
            }
        }
        else {
            // See if we're the default button
            if (oldDefaultButton == newDefaultButton) {
                rootPane.setDefaultButton(null);
            }
            // DK:11/11/2008: reset the default button as far as we do not want the button to be default any more.
            JButton initialDefault = (JButton)rootPane.getClientProperty("initialDefaultButton");
            if (newDefaultButton == initialDefault) {
              rootPane.putClientProperty("initialDefaultButton", null);
      }
         
            newDefaultButton.setDefaultCapable(false);
        }
    }
View Full Code Here

     * Gets default button for root container of the component.
     * @param component the component to obtain root container.
     * @return default button of the container or null if root container did not obtained or default button is not defined.
     */
    public static JButton get(JComponent component) {
        JRootPane rootPane = component.getRootPane();
        if (rootPane != null) {
            return rootPane.getDefaultButton();
        }
    return null;
  }
View Full Code Here

             *
             * @deprecated, this code remains only for backward compatability.
             * Only code generated prior to 6/8/07 will use this
             */
            Component grandMa = ((JComponent)parent).getTopLevelAncestor();
            JRootPane root = ((JComponent)parent).getRootPane();
            JLayeredPane layeredPane = getLayeredPane(grandMa);
            Component glassPane = UIutils.getGlassPane(grandMa);
            JMenuBar menuBar = root == null ? null : root.getJMenuBar();
            if (grandMa != null) {
                Insets insets = ((Container)grandMa).getInsets();
                Insets tempInsets = new Insets(0,0,0,0);

                int menuHeight = 0;
                // TF:19/09/2009:Only compensate for the menu bar if it's visible.
                if (menuBar != null && menuBar.isVisible()) {
                    // Compensate for only the height of the menu, the width is derived from the screen.
                    menuHeight = menuBar.getHeight();
                }

                // Layered pane = content pane + menu bar + insets
                if (layeredPane != null) {
                    layeredPane.getInsets(tempInsets);
                    newSize.height += menuHeight + tempInsets.top + tempInsets.bottom;
                    newSize.width += tempInsets.left + tempInsets.right;
                    if (debugEnabled) {
                      _log.debug("\tsetting layered pane size to " + newSize);
                    }
                    if (newSize.height != layeredPane.getHeight()
                            || newSize.width != layeredPane.getWidth()) {
                        layeredPane.setSize(newSize);
                    }
                }
                if (glassPane != null) {
                  if (debugEnabled) {
                    _log.debug("\tsetting glass pane size to " + newSize);
                  }
                    if (newSize.height != glassPane.getHeight()
                            || newSize.width != glassPane.getWidth()) {
                        glassPane.setSize(newSize);
                    }
                }

                if (root != null) {
                    root.getInsets(tempInsets);
                    newSize.height += tempInsets.top + tempInsets.bottom;
                    newSize.width += tempInsets.left + tempInsets.right;
                    if (debugEnabled) {
                      _log.debug("\tsetting root pane size to " + newSize);
                    }
                    if (newSize.height != root.getHeight()
                            || newSize.width != root.getWidth()) {
                        root.setSize(newSize);
                        root.revalidate(); //PM:4/8/07 Added to correct paint issue
                    }
                }

                if (debugEnabled) {
                  _log.debug("\tSetting owning container's size to ("
View Full Code Here

        JLayeredPane layeredPane = this.frame.getLayeredPane();
        Insets layeredPaneInsets = new Insets(0,0,0,0);
        JMenuBar menuBar = this.frame.getJMenuBar();
        int menuHeight = (menuBar == null) ? 0 : menuBar.getHeight()// Compensate for only the height of the menu, the width is derived from the screen.
        Component glassPane = this.frame.getGlassPane();
        JRootPane rootPane = this.frame.getRootPane();
        Insets RootPaneInsets = new Insets(0,0,0,0);

        // Layered pane = content pane + menu bar + insets
        if (layeredPane != null) {
            layeredPane.getInsets(layeredPaneInsets);
            // TF:20/8/07:Tests show that if we include the menu height here that our window comes out too big,
            // by the height of the menu. So setting the layered pane size must cater for this.
            newSize.height += menuHeight + layeredPaneInsets.top + layeredPaneInsets.bottom;
            newSize.width += layeredPaneInsets.left + layeredPaneInsets.right;
            if (_log.isDebugEnabled()) {
              _log.debug("\tsetting layered pane size to " + newSize);
            }
            if (newSize.height != layeredPane.getHeight()
                    || newSize.width != layeredPane.getWidth()) {
                layeredPane.setSize(newSize);
                layeredPane.revalidate();
                layeredPane.repaint();
            }
        }
        // size the glass pane
        if (glassPane != null) {
            if (_log.isDebugEnabled()) {
              _log.debug("\tsetting glass pane size to " + newSize);
            }
            if (newSize.height != glassPane.getHeight()
                    || newSize.width != glassPane.getWidth()) {
                glassPane.setSize(newSize);
            }
        }

        //size the root pane
        if (rootPane != null) {
            rootPane.getInsets(RootPaneInsets);
            newSize.height += RootPaneInsets.top + RootPaneInsets.bottom;
            newSize.width += RootPaneInsets.left + RootPaneInsets.right;
            if (_log.isDebugEnabled()) {
              _log.debug("\tsetting root pane size to " + newSize);
            }
            if (newSize.height != rootPane.getHeight()
                    || newSize.width != rootPane.getWidth()) {
                rootPane.setSize(newSize);
                rootPane.revalidate(); //PM:4/8/07 Added to correct paint issue
                rootPane.repaint();
            }
        }

        if (_log.isDebugEnabled()) {
          _log.debug("\tSetting owning container's size to ("
View Full Code Here

          if (initialFocusComponent instanceof JButton) {
            JButton defaultB = (JButton)initialFocusComponent;
            defaultB.addAncestorListener(new AncestorListener() {
              public void ancestorAdded(AncestorEvent e) {
                JButton defaultButton = (JButton)e.getComponent();
                JRootPane root = SwingUtilities.getRootPane(defaultButton);
                if (root != null) {
                  root.setDefaultButton(defaultButton);
                }
              }
              public void ancestorRemoved(AncestorEvent event) {}
              public void ancestorMoved(AncestorEvent event) {}
            });
View Full Code Here

    /** Make the Go button the default button for the root pane.
     *  You should call this after placing this pane in a container with
     *  a root pane.
     */
    public void setDefaultButton() {
        JRootPane root = getRootPane();

        if ((root != null) && ((_show & BUTTONS) != 0)) {
            root.setDefaultButton(_goButton);
            _goButton.setMnemonic(KeyEvent.VK_G);
            _pauseButton.setMnemonic(KeyEvent.VK_P);
            _resumeButton.setMnemonic(KeyEvent.VK_R);
            _stopButton.setMnemonic(KeyEvent.VK_S);
        }
View Full Code Here

        protected JComponent createFormControl()
        {
            JTextField textControl = (JTextField)getBindingFactory().createBinding("field").getControl();
           
            // provide a rootpane for the form's control.
            JRootPane rootPane= new JRootPane();
            rootPane.add(textControl);
           
            return textControl;
        }
View Full Code Here

        JComponent component = createTestComponent();
        JComponent overlay = createTestOverlay();
        final ReferenceQueue rq = new ReferenceQueue();
        final PhantomReference componentRef = new PhantomReference(component, rq);

        final JRootPane rootPane = new JRootPane() {
            public boolean isVisible() {
                return true;
            }
            public boolean isShowing() {
                return true;
            }
            protected JLayeredPane createLayeredPane() {
                return new JLayeredPane() {
                    public boolean isVisible() {
                        return true;
                    }
                    public boolean isShowing() {
                        return true;
                    }
                };
            }
        };
       
        final int lpcount = rootPane.getLayeredPane().getComponentCountInLayer(JLayeredPane.PALETTE_LAYER.intValue());
       
        OverlayHelper.attachOverlay(overlay, component, 0, 0, 0);
       
        assertEquals(lpcount, rootPane.getLayeredPane().getComponentCountInLayer(JLayeredPane.PALETTE_LAYER.intValue()));
        rootPane.getContentPane().add(component);
        // updateOverlay is "invokedLater", so wait for it...
        waitUntilEventQueueIsEmpty();
        assertEquals(lpcount + 1, rootPane.getLayeredPane().getComponentCountInLayer(JLayeredPane.PALETTE_LAYER.intValue()));
       
        rootPane.getContentPane().remove(component);
       
        // the remove operation make be invoked later, so wait for it...
        waitUntilEventQueueIsEmpty();
       
        // Clear out our strong references so it gets garbage collected.
        component = null;
        overlay = null;
       
        // Make sure the overlay was removed from the layered pane.
        assertEquals("It appears the overlay was not removed from the layered pane when its component was removed from the content pane", lpcount, rootPane.getLayeredPane().getComponentCountInLayer(JLayeredPane.PALETTE_LAYER.intValue()));
       
        // Make sure no other references are held... wait up to 15 seconds for
        // the object to be garbage collected.
        // Note: we may want to remove this section from the test as it
        // presumes the VM will garbage collect the reference fairly quickly
View Full Code Here

            }
        }
    }

    public static void showAt(Component component) {
        JRootPane root = SwingUtilities.getRootPane(component);
        if (root != null && root.isShowing()) {
            root.setGlassPane(BusyGlassPanel.INSTANCE);
            root.getGlassPane().setVisible(true);
        }
    }
View Full Code Here

TOP

Related Classes of javax.swing.JRootPane

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.