javax.swing.JLayeredPane.getLayer()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中javax.swing.JLayeredPane.getLayer()方法的一些代码示例,展示了JLayeredPane.getLayer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLayeredPane.getLayer()方法的具体详情如下:
包路径:javax.swing.JLayeredPane
类名称:JLayeredPane
方法名:getLayer

JLayeredPane.getLayer介绍

暂无

代码示例

代码示例来源:origin: com.google.code.validationframework/validationframework-swing

/**
 * Retrieves the layer index of the decorated component in the layered pane of the window.
 *
 * @param layeredPane Layered pane of the window.
 *
 * @return Index of the decorated component in the layered pane.
 */
private Integer getDecoratedComponentLayerInLayeredPane(JLayeredPane layeredPane) {
  Container ancestorInLayer = decoratedComponent;
  while (!layeredPane.equals(ancestorInLayer.getParent())) {
    ancestorInLayer = ancestorInLayer.getParent();
  }
  return (layeredPane.getLayer(ancestorInLayer) + DECORATION_LAYER_OFFSET);
}

代码示例来源:origin: stackoverflow.com

public static class MouseBlockerUI extends LayerUI<JComponent> {

  @Override
  protected void processMouseEvent(MouseEvent e, JLayer l) {
    JLayeredPane layeredPane = (JLayeredPane) l.getParent();
    if (layeredPane.getLayer(l) != layeredPane.highestLayer())
      e.consume();
  }

  @Override
  public void installUI(JComponent c) {
    super.installUI(c);
    JLayer jlayer = (JLayer)c;
    jlayer.setLayerEventMask(
        AWTEvent.MOUSE_EVENT_MASK 
    );
  }

  @Override
  public void uninstallUI(JComponent c) {
    JLayer jlayer = (JLayer)c;
    jlayer.setLayerEventMask(0);
    super.uninstallUI(c);
  }

}

代码示例来源:origin: abbot/abbot

/** Returns whether the given Component is the content pane for a
  {@link RootPaneContainer}. 
  @see javax.swing.RootPaneContainer#getContentPane
*/
public static boolean isContentPane(Component c) {
  if (c.getParent() instanceof JLayeredPane) {
    JLayeredPane p = (JLayeredPane)c.getParent();
    if (p.getParent() instanceof JRootPane) {
      return ((JRootPane)p.getParent()).getContentPane() == c;
    }
    int layer = JLayeredPane.FRAME_CONTENT_LAYER.intValue();
    return p.getLayer(c) == layer
      && !(c instanceof JMenuBar);
  }
  return false;
}

代码示例来源:origin: abbot/abbot

/** Returns whether the given component is a lightweight popup, that is, a
  container for a JPopupMenu that is implemented with a lightweight
  component (usually JPanel).
*/
public static boolean isLightweightPopup(Component c) {
  if (c instanceof JPanel) {
    Window w = SwingUtilities.getWindowAncestor(c);
    if (w != null && isHeavyweightPopup(w))
      return false;
    JPanel panel = (JPanel)c;
    Container parent = panel.getParent();
    if (parent != null) {
      if (parent instanceof JLayeredPane) {
        int layer = JLayeredPane.POPUP_LAYER.intValue();
        if (JLayeredPane.getLayer(panel) == layer)
          return true;
      }
    }
    return panel.getComponentCount() == 1
      && panel.getComponents()[0] instanceof JPopupMenu;
  }
  return false;
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
  public void eventDispatched(AWTEvent ev) {
    if (!(ev instanceof MouseEvent) || !(ev.getSource() instanceof Component)) {
      // We are interested in MouseEvents only
      return;
    }
    Component src = (Component) ev.getSource();
    // Close popup only on mouse press on a component which has
    // the same window ancestor as our popup, but is not in the
    // popup layer of the window.
    if (ev.getID() == MouseEvent.MOUSE_PRESSED) {
      if (SwingUtilities.getWindowAncestor(src)
          == SwingUtilities.getWindowAncestor(JPopupButton.this)) {
        JLayeredPane srcLP = (JLayeredPane) SwingUtilities.getAncestorOfClass(JLayeredPane.class, src);
        Component srcLPChild = src;
        while (srcLPChild.getParent() != srcLP) {
          srcLPChild = srcLPChild.getParent();
        }
        if (srcLP.getLayer(srcLPChild) < JLayeredPane.POPUP_LAYER) {
          popupMenu.setVisible(false);
        }
      }
    } else {
    }
  }
};

代码示例来源:origin: stackoverflow.com

Component c = (Component) evt.getSource();
  currentComponent = c;
  layerOfCurrent = desktopPane.getLayer(c);
  desktopPane.remove(c);
  desktopPane.add(c, new Integer(100));
Component c = (Component) evt.getSource();
currentComponent = c;
layerOfCurrent = desktopPane.getLayer(c);

代码示例来源:origin: stackoverflow.com

JButton button = new JButton(" Menu \u25be ");

JFrame frame = new JFrame("Title");
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

// Force creation of title bar components.
frame.setPreferredSize(new Dimension(400, 400));
frame.pack();

JLayeredPane layeredPane = frame.getLayeredPane();
JComponent titlePane = (JComponent) layeredPane.getComponentAt(0, 0);
for (Component c : titlePane.getComponents()) {
  if (c instanceof Container &&
    ((Container) c).getLayout() instanceof DefaultMenuLayout) {

    int layer = layeredPane.getLayer(titlePane);
    layeredPane.setLayer(button, layer + 1);

    button.setLocation(c.getX() + c.getWidth() + 3, 1);
    Dimension size = button.getPreferredSize();
    size.height = Math.min(size.height, titlePane.getHeight() - 2);
    button.setSize(size);
    layeredPane.add(button);

    break;
  }
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

srcLPChild = srcLPChild.getParent();
if (srcLP.getLayer(srcLPChild) < JLayeredPane.POPUP_LAYER) {
  JComponentPopup.this.setVisible(false);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

srcLPChild = srcLPChild.getParent();
if (srcLP.getLayer(srcLPChild) < JLayeredPane.POPUP_LAYER) {
  JComponentPopup.this.setVisible(false);

代码示例来源:origin: stackoverflow.com

if (comp instanceof JInternalFrame.JDesktopIcon) {
  icons.add(comp);
  maxLayer = Math.max(getLayer(comp), maxLayer);

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

int layer = JLayeredPane.getLayer(f);
JLayeredPane.putLayer(desktopIcon, layer);

相关文章