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

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

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

JTextComponent.setDocument介绍

暂无

代码示例

代码示例来源:origin: zgqq/mah

public void setDocument(Document document) {
  this.input.setDocument(document);
  listenInput((JTextPane) input);
}

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

textArea.setDocument(model.getDocument());
textArea.setEditable(false);
textArea.setLineWrap(true);

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

mirroredEditor.setDocument(editor.getDocument());

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

textComponent.setDocument(textFieldLimit);

代码示例来源:origin: org.activecomponents.jadex/jadex-commons-gui

/**
   * 
   */
  public void setEditor(ComboBoxEditor anEditor)
  {
    super.setEditor(anEditor);
    JTextComponent comp = (JTextComponent)getEditor().getEditorComponent();
    if(comp.getDocument() instanceof AutoCompleteCombo.AutoCompleteDocument)
    {
      AutoCompleteCombo.AutoCompleteDocument doc = (AutoCompleteCombo.AutoCompleteDocument)comp.getDocument();
      doc.dispose();
    }
    comp.setDocument(new AutoCompleteDocument());
  }
//

代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-swing-widget

/**
 * Désactive l'aut-complétion sur une liste déroulante, en y repositionnant
 * le modèle du document d'édition d'avant auto-complétion.
 *
 * @param combo la liste déroulante à décorer
 * @param originalDocument le document original de l'édtieur de la
 *        liste déroulante.
 */
public static void undecorate(JComboBox combo, Document originalDocument) {
  // has not to be editable
  combo.setEditable(false);
  // configure the text component=editor component
  Component c = combo.getEditor().getEditorComponent();
  JTextComponent editorComponent = (JTextComponent) c;
  editorComponent.setDocument(originalDocument);
  editorComponent.setText(null);
  //remove old property change listener
  for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) {
    if (l instanceof AutoCompletePropertyChangeListener) {
      c.removePropertyChangeListener("editor", l);
    }
  }
}

代码示例来源:origin: org.xworker/xworker_core

public static void createDocument(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  JTextComponent parent = (JTextComponent) actionContext.get("parent");
  
  for(Thing child : self.getChilds()){
    Document l = (Document) child.doAction("create", actionContext);
    if(l != null){
      parent.setDocument(l);
      break;
    }
  }
}

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets

static void undecorate(JTextComponent textComponent, Document originalDocument) {
  Document doc = textComponent.getDocument();
  if (doc instanceof AutoCompleteDocument) {
    //remove autocomplete key/action mappings
    InputMap map = textComponent.getInputMap();
    while (map.getParent() != null) {
      InputMap parent = map.getParent();
      //if (parent instanceof AutoComplete.InputMap) {
      if (parent.getClass().getName().contains("AutoComplete")) {
        map.setParent(parent.getParent());
      }
      map = parent;
    }
    textComponent.getActionMap().put("nonstrict-backspace", null);
    //remove old focus listener
    for (FocusListener l : textComponent.getFocusListeners()) {
      //if (l instanceof AutoComplete.FocusAdapter) {
      if (l.getClass().getName().contains("AutoComplete")) {
        textComponent.removeFocusListener(l);
        break;
      }
    }
    //reset to original document
    //textComponent.setDocument(((AutoCompleteDocument) doc).delegate);
    textComponent.setDocument(originalDocument);
  }
}

代码示例来源:origin: triplea-game/triplea

void configureEditor(final ComboBoxEditor newEditor) {
 if (editor != null) {
  editor.removeKeyListener(editorKeyListener);
  editor.removeFocusListener(editorFocusListener);
 }
 if (newEditor != null) {
  editor = (JTextComponent) newEditor.getEditorComponent();
  editor.addKeyListener(editorKeyListener);
  editor.addFocusListener(editorFocusListener);
  editor.setDocument(this);
 }
}

代码示例来源:origin: net.sf.cuf/cuf-swing

void configureEditor(final ComboBoxEditor pNewEditor)
{
  if (mEditor != null)
  {
    mEditor.removeKeyListener(mEditorKeyListener);
    mEditor.removeFocusListener(mEditorFocusListener);
  }
  if (pNewEditor != null)
  {
    mEditor = (JTextComponent) pNewEditor.getEditorComponent();
    mEditor.addKeyListener(mEditorKeyListener);
    mEditor.addFocusListener(mEditorFocusListener);
    mEditor.setDocument(this);
  }
}

代码示例来源:origin: net.sf.cuf/cuf-swing

mComboBox.setModel(mModel);
mDocument = new FilteringDocument();
mTextComponent.setDocument(mDocument);

代码示例来源:origin: tmyroadctfig/swingx

textComponent.setDocument(((AutoCompleteDocument) doc).delegate);

代码示例来源:origin: com.jidesoft/jide-oss

private void configureEditor(JTextComponent textComponent) {
    if (getTextComponent() != null) {
      getTextComponent().removeKeyListener(_editorKeyListener);
//            getTextComponent().removeFocusListener(_editorFocusListener);
    }

    if (textComponent != null) {
      _textComponent = textComponent;
      getTextComponent().addKeyListener(_editorKeyListener);
//            getTextComponent().addFocusListener(_editorFocusListener);
      String text = getTextComponent().getText();
      _oldDocument = getTextComponent().getDocument();
      if (_oldDocument instanceof AbstractDocument && _document != null) {
        _document.setDocumentFilter(((AbstractDocument) _oldDocument).getDocumentFilter());
      }
      getTextComponent().setDocument(_document);
      getTextComponent().setText(text);
    }
  }

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

editorPane.setDocument(document);

代码示例来源:origin: org.swinglabs.swingx/swingx-all

textComponent.setDocument(((AutoCompleteDocument) doc).delegate);

代码示例来源:origin: com.jidesoft/jide-oss

/**
   * Uninstalls the listeners so that the component is not auto-completion anymore.
   */
  public void uninstallListeners() {
    if (_propertyChangeListener != null && _comboBox != null) {
      _comboBox.removePropertyChangeListener(_propertyChangeListener);
    }

    if (getTextComponent() != null) {
      getTextComponent().removeKeyListener(_editorKeyListener);
//            getTextComponent().removeFocusListener(_editorFocusListener);
      String text = getTextComponent().getText();
      if (_oldDocument != null) {
        getTextComponent().setDocument(_oldDocument);
        _oldDocument = null;
      }
      getTextComponent().setText(text);
    }
    getTextComponent().putClientProperty(CLIENT_PROPERTY_AUTO_COMPLETION, null);
  }

代码示例来源:origin: datacleaner/DataCleaner

public HeaderLineComboBox(boolean hasHeaderByDefault) {
    super();
    final JTextComponent headerLineNumberText = (JTextComponent) getEditor().getEditorComponent();
    headerLineNumberText.setDocument(new NumberDocument());
    setEditable(true);
    setModel(new DefaultComboBoxModel<>(new Integer[] { 0, 1 }));
    if (hasHeaderByDefault) {
      setSelectedItem(1);
    }
    setRenderer(new DCListCellRenderer() {

      private static final long serialVersionUID = 1L;

      @Override
      public Component getListCellRendererComponent(final JList<?> list, Object value, final int index,
          final boolean isSelected, final boolean cellHasFocus) {
        if (value instanceof Integer) {
          final Integer i = (Integer) value;
          if (i <= 0) {
            value = "No header";
          }
        }
        return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      }

    });
  }
}

代码示例来源:origin: openstreetmap/osmembrane

/**
 * Creates a new combo box with auto completion support.
 */
public AutoCompletingComboBox() {
  setRenderer(new AutoCompleteListCellRenderer());
  final JTextComponent editor = (JTextComponent) this.getEditor()
      .getEditorComponent();
  editor.setDocument(new AutoCompletingComboBoxDocument(this));
  editor.addFocusListener(new FocusListener() {
    public void focusLost(FocusEvent e) {
    }
    public void focusGained(FocusEvent e) {
      editor.selectAll();
    }
  });
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

textComponent.setDocument(document);

代码示例来源:origin: tmyroadctfig/swingx

textComponent.setDocument(document);

相关文章

JTextComponent类方法