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

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

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

JTextComponent.isShowing介绍

暂无

代码示例

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

public boolean isShowing() { return textComponent.isShowing(); }

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

protected void refresh(){
  if (getComponent().isShowing() && needsRefresh){
    modelChanged();
    needsRefresh = false;
  }
}

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

public void showPopupMenu(int x, int y) {
  // First call the build-popup-menu action to possibly rebuild the popup menu
  JTextComponent component = getComponent();
  if (component != null) {
    BaseKit kit = Utilities.getKit(component);
    if (kit != null) {
      Action a = kit.getActionByName(ExtKit.buildPopupMenuAction);
      if (a != null) {
        a.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N
      }
    }
    JPopupMenu pm = getPopupMenu();
    if (pm != null) {
      if (component.isShowing()) { // fix of #18808
        pm.show(component, x, y);
      }
    }
  }
}

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

public void showPopupMenu(int x, int y) {
  // First call the build-popup-menu action to possibly rebuild the popup
  // menu
  JTextComponent component = getComponent();
  if (component != null) {
    BaseKit kit = Utilities.getKit(component);
    if (kit != null) {
      Action a = kit.getActionByName(ExtKit.buildPopupMenuAction);
      if (a != null) {
        a.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N
      }
    }
    JPopupMenu pm = getPopupMenu();
    if (pm != null) {
      if (component.isShowing()) { // fix of #18808
        pm.show(component, x, y);
      }
    }
  }
}

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

public void start() {
  // Possibly clear editor from previous error message (#115073)
  String lastMessage = mostRecentMessage;
  if (lastMessage != null) {
    JTextComponent pane = EditorRegistry.lastFocusedComponent();
    if (pane != null) {
      if (pane.isShowing()) {
        String text = Utilities.getStatusText(pane);
        if (lastMessage.equals(text)) {
          Utilities.clearStatusText(pane);
        }
      }
    }
    mostRecentMessage = null;
  }
  resetResults();
}

代码示例来源:origin: notzippy/JALOPY2-MAIN

public void keyPressed(KeyEvent ev)
  {
    if (ev.isShiftDown() && (ev.getKeyCode() == KeyEvent.VK_F10))
    {
      JTextComponent component = (JTextComponent) ev.getSource();
      if (component.isShowing())
      {
        try
        {
          Rectangle r = component.modelToView(component.getCaretPosition());
          getPopup(component).show(component, r.x, r.y);
        }
        catch (BadLocationException ignored)
        {
          ;
        }
      }
    }
  }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

public void showSmartFix( final int offset, final int length, final String displayText )
{
 Runnable runnable = () -> {
  try
  {
   _offset = offset;
   _length = length;
   Rectangle rectangle = getLocationFromOffset( _offset );
   if( rectangle != TEST_RECTANGLE && _editor.isShowing() )
   {
    _managerPopup = new SmartFixPopup( displayText );
   }
   _editor.getHighlighter().addHighlight( _offset, _offset + _length, new SmartFixHighlightPainter( SMARTFIX_HIGHLIGHT_COLOR ) );
  }
  catch( BadLocationException e )
  {
   resetSmartHelpState();  //The user must have cleared out the given smart fix.
  }
 };
 SwingUtilities.invokeLater( runnable );
}

代码示例来源:origin: otros-systems/otroslogviewer

private void setSuggestionWindowLocation() {
 if (textComponent.isShowing()){
  suggestionWindow.pack();
  if (textComponent instanceof JTextField) {
   int width = Math.max(textComponent.getWidth(), suggestionWindow.getWidth());
   int screenHeight = suggestionWindow.getGraphicsConfiguration().getDevice().getDisplayMode().getHeight();
   suggestionWindow.setSize(width, (int) Math.min(suggestionWindow.getHeight(), screenHeight / 2));
   int x = (int) textComponent.getLocationOnScreen().getX();
   int y = (int) (textComponent.getLocationOnScreen().getY() + textComponent.getHeight());
   suggestionWindow.setLocation(x, y);
  } else {
   try {
    final int caretPosition = Math.min(textComponent.getText().length(), textComponent.getCaretPosition());
    final Rectangle rectangle = textComponent.modelToView(caretPosition);
    final Point p = new Point(rectangle.x, rectangle.y + rectangle.height);
    SwingUtilities.convertPointToScreen(p, textComponent);
    suggestionWindow.setLocation(p.x, p.y);
   } catch (BadLocationException e) {
    e.printStackTrace();
   }
  }
 }
}

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

public static boolean isEnabled() {
  if (EditorRegistry.lastFocusedComponent() == null
      || !EditorRegistry.lastFocusedComponent().isShowing())
  {
    return false;
  }
  if ( OpenProjects.getDefault().getOpenProjects().length == 0 ){
    return false;
  }
  final FileObject fileObject = NbEditorUtilities.getFileObject( 
      EditorRegistry.lastFocusedComponent().getDocument());
  return isEnabled( fileObject );
  /*WebModule webModule = WebModule.getWebModule(fileObject);
  if ( webModule == null ){
    return false;
  }
  Profile profile = webModule.getJ2eeProfile();
  return Profile.JAVA_EE_6_WEB.equals( profile) || 
    Profile.JAVA_EE_6_FULL.equals( profile );*/
}

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

/**
 * Attributes were changed in the are this view is responsible for.
 * 
 * @param e
 *            the change information from the associated document
 * @param a
 *            the current allocation of the view
 * @param f
 *            the factory to use to rebuild if the view has children
 */
public void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
  try {
    if (getComponent().isShowing()) {
      getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
    }
  } catch (BadLocationException ex) {
    if (Boolean.getBoolean("netbeans.debug.exceptions")) { // NOI18N
      ex.printStackTrace();
    }
  }
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

@Override
 public void run()
 {
  try
  {
   _offset = offset;
   _length = length;
   Rectangle rectangle = getLocationFromOffset( _offset );
   if( rectangle != TEST_RECTANGLE && _editor.isShowing() )
   {
    _managerPopup = new SmartFixPopup( displayText );
   }
   _editor.getHighlighter().addHighlight( _offset, _offset + _length, new SmartFixHighlightPainter( SMARTFIX_HIGHLIGHT_COLOR ) );
  }
  catch( BadLocationException e )
  {
   resetSmartHelpState();  //The user must have cleared out the given smart fix.
  }
 }
};

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

/** Remove from document notification. */
public void removeUpdate(DocumentEvent evt) {
  try {
    BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
    EditorUI editorUI = getEditorUI();
    int y = getYFromPos(evt.getOffset());
    int lineHeight = editorUI.getLineHeight();
    int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
    // !!! patch for case when DocMarksOp.eolMark is at the end of document
    if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
      syntaxY += lineHeight;
    }
    if (getComponent().isShowing()) {
      editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
    }
  } catch (BadLocationException ex) {
    Utilities.annotateLoggable(ex);
  }
}

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

/** Insert to document notification. */
public void insertUpdate(DocumentEvent evt) {
  try {
    BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
    EditorUI editorUI = getEditorUI();
    int y = getYFromPos(evt.getOffset());
    int lineHeight = editorUI.getLineHeight();
    int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
    // !!! patch for case when DocMarksOp.eolMark is at the end of document
    if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
      syntaxY += lineHeight;
    }
    if (getComponent().isShowing()) {
      editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
    }
  } catch (BadLocationException ex) {
    Utilities.annotateLoggable(ex);
  }
}

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

/** Attributes were changed in the are this view is responsible for.
* @param e the change information from the associated document
* @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children
*/
public void changedUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
  try {
    if (getComponent().isShowing()) {
      getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
    }
  } catch (BadLocationException ex) {
    Utilities.annotateLoggable(ex);
  }
}

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

if (getComponent().isShowing()) {
  editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));

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

if (getComponent().isShowing()) {
  editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));

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

if (getComponent().isShowing()) {
  editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));

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

if (getComponent().isShowing()) {
  editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));

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

if (pane.isShowing()) {
  mostRecentMessage = message;
  if (isError()) {

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

/** The change in document notification.
*
* @param evt  The change notification from the currently associated document.
*/
public void changedUpdate(DocumentEvent evt) {
  if (evt instanceof BaseDocumentEvent) {
    BaseDocumentEvent bdevt = (BaseDocumentEvent)evt;
    BaseDocument doc = (BaseDocument)bdevt.getDocument();
    String layerName = bdevt.getDrawLayerName();
    if (layerName != null) {
      getEditorUI().addLayer(doc.findLayer(layerName),
          bdevt.getDrawLayerVisibility());
    }else{ //temp
      try {
        JTextComponent comp = getComponent();
        if (comp!=null && comp.isShowing()) {
          getEditorUI().repaintBlock(evt.getOffset(), evt.getOffset() + evt.getLength());
        }
      } catch (BadLocationException ex) {
        Utilities.annotateLoggable(ex);
      }
    }
  }
}

相关文章

JTextComponent类方法