javax.swing.text.JTextComponent.getParent()方法的使用及代码示例

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

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

JTextComponent.getParent介绍

暂无

代码示例

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

/** Is the parent of some editor component a viewport */
private JViewport getParentViewport() {
  Component pc = component.getParent();
  return (pc instanceof JViewport) ? (JViewport)pc : null;
}

代码示例来源:origin: net.java.abeille/abeille

/** Is the parent of some editor component a viewport */
private JViewport getParentViewport() {
  Component pc = component.getParent();
  return (pc instanceof JViewport) ? (JViewport) pc : null;
}

代码示例来源:origin: de.sciss/syntaxpane

/**
 * Returns the JScrollPane that contains this EditorPane, or null if no
 * JScrollPane is the parent of this editor
 */
public JScrollPane getScrollPane(JTextComponent editorPane) {
  Container p = editorPane.getParent();
  while (p != null) {
    if (p instanceof JScrollPane) {
      return (JScrollPane) p;
    }
    p = p.getParent();
  }
  return null;
}

代码示例来源:origin: de.sciss/jsyntaxpane

/**
 * Get the JscrollPane that contains this EditorPane, or null if no
 * JScrollPane is the parent of this editor
 * @param editorPane
 * @return
 */
public JScrollPane getScrollPane(JTextComponent editorPane) {
  Container p = editorPane.getParent();
  while (p != null) {
    if (p instanceof JScrollPane) {
      return (JScrollPane) p;
    }
    p = p.getParent();
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spellchecker

public void ancestorAdded(AncestorEvent event) {
  if (pane.getParent() != null)
    doUpdateCurrentVisibleSpan();
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

protected void refresh() {
 if ( getComponent().getParent() != null ) {
  Component papi = getComponent();
  papi.getParent().repaint( papi.getX()-5, papi.getY()-5, 
               papi.getWidth()+10, papi.getHeight()+10);
 }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

/** Possibly do translation when over the gutter.
 */
private Point getLastMouseEventPoint() {
  Point p = null;
  MouseEvent lme = lastMouseEvent;
  if (lme != null) {
    p = lme.getPoint();
    if (lme.getSource() == extEditorUI.getGlyphGutter()) {
      // Over glyph gutter - change coords
      JTextComponent c = extEditorUI.getComponent();
      if (c != null) {
        if (c.getParent() instanceof JViewport) {
          JViewport vp = (JViewport)c.getParent();
          p = new Point(vp.getViewPosition().x, p.y);
        }
      }
    }
  }
  return p;
}

代码示例来源:origin: markiewb/nb-codeoutline

@Override
public JComponent createSideBar(JTextComponent jtc) {
  /**
   * <pre>
   * jtc.getParent()                              #8227    NbEditorUI$LayeredEditorPane
   * jtc.getParent().getParent()                  #8233    JViewport
   * jtc.getParent().getParent().getParent()    #8234    JScrollPane
   * </pre>
   */
  Container parent = jtc.getParent();
  if (null == parent) {
    return null;
  }
  parent = parent.getParent();
  if (null == parent) {
    return null;
  }
  // a new container JViewport has been introduced in 8.2
  parent = parent.getParent();
  if (null == parent) {
    return null;
  }
  if (parent instanceof JScrollPane && null != jtc.getDocument()) {
    JScrollPane scrollPane = (JScrollPane) parent;
    return new NaviViewExt(jtc.getDocument(), scrollPane.getVerticalScrollBar());
  }
  return null;
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

protected void refreshBorder() {
 if ( getComponent().getParent() != null ) {
  Component papi = getComponent();
  papi.getParent().repaint( papi.getX()-5, papi.getY()-5, 
               papi.getWidth()+10, papi.getHeight()+10);
 }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

private void trySendEnterToDialog() {
//        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();
    if (ev instanceof KeyEvent && ((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER) {
      
      if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
        return;
      }
      
      if (ev.getSource() instanceof JTextComponent && ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
        ((JComboBox)((JTextComponent) ev.getSource()).getParent()).isPopupVisible()) {
          return;
      }

      JRootPane jrp = getRootPane();
      if (jrp != null) {
        JButton b = jrp.getDefaultButton();
        if (b != null && b.isEnabled()) {
          b.doClick();
        }
      }
    }
  }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

private void trySendEnterToDialog() {
//        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();
    if (ev instanceof KeyEvent && ((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER) {
      
      if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
        return;
      }
      
      if (ev.getSource() instanceof JTextComponent && ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
        ((JComboBox)((JTextComponent) ev.getSource()).getParent()).isPopupVisible()) {
          return;
      }

      JRootPane jrp = getRootPane();
      if (jrp != null) {
        JButton b = jrp.getDefaultButton();
        if (b != null && b.isEnabled()) {
          b.doClick();
        }
      }
    }
  }

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();
    if (ev instanceof KeyEvent && ((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER) {
      
      if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
        return;
      }
      
      if (ev.getSource() instanceof JTextComponent && ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
      ((JComboBox)((JTextComponent) ev.getSource()).getParent()).isPopupVisible()) {
        return;
      }
      
      JRootPane jrp = bt.getRootPane();
      if (jrp != null) {
        JButton b = jrp.getDefaultButton();
        if (b != null && b.isEnabled()) {
          b.doClick();
        }
      }
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spellchecker

private int[] computeVisibleSpan() {
  Component parent = pane.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()};
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();
    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
      if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
        return;
      }
      if (
        ev.getSource() instanceof JTextComponent &&
          ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
          ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
      ) {
        return;
      }
      JRootPane jrp = bt.getRootPane();
      if (jrp != null) {
        JButton b = jrp.getDefaultButton();
        if ((b != null) && b.isEnabled()) {
          b.doClick();
        }
      }
    }
  }
}

代码示例来源:origin: com.jgoodies/validation

/**
 * Sets the text component's border to use a new border that shall indicate
 * that the component's content is mandatory.<p>
 *
 * <strong>Note:</strong> The component foreground and border colors are
 * managed by the look&amp;feel implementation. Many l&amp;fs will honor a
 * custom foreground color and custom border configuration. However, some
 * l&amp;fs may ignore these custom settings. It is recommended to check
 * the appearance in all l&amp;fs available in an application.
 *
 * @param comp   the component that gets a new border
 *
 * @see #setMandatoryBackground(JTextComponent)
 * @see #getMandatoryBorder()
 */
public static void setMandatoryBorder(JTextComponent comp) {
  Container parent = comp.getParent();
  if (parent instanceof JViewport) {
    Container grandpa = parent.getParent();
    if (grandpa instanceof JScrollPane) {
      ((JScrollPane) grandpa).setBorder(getMandatoryBorder());
      return;
    }
  }
  comp.setBorder(getMandatoryBorder());
}

代码示例来源:origin: com.jgoodies/jgoodies-validation

/**
 * Sets the text component's border to use a new border that shall indicate
 * that the component's content is mandatory.<p>
 *
 * <strong>Note:</strong> The component foreground and border colors are
 * managed by the look&amp;feel implementation. Many l&amp;fs will honor a
 * custom foreground color and custom border configuration. However, some
 * l&amp;fs may ignore these custom settings. It is recommended to check
 * the appearance in all l&amp;fs available in an application.
 *
 * @param comp   the component that gets a new border
 *
 * @see #setMandatoryBackground(JTextComponent)
 * @see #getMandatoryBorder()
 */
public static void setMandatoryBorder(JTextComponent comp) {
  Container parent = comp.getParent();
  if (parent instanceof JViewport) {
    Container grandpa = parent.getParent();
    if (grandpa instanceof JScrollPane) {
      ((JScrollPane) grandpa).setBorder(getMandatoryBorder());
      return;
    }
  }
  comp.setBorder(getMandatoryBorder());
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();
    if (ev instanceof KeyEvent && ((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER) {
      
      if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
        return;
      }
      
      if (ev.getSource() instanceof JTextComponent && ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
      ((JComboBox)((JTextComponent) ev.getSource()).getParent()).isPopupVisible()) {
        return;
      }
      
      JRootPane jrp = bt.getRootPane();
      if (jrp != null) {
        JButton b = jrp.getDefaultButton();
        if (b != null && b.isEnabled()) {
          b.doClick();
        }
      }
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

private void trySendEnterToDialog() {
  //        System.err.println("SendEnterToDialog");
  EventObject ev = EventQueue.getCurrentEvent();
  if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
    if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
      return;
    }
    if (
      ev.getSource() instanceof JTextComponent &&
        ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
        ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
    ) {
      return;
    }
    JRootPane jrp = getRootPane();
    if (jrp != null) {
      JButton b = jrp.getDefaultButton();
      if ((b != null) && b.isEnabled()) {
        b.doClick();
      }
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

if (ev.getSource() instanceof JTextComponent && ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
((JComboBox)((JTextComponent) ev.getSource()).getParent()).isPopupVisible()) {
  return;

代码示例来源:origin: de.sciss/syntaxpane

public void showFor(final JTextComponent target) {
  oldCaretPosition = target.getCaretPosition();
  Container view = target.getParent();
  Dimension wd = getSize();
  wd.width = target.getVisibleRect().width;

相关文章

JTextComponent类方法