Java Code Examples for javax.swing.JLayeredPane

The following are top voted examples for showing how to use javax.swing.JLayeredPane. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: DragOperation.java   View source code 6 votes vote down vote up
void start(PaletteItem item, Point pt) {
    // clean up prev is necessary
    if(dragComponent != null) {
        menuEditLayer.layers.remove(dragComponent);
        dragComponent = null;
    }
    
    if(!menuEditLayer.doesFormContainMenuBar()) {
        //op = Op.NO_MENUBAR;
        menuEditLayer.showMenubarWarning = true;
        FormEditor.getAssistantModel(menuEditLayer.formDesigner.getFormModel()).setContext("missingMenubar"); // NOI18N
        menuEditLayer.repaint();
    }
    
    op = Op.PICK_AND_PLOP_FROM_PALETTE;
    started = true;
    dragComponent = createDragFeedbackComponent(null, item.getComponentClass());
    dragComponent.setSize(dragComponent.getPreferredSize());
    dragComponent.setLocation(pt);
    menuEditLayer.layers.add(dragComponent, JLayeredPane.DRAG_LAYER);
    menuEditLayer.repaint();
    currentItem = item;
    menuEditLayer.glassLayer.requestFocusInWindow();
}
 
Example 2
Project: incubator-netbeans   File: ComponentPeer.java   View source code 6 votes vote down vote up
private int[] computeVisibleSpan() {
    Component parent = pane.getParent();
    
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }

    if (parent instanceof JViewport) {
        JViewport vp = (JViewport) parent;

        Point start = vp.getViewPosition();
        Dimension size = vp.getExtentSize();
        Point end = new Point((int) (start.getX() + size.getWidth()), (int) (start.getY() + size.getHeight()));

        int startPosition = pane.viewToModel(start);
        int endPosition = pane.viewToModel(end);

        if (parentWithListener != vp) {
            vp.addChangeListener(WeakListeners.change(this, vp));
            parentWithListener = vp;
        }
        return new int[] {startPosition, endPosition};
    }

    return new int[] {0, pane.getDocument().getLength()};
}
 
Example 3
Project: incubator-netbeans   File: AnnotationView.java   View source code 6 votes vote down vote up
double getUsableHeight() {
    //fix for issue #54080:
    //find the scrollpane which contains the pane:
    Component scrollPaneCandidade = pane.getParent();
    
    if (scrollPaneCandidade instanceof JLayeredPane) {
        scrollPaneCandidade = scrollPaneCandidade.getParent();
    }
    
    if (scrollPaneCandidade != null && !(scrollPaneCandidade instanceof JScrollPane)) {
        scrollPaneCandidade = scrollPaneCandidade.getParent();
    }
    
    if (scrollPaneCandidade == null || !(scrollPaneCandidade instanceof JScrollPane) || scrollBar == null) {
        //no help for #54080:
        return getHeight() - HEIGHT_OFFSET;
    }
    
    JScrollPane scrollPane = (JScrollPane) scrollPaneCandidade;
    int visibleHeight = scrollPane.getViewport().getExtentSize().height;
    
    int topButton = topOffset();
    int bottomButton = scrollBar.bottom;
    
    return visibleHeight - topButton - bottomButton;
}
 
Example 4
Project: incubator-netbeans   File: SlideOperationImpl.java   View source code 6 votes vote down vote up
private void performOperation(JLayeredPane pane, Integer layer) {
    // XXX - TBD
    switch (type) {
        case SLIDE_IN:
            component.setBounds(finishBounds);
            pane.add(component, layer);
            if( isHeavyWeightShowing() ) {
                repaintLayeredPane();
            }
            break;
        case SLIDE_OUT:
            pane.remove(component);
            break;
        case SLIDE_RESIZE:
            component.setBounds(finishBounds);
            ((JComponent)component).revalidate();
            if( isHeavyWeightShowing() ) {
                repaintLayeredPane();
            }
            break;
    }
}
 
Example 5
Project: incubator-netbeans   File: QuickSearchPopup.java   View source code 6 votes vote down vote up
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
    Dimension cSize = comboBar.getSize();
    int width = getPopupWidth();
    Point location = new Point(cSize.width - width - 1, comboBar.getBottomLineY() - 1);
    if (SwingUtilities.getWindowAncestor(comboBar) != null) {
        location = SwingUtilities.convertPoint(comboBar, location, lPane);
    }
    result.setLocation(location);

    // hack to make jList.getpreferredSize work correctly
    // JList is listening on ResultsModel same as us and order of listeners
    // is undefined, so we have to force update of JList's layout data
    jList1.setFixedCellHeight(15);
    jList1.setFixedCellHeight(-1);
    // end of hack

    jList1.setVisibleRowCount(modelSize);
    Dimension preferredSize = jList1.getPreferredSize();

    preferredSize.width = width;
    preferredSize.height += statusPanel.getPreferredSize().height + 3;

    result.setSize(preferredSize);
}
 
Example 6
Project: incubator-netbeans   File: QuickSearchPopup.java   View source code 6 votes vote down vote up
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
    Point location =
            new Point(
                comboBar.getIssueComponent().getX(),
                comboBar.getIssueComponent().getY() + comboBar.getIssueComponent().getHeight() - 1);
    location = SwingUtilities.convertPoint(comboBar, location, lPane); // XXX terrible hack! fix this
    result.setLocation(location);

    // hack to make jList.getpreferredSize work correctly
    // JList is listening on ResultsModel same as us and order of listeners
    // is undefined, so we have to force update of JList's layout data
    jList1.setFixedCellHeight(15);
    jList1.setFixedCellHeight(-1);
    // end of hack

    jList1.setVisibleRowCount(modelSize);
    Dimension preferredSize = jList1.getPreferredSize();

    preferredSize.width = comboBar.getIssueComponent().getWidth();
    preferredSize.height += statusPanel.getPreferredSize().height + 3;
    if(preferredSize.height > 150) {
        preferredSize.height = 150;
    }

    result.setSize(preferredSize);
}
 
Example 7
Project: VASSAL-src   File: GenericListener.java   View source code 6 votes vote down vote up
/**
 * Return true if the given component is likely to be a container such the each
 * component within the container should be be considered as a user input.
 * 
 * @param c
 * @return true if the component children should have this listener added.
 */
protected boolean isProbablyAContainer (Component c) {
    boolean result = extListener != null ? extListener.isContainer(c) : false;
    if (!result) {
        boolean isSwing = isSwingClass(c);
        if (isSwing) {
           result = c instanceof JPanel || c instanceof JSplitPane || c instanceof
                   JToolBar || c instanceof JViewport || c instanceof JScrollPane ||
                   c instanceof JFrame || c instanceof JRootPane || c instanceof
                   Window || c instanceof Frame || c instanceof Dialog ||
                   c instanceof JTabbedPane || c instanceof JInternalFrame ||
                   c instanceof JDesktopPane || c instanceof JLayeredPane;
        } else {
            result = c instanceof Container;
        }
    }
    return result;
}
 
Example 8
Project: VASSAL-src   File: PrivateMap.java   View source code 6 votes vote down vote up
public JComponent getView() {
  if (theMap == null) {
    theMap = new View(this);
    scroll = new AdjustableSpeedScrollPane(
          theMap,
          JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
          JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.unregisterKeyboardAction(KeyStroke.getKeyStroke(
          KeyEvent.VK_PAGE_DOWN, 0));
    scroll.unregisterKeyboardAction(KeyStroke.getKeyStroke(
          KeyEvent.VK_PAGE_UP, 0));

    layeredPane.setLayout(new InsetLayout(layeredPane, scroll));
    layeredPane.add(scroll, JLayeredPane.DEFAULT_LAYER);
  }
  return theMap;
}
 
Example 9
Project: VASSAL-src   File: GlobalMap.java   View source code 6 votes vote down vote up
/**
 * Expects to be added to a {@link Map}. Adds itself as a {@link
 * GameComponent} and a {@link Drawable}component
 */
public void addTo(Buildable b) {
  map = (Map) b;

  mouseOverViewer = new CounterViewer();

  GameModule.getGameModule().getGameState().addGameComponent(this);

  GameModule.getGameModule().addKeyStrokeSource(
    new KeyStrokeSource(view, JComponent.WHEN_FOCUSED));

  map.addDrawComponent(this);
  map.getToolBar().add(launch);

  if (b instanceof Translatable) {
    getI18nData().setOwningComponent((Translatable) b);
  }

  map.getLayeredPane().add(scroll, JLayeredPane.PALETTE_LAYER);
}
 
Example 10
Project: VASSAL-src   File: PieceMover.java   View source code 6 votes vote down vote up
/**
 * creates or moves cursor object to given JLayeredPane. Usually called by setDrawWinToOwnerOf()
 */
private void setDrawWin(JLayeredPane newDrawWin) {
  if (newDrawWin != drawWin) {
    // remove cursor from old window
    if (dragCursor.getParent() != null) {
      dragCursor.getParent().remove(dragCursor);
    }
    if (drawWin != null) {
      drawWin.repaint(dragCursor.getBounds());
    }
    drawWin = newDrawWin;
    calcDrawOffset();
    dragCursor.setVisible(false);
    drawWin.add(dragCursor, JLayeredPane.DRAG_LAYER);
  }
}
 
Example 11
Project: VASSAL-src   File: Map.java   View source code 6 votes vote down vote up
/** @return the Swing component representing the map */
public JComponent getView() {
  if (theMap == null) {
    theMap = new View(this);

    scroll = new AdjustableSpeedScrollPane(
      theMap,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.unregisterKeyboardAction(
      KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0));
    scroll.unregisterKeyboardAction(
      KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0));
    scroll.setAlignmentX(0.0f);
    scroll.setAlignmentY(0.0f);

    layeredPane.setLayout(new InsetLayout(layeredPane, scroll));
    layeredPane.add(scroll, JLayeredPane.DEFAULT_LAYER);
  }
  return theMap;
}
 
Example 12
Project: Cognizant-Intelligent-Test-Scripter   File: SlideContainer.java   View source code 6 votes vote down vote up
@Override
public Component add(Component comp) {
    setsize(comp.getPreferredSize());
    Component[] comps = getComponents();
    if (comps.length > 0) {
        oldComponent = comps[0];
    }
    if (comp.equals(oldComponent)) {
        return super.add(comp);
    }
    if (oldComponent != null) {
        putLayer((JComponent) oldComponent, JLayeredPane.DEFAULT_LAYER);
    }
    Component returnResult = super.add(comp);
    putLayer((JComponent) comp, JLayeredPane.DRAG_LAYER);
    comp.setSize(getPreferredSize());
    comp.setVisible(true);
    comp.setLocation(0, 0 - getPreferredSize().height);
    slideFromTop(comp, oldComponent);
    return returnResult;
}
 
Example 13
Project: Cognizant-Intelligent-Test-Scripter   File: SlideContainer.java   View source code 6 votes vote down vote up
private void slideFromTop(final Component comp,
        final Component oldComponent2) {
    new Timer(DELAY, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent aEvt) {
            int y = comp.getY();
            if (y >= -2) {
                comp.setLocation(0, 0);
                putLayer((JComponent) comp, JLayeredPane.DEFAULT_LAYER);
                if (oldComponent2 != null) {
                    remove(oldComponent2);
                }
                ((Timer) aEvt.getSource()).stop();
            } else {
                y += DY;
                comp.setLocation(0, y);
            }
            repaint();
        }
    }).start();
}
 
Example 14
Project: jdk8u-jdk   File: javax_swing_JLayeredPane.java   View source code 6 votes vote down vote up
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}
 
Example 15
Project: openjdk-jdk10   File: javax_swing_JLayeredPane.java   View source code 6 votes vote down vote up
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}
 
Example 16
Project: VISNode   File: JNodeContainer.java   View source code 5 votes vote down vote up
@Override
public void dragStarted(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof JLayeredPane) {
        selectionContainer = new JNodeContainerSelection(e.getPoint());
        add(selectionContainer, JLayeredPane.POPUP_LAYER);
    }
}
 
Example 17
Project: incubator-netbeans   File: AnnotationHolder.java   View source code 5 votes vote down vote up
private void addViewportListener(JEditorPane pane) {
    Container parent = pane.getParent();
    
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }

    if (parent instanceof JViewport) {
        JViewport viewport = (JViewport) parent;

        viewport.addChangeListener(WeakListeners.change(AnnotationHolder.this, viewport));
    }
}
 
Example 18
Project: incubator-netbeans   File: HintsUI.java   View source code 5 votes vote down vote up
private int getUsableWidth(JTextComponent component) {
    Container parent = component.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    return (parent instanceof JViewport)
        ? ((JViewport)parent).getExtentSize().width
        : component.getSize().width;
}
 
Example 19
Project: incubator-netbeans   File: DragOperation.java   View source code 5 votes vote down vote up
void start(JMenuItem item, Point pt) {
    op = Op.INTER_MENU_DRAG;
    started = true;
    
    
    //josh: intial support for dragging multiple items
    //in the future we should use the payloadComponents variable
    //for dragging components instead of the payloadComponent variable.
    List<RADComponent> rads = menuEditLayer.getSelectedRADComponents();
    
    payloadComponents = new ArrayList<JMenuItem>();
    if(rads.size() > 1) {
        for(RADComponent rad : rads) {
            Object comp = menuEditLayer.formDesigner.getComponent(rad);
            if(comp instanceof JMenuItem) {
                payloadComponents.add((JMenuItem)comp);
            } else {
                fastEnd();
                return;
            }
        }
    } else {
        payloadComponents.add(item);
    }
    
    dragComponent = (JMenuItem) createDragFeedbackComponent(item, null);
    dragComponent.setSize(dragComponent.getPreferredSize());
    dragComponent.setLocation(pt);
    menuEditLayer.layers.add(dragComponent, JLayeredPane.DRAG_LAYER);
    menuEditLayer.repaint();
    payloadComponent = item;
}
 
Example 20
Project: incubator-netbeans   File: DragOperation.java   View source code 5 votes vote down vote up
void setTargetVisible(boolean vis) {
    if(!vis) {
        menuEditLayer.layers.remove(dragComponent);
    } else {
        menuEditLayer.layers.add(dragComponent, JLayeredPane.DRAG_LAYER);
    }
    menuEditLayer.repaint();
}
 
Example 21
Project: incubator-netbeans   File: DragOperation.java   View source code 5 votes vote down vote up
public JComponent getDeepestComponentInPopups(Point pt) {
    Component[] popups = menuEditLayer.layers.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
    for(Component popup : popups) {
        if(popup.isVisible()) {
            Point pt2 = SwingUtilities.convertPoint(menuEditLayer, pt, popup);
            JComponent child = (JComponent) javax.swing.SwingUtilities.getDeepestComponentAt(popup, pt2.x, pt2.y);
            if(child != null) return child;
        }
    }
    return null;
}
 
Example 22
Project: FreeCol   File: Canvas.java   View source code 5 votes vote down vote up
/**
 * Adds a component to this Canvas.
 *
 * Make sure the status panel is not present unless the component
 * *is* the status panel.
 *
 * @param comp The {@code Component} to add to this canvas.
 * @param i The layer to add the component to (see JLayeredPane).
 */
private void addToCanvas(Component comp, Integer i) {
    if (statusPanel.isVisible()) {
        if (comp == statusPanel) return;
        if (!(comp instanceof JMenuItem)) removeFromCanvas(statusPanel);
    }

    if (i == null) i = JLayeredPane.DEFAULT_LAYER;
    try {
        super.add(comp, i);
    } catch (Exception e) {
        logger.log(Level.WARNING, "addToCanvas(" + comp + ", " + i
            + ") failed.", e);
    }
}
 
Example 23
Project: incubator-netbeans   File: EditorUI.java   View source code 5 votes vote down vote up
/** Is the parent of some editor component a viewport */
private JViewport getParentViewport() {
    Component pc = component.getParent();
    if (pc instanceof JLayeredPane) {
        pc = pc.getParent();
    }
    return (pc instanceof JViewport) ? (JViewport)pc : null;
}
 
Example 24
Project: incubator-netbeans   File: PopupManager.java   View source code 5 votes vote down vote up
/** Install popup panel to current textComponent root pane */
private void installToRootPane(JComponent c) {
    JRootPane rp = textComponent.getRootPane();
    if (rp != null) {
        rp.getLayeredPane().add(c, JLayeredPane.POPUP_LAYER, 0);
    }
}
 
Example 25
Project: incubator-netbeans   File: PopupManager.java   View source code 5 votes vote down vote up
/** Variation of the method for computing the bounds
 * for the concrete view component. As the component can possibly
 * be placed in a scroll pane it's first necessary
 * to translate the cursor bounds and also translate
 * back the resulting popup bounds.
 * @param popup  popup panel to be displayed
 * @param view component over which the popup is displayed.
 * @param cursorBounds the bounds of the caret or mouse cursor
 *    relative to the upper-left corner of the visible view.
 * @param placement where to place the popup panel according to
 *    the cursor position.
 * @return bounds of popup panel relative to the upper-left corner
 *    of the underlying view component.
 *    <CODE>null</CODE> if there is no place to display popup.
 */
protected static Rectangle computeBounds(JComponent popup,
JComponent view, Rectangle cursorBounds, Placement placement, HorizontalBounds horizontalBounds) {
    
    if (horizontalBounds == null) horizontalBounds = ViewPortBounds;
    
    Rectangle ret;
    Component viewParent = view.getParent();
    
    if (viewParent instanceof JLayeredPane) {
        viewParent = viewParent.getParent();
    }
    
    if (viewParent instanceof JViewport) {
        Rectangle viewBounds = ((JViewport)viewParent).getViewRect();

        Rectangle translatedCursorBounds = (Rectangle)cursorBounds.clone();
        if (placement != FixedPoint) {
            translatedCursorBounds.translate(-viewBounds.x, -viewBounds.y);
        }

        ret = computeBounds(popup, viewBounds.width, viewBounds.height,
            translatedCursorBounds, placement, horizontalBounds);
        
        if (ret != null) { // valid bounds
            ret.translate(viewBounds.x, viewBounds.y);
        }
        
    } else { // not in scroll pane
        ret = computeBounds(popup, view.getWidth(), view.getHeight(),
            cursorBounds, placement);
    }
    
    return ret;
}
 
Example 26
Project: incubator-netbeans   File: StickyWindowSupport.java   View source code 5 votes vote down vote up
StickyWindowSupport(final JTextComponent jtc) {
    this.jtc = jtc;
    ViewHierarchy.get(jtc).addViewHierarchyListener(new ViewHierarchyListener() {
        @Override
        public void viewHierarchyChanged(ViewHierarchyEvent evt) {
            JTextComponent editor = jtc;
            Container container = editor.getParent();
            if(container instanceof JLayeredPane && evt.isChangeY()) {
                JLayeredPane pane = (JLayeredPane) container;
                double deltaY = evt.deltaY();
                Component[] components = pane.getComponentsInLayer(JLayeredPane.PALETTE_LAYER);
                Rectangle rv = null;
                for (final Component component : components) {
                    rv = component.getBounds(rv);
                    if(rv.getY() > evt.startY() ||
                            rv.contains(new Point(rv.x, (int) evt.startY())) ||
                            rv.contains(new Point(rv.x, (int) evt.endY()))) {
                        final Point p = rv.getLocation();
                        p.translate(0, (int) deltaY);
                        EventQueue.invokeLater(new Runnable() {

                            @Override
                            public void run() {      
                              component.setLocation(p);
                            }
                        });
                        
                    }
                }
            }
        }
    });
}
 
Example 27
Project: incubator-netbeans   File: StickyWindowSupport.java   View source code 5 votes vote down vote up
/**
 * Add a sticky window to the editor.
 * @param window the JComponent to add to the editor
 */
public void addWindow(JComponent window) {
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        pane.add(window, JLayeredPane.PALETTE_LAYER);
        window.setVisible(true);
    }
}
 
Example 28
Project: incubator-netbeans   File: StickyWindowSupport.java   View source code 5 votes vote down vote up
/**
 * Convert a <code>aPoint</code> in root component coordinate system to the
 * editor coordinate system. <code>aPoint</code> is assumed to be in the
 * root component coordinate system of the editor. If conversion is not
 * possible, return <code>aPoint</code> without any conversion.
 *
 * @param aPoint the Point to convert
 * @return aPoint converted to editor coordinate system
 */
public @NonNull Point convertPoint(Point aPoint) {
    Point value = aPoint;
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        value = SwingUtilities.convertPoint(pane.getRootPane(), value, pane);
    }
    return value;
}
 
Example 29
Project: incubator-netbeans   File: StickyWindowSupport.java   View source code 5 votes vote down vote up
/**
 * Remove a sticky window from the editor.
 * @param window the JComponent to remove
 */
public void removeWindow(JComponent window) {
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        pane.remove(window);
        pane.repaint(window.getBounds());
    }
}
 
Example 30
Project: incubator-netbeans   File: BraceMatchingSidebarComponent.java   View source code 5 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public BraceMatchingSidebarComponent(JTextComponent editor) {
    this.editor = editor;
    this.mimeType = DocumentUtilities.getMimeType(editor);
    this.prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    
    final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
            FontColorSettings.class);
    prefListenerGC = new PrefListener();
    this.colorResult = r;
    r.addLookupListener(WeakListeners.create(LookupListener.class, this , r));
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
    loadPreferences();
    
    editorPane = findEditorPane(editor);
    Component parent = editor.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    if (parent instanceof JViewport) {
        this.viewport = (JViewport)parent;
        // see #219015; need to listen on viewport change to show/hide the tooltip
        viewport.addChangeListener(WeakListeners.change(this, viewport));
    }
    TextUI ui = editor.getUI();
    if (ui instanceof BaseTextUI) {
        baseUI = (BaseTextUI)ui;
        MasterMatcher.get(editor).addMatchListener(this);
    } else {
        baseUI = null;
    }
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    updatePreferredSize();
}
 
Example 31
Project: incubator-netbeans   File: DesktopImpl.java   View source code 5 votes vote down vote up
/** Creates a new instance of DesktopImpl */
public DesktopImpl () {
    // layered pane with absolute positioning, to enable overlapping
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new LayeredLayout());
    // desktop represents regular layer of layeredPane
    desktop = new JPanel() {
        @Override
        public boolean isOpaque() {
            if( UIManager.getBoolean( "NbMainWindow.showCustomBackground" ) ) //NOI18N
                return false;
            return super.isOpaque();
        }

        @Override
        public void updateUI() {
            Mutex.EVENT.readAccess( new Runnable() {
                @Override
                public void run() {
                    superUpdateUI();
                }
            });
        }

        private void superUpdateUI() {
            super.updateUI();
        }
    };
    desktop.setLayout(new GridBagLayout());
    Color bkColor = UIManager.getColor("NbSplitPane.background"); //NOI18N
    if( null != bkColor ) {
        desktop.setBackground(bkColor);
        desktop.setOpaque(true);
    }
    layeredPane.add(desktop);
}
 
Example 32
Project: incubator-netbeans   File: DefaultSlidingFx.java   View source code 5 votes vote down vote up
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
//        Component comp = operation.getComponent();
//        Graphics2D gr2d = (Graphics2D)pane.getGraphics();
//        Color original = gr2d.getColor();
//        gr2d.setColor(Color.BLUE.darker().darker());
//        Rectangle start = operation.getStartBounds();
//        Rectangle finish = operation.getFinishBounds();
//        Rectangle current = start;
//        for (int i = 0; i < 6 /** magic constant **/; i++) {
//            Rectangle newRect;
//            if (i > 0) {
//                // wipe out old
//            } 
//            newRect = new Rectangle();
//            newRect.x = Math.abs((current.x + finish.x) / 2);
//            newRect.y = Math.abs((current.y + finish.y) / 2);
//            newRect.height = Math.abs((current.height + finish.height) / 2);
//            newRect.width = Math.abs((current.width + finish.width) / 2);
//            gr2d.drawRect(newRect.x, newRect.y, newRect.width, newRect.height);
//            gr2d.setColor(gr2d.getColor().brighter());
//            current = newRect;
//        }
//        gr2d.setColor(original);
////        try {
////            Thread.sleep(5000);
////        } catch (Throwable th) {
////            
////        }
        
    }
 
Example 33
Project: incubator-netbeans   File: ScaleFx.java   View source code 5 votes vote down vote up
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
    this.pane = pane;
    this.operation = operation;
    Component comp = operation.getComponent();
    Graphics2D gr2d = (Graphics2D)pane.getGraphics();
    Rectangle start = operation.getStartBounds();
    Rectangle finish = operation.getFinishBounds();
    Dimension finishSize = finish.getSize();
    Dimension startSize = start.getSize();
    Rectangle current = start;
    Image compImage = preparedImage;

   /* if (compImage == null) {
        if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
            compImage = renderCompIntoImage(comp, finishSize, pane);
        } else {
            compImage = renderCompIntoImage(comp, startSize, pane);
        }
    }*/
    pane.add(stretchedImage, layer);
    
    path = computePath(start, finish);
    
    curIter = 1;
    if (compImage != null) {
        stretchedImage.setOrigImage(compImage);
    } else {
        if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
            stretchedImage.setComp(comp, finishSize);
        } else {
            stretchedImage.setComp(comp, startSize);
        }
    }
    stretchedImage.setBoundsAndAlpha(start, initialAlpha);
    
    getTimer().start();
}
 
Example 34
Project: incubator-netbeans   File: SlideOperationImpl.java   View source code 5 votes vote down vote up
public void run(JLayeredPane pane, Integer layer) {
    if (effect != null && effect.shouldOperationWait()) {
        // OK, effect is asynchronous and we should wait for effect finish,
        // so register and wait for stateChanged notification
        this.pane = pane;
        this.layer = layer;
        effect.setFinishListener(this);
        effect.showEffect(pane, layer, this);
    } else {
        if (effect != null) {
            effect.showEffect(pane, layer, this);
        }
        performOperation(pane, layer);
    }
}
 
Example 35
Project: incubator-netbeans   File: SlideOperationImpl.java   View source code 5 votes vote down vote up
private void repaintLayeredPane() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Frame f = WindowManagerImpl.getInstance().getMainWindow();
            if( f instanceof JFrame ) {
                JLayeredPane lp = ((JFrame)f).getLayeredPane();
                if( null != lp ) {
                    lp.invalidate();
                    lp.revalidate();
                    lp.repaint();
                }
            }
        }
    });
}
 
Example 36
Project: incubator-netbeans   File: ConsoleEditor.java   View source code 5 votes vote down vote up
private void removeProgressIndicator() {
    if (lastLayeredPane == null || progressIndicator == null) {
        return;
    }
    progressIndicator.setVisible(false);
    JLayeredPane lp = lastLayeredPane;
    lp.remove(progressIndicator);
    lp.repaint();
    progressIndicator = null;
    
}
 
Example 37
Project: incubator-netbeans   File: WindowBuilders.java   View source code 5 votes vote down vote up
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JRootPane.class.getName())) {
        return new JRootPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JDesktopPane.class.getName())) {
        return new JDesktopPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JLayeredPane.class.getName())) {
        return new JLayeredPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Frame.class.getName())) {
        return new FrameBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Dialog.class.getName())) {
        return new DialogBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JInternalFrame.class.getName())) {
        return new JInternalFrameBuilder(instance, heap);
    }
    return null;
}
 
Example 38
Project: incubator-netbeans   File: QuickSearchPopup.java   View source code 5 votes vote down vote up
/**
 * Updates size and visibility of this panel according to model content
 */
public void updatePopup () {
    int modelSize = rModel.getSize();

    // plug this popup into layered pane if needed
    JLayeredPane lPane = JLayeredPane.getLayeredPaneAbove(comboBar);
    // lPane can be null when the corresponding dialog is closed already
    // for example, when the user didn't want to wait until the search finishes
    if (!isDisplayable() && (lPane != null)) {
        lPane.add(this, new Integer(JLayeredPane.POPUP_LAYER + 1) );
    }

    boolean statusVisible = updateStatusPanel();

    if(lPane != null) {
        computePopupBounds(popupBounds, lPane, modelSize);
        setBounds(popupBounds);
    }

    // popup visibility constraints
    if ((modelSize > 0 || statusVisible) && comboBar.isTextFieldFocusOwner()) {
        if (jList1.getSelectedIndex() >= modelSize) {
            jList1.setSelectedIndex(modelSize - 1);
        }
        setVisible(true);
    } else {
        setVisible(false);
    }

    // needed on JDK 1.5.x to repaint correctly
    revalidate();
}
 
Example 39
Project: AgentWorkbench   File: GraphEnvironmentControllerGUI.java   View source code 5 votes vote down vote up
/**
  * Returns the BasicGraphGuiJDesktopPane
  * @return the BasicGraphGuiJDesktopPane
  */
 public BasicGraphGuiJDesktopPane getBasicGraphGuiJDesktopPane() {
 	if (basicGraphGuiJDesktopPane==null) {
 		basicGraphGuiJDesktopPane = new BasicGraphGuiJDesktopPane((GraphEnvironmentController) this.environmentController);
 		basicGraphGuiJDesktopPane.add(this.getBasicGraphGuiRootJSplitPane(), JLayeredPane.DEFAULT_LAYER);
 		try {
	this.getBasicGraphGuiRootJSplitPane().setMaximum(true);
} catch (PropertyVetoException pvex) {
	pvex.printStackTrace();
}
 	}
 	return basicGraphGuiJDesktopPane;
 }
 
Example 40
Project: rapidminer   File: CSVFormatSpecificationPanel.java   View source code 5 votes vote down vote up
/**
 * Fills the tablePane with content.
 */
private JComponent makePreviewTable() {
	previewTable = new ExtendedJTable(false, false, false);
	// ensure same background as JPanels in case of only few rows
	previewTable.setBackground(Colors.PANEL_BACKGROUND);
	previewTable.setColoredTableCellRenderer(new ColoredTableCellRenderer() {

		private final Font boldFont = getFont().deriveFont(Font.BOLD);

		@Override
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
				int row, int column) {
			JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
			adjustCell(row, label, boldFont);
			return label;
		}

	});

	loadingContentPane = new LoadingContentPane("loading_data", previewTable);

	tablePane = new JScrollPane(loadingContentPane);
	tablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
	tablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	tablePane.setBorder(null);

	// add PREVIEW label in front of scrollpane
	JLayeredPane layeredPane = new JLayeredPane();
	layeredPane.setLayout(new OverlayLayout(layeredPane));
	layeredPane.add(tablePane, JLayeredPane.DEFAULT_LAYER);

	JPanel overlayPanel = new JPanel(new BorderLayout());
	overlayPanel.setOpaque(false);
	overlayLabel = new JLabel("", SwingConstants.CENTER);
	showPreviewLettering();
	overlayPanel.add(overlayLabel, BorderLayout.CENTER);

	layeredPane.add(overlayPanel, JLayeredPane.PALETTE_LAYER);
	return layeredPane;
}