javax.swing.JEditorPane.setCaretPosition()方法的使用及代码示例

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

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

JEditorPane.setCaretPosition介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

private void displayTsurgeonHelp() {
 if(tsurgeonHelpFrame != null) {
  tsurgeonHelpFrame.setVisible(true);
 } else {
  tsurgeonHelpFrame = new JFrame("TSurgeon Help...");
  JEditorPane helpText = new JEditorPane();
  helpText.setContentType("text/html");
  // StringBuffer s = new StringBuffer();
  // s.append(htmlTsurgeonHelp);
  helpText.setText(htmlTsurgeonHelp);
  helpText.setEditable(false);
  JScrollPane scroller = new JScrollPane(helpText);
  helpText.setCaretPosition(0);
  scroller.setPreferredSize(new Dimension(500,500));
  tsurgeonHelpFrame.add(scroller);
  tsurgeonHelpFrame.pack();
  tsurgeonHelpFrame.setBackground(Color.WHITE);
  tsurgeonHelpFrame.setVisible(true);
 }
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void displayHelp() {
 if (helpFrame != null) {
  helpFrame.setVisible(true);
 } else {
  helpFrame = new JFrame("Tregex Help...");
  //JPanel helpPanel = new JPanel();
  JEditorPane helpText = new JEditorPane();
  helpText.setContentType("text/html");
  // StringBuffer s = new StringBuffer();
  // s.append(htmlHelp);
  helpText.setText(htmlHelp);
  helpText.setEditable(false);
  //helpPanel.add(helpText);
  JScrollPane scroller = new JScrollPane(helpText);
  helpText.setCaretPosition(0);
  scroller.setPreferredSize(new Dimension(500,500));
  helpFrame.add(scroller);
  helpFrame.pack();
  helpFrame.setBackground(Color.WHITE);
  helpFrame.setVisible(true);
  //helpFrame.repaint();
 }
}

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

/** @see ListSelectionListener **/
public void valueChanged(ListSelectionEvent aEvent) {
  //Ignore extra messages.
  if (aEvent.getValueIsAdjusting()) {
    return;
  }
  final ListSelectionModel lsm = (ListSelectionModel) aEvent.getSource();
  if (lsm.isSelectionEmpty()) {
    mDetails.setText("Nothing selected");
  } else {
    final int selectedRow = lsm.getMinSelectionIndex();
    final EventDetails e = mModel.getEventDetails(selectedRow);
    final Object[] args =
    {
      new Date(e.getTimeStamp()),
      e.getPriority(),
      escape(e.getThreadName()),
      escape(e.getNDC()),
      escape(e.getCategoryName()),
      escape(e.getLocationDetails()),
      escape(e.getMessage()),
      escape(getThrowableStrRep(e))
    };
    mDetails.setText(FORMATTER.format(args));
    mDetails.setCaretPosition(0);
  }
}

代码示例来源:origin: apache/tika

private void setText(JEditorPane editor, String text) {
  editor.setText(text);
  editor.setCaretPosition(0);
}

代码示例来源:origin: apache/tika

private void handleError(String name, Throwable t) {
  StringWriter writer = new StringWriter();
  writer.append("Apache Tika was unable to parse the document\n");
  writer.append("at " + name + ".\n\n");
  writer.append("The full exception stack trace is included below:\n\n");
  t.printStackTrace(new PrintWriter(writer));
  JEditorPane editor =
    new JEditorPane("text/plain", writer.toString());
  editor.setEditable(false);
  editor.setBackground(Color.WHITE);
  editor.setCaretPosition(0);
  editor.setPreferredSize(new Dimension(600, 400));
  JDialog dialog = new JDialog(this, "Apache Tika error");
  dialog.add(new JScrollPane(editor));
  dialog.pack();
  dialog.setVisible(true);
}

代码示例来源:origin: apache/tika

public void hyperlinkUpdate(HyperlinkEvent e) {
  if (e.getEventType() == EventType.ACTIVATED) {
    try {
      URL url = e.getURL();
      try (InputStream stream = url.openStream()) {
        JEditorPane editor =
          new JEditorPane("text/plain", IOUtils.toString(stream, UTF_8));
        editor.setEditable(false);
        editor.setBackground(Color.WHITE);
        editor.setCaretPosition(0);
        editor.setPreferredSize(new Dimension(600, 400));
        String name = url.toString();
        name = name.substring(name.lastIndexOf('/') + 1);
        JDialog dialog = new JDialog(this, "Apache Tika: " + name);
        dialog.add(new JScrollPane(editor));
        dialog.pack();
        dialog.setVisible(true);
      }
    } catch (IOException exception) {
      exception.printStackTrace();
    }
  }
}

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

@Override
  public void run() {
    jEditorPane.setCaretPosition(0);
  }
});

代码示例来源:origin: net.sf.taverna.t2.ui-activities/beanshell-activity-ui

public void actionPerformed(ActionEvent e) {
    String newScript = FileTools.readStringFromFile(BeanshellConfigView.this, "Load Beanshell script", ".bsh");
    if (newScript != null) {
      scriptTextArea.setText(newScript);
      scriptTextArea.setCaretPosition(0);
    }
  }
});

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

private void showRenderJSONResponse(String response) {
  results.setContentType("text/plain"); // $NON-NLS-1$
  results.setText(response == null ? "" : prettyJSON(response));
  results.setCaretPosition(0);
  resultsScrollPane.setViewportView(results);
}

代码示例来源:origin: kaikramer/keystore-explorer

@Override
  public void actionPerformed(ActionEvent e) {
    try {
      CursorUtil.setCursorBusy(DTipOfTheDay.this);
      jepTip.setText(getPreviousTip());
      jepTip.setCaretPosition(0);
    } finally {
      CursorUtil.setCursorFree(DTipOfTheDay.this);
    }
  }
});

代码示例来源:origin: kaikramer/keystore-explorer

@Override
  public void actionPerformed(ActionEvent e) {
    try {
      CursorUtil.setCursorBusy(DTipOfTheDay.this);
      jepTip.setText(getNextTip());
      jepTip.setCaretPosition(0);
    } finally {
      CursorUtil.setCursorFree(DTipOfTheDay.this);
    }
  }
});

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

private void showTextResponse(String response) {
  results.setContentType("text/plain"); // $NON-NLS-1$
  results.setText(response == null ? "" : response); // $NON-NLS-1$
  results.setCaretPosition(0);
  resultsScrollPane.setViewportView(results);
  // Bug 55111 - Refresh JEditor pane size depending on the presence or absence of scrollbars
  resultsScrollPane.setPreferredSize(resultsScrollPane.getMinimumSize());
  results.revalidate();
}

代码示例来源:origin: eu.mihosoft.vrl/vrl

private void updateCaretPos(KeyEvent e) {
  if (getEditor().getCaretPosition() <= startPos) {
    getEditor().setCaretPosition(startPos);
    if (e == null) {
      return;
    }
    if (e.getKeyCode() == KeyEvent.VK_LEFT
        || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
      e.consume();
    }
  }
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

private void showDocumentResponse(SampleResult sampleResult) {
  String response = Document.getTextFromDocument(sampleResult.getResponseData());
  results.setContentType("text/plain"); // $NON-NLS-1$
  results.setText(response);
  results.setCaretPosition(0);
  resultsScrollPane.setViewportView(results);
}

代码示例来源:origin: SonarSource/sonarlint-intellij

private void updateEditor(String text) {
 ApplicationManager.getApplication().assertIsDispatchThread();
 if (editor == null) {
  panel.removeAll();
  editor = createEditor();
  panel.add(editor, BorderLayout.CENTER);
 }
 SwingHelper.setHtml(editor, text, null);
 editor.setCaretPosition(0);
 panel.revalidate();
}

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

public void setCredits(String credits, String contentType) {
  if(credits != null) {
    ggCredits.setContentType(contentType);
  }
  ggCredits.setText(credits != null?credits:"");
  ggCredits.setCaretPosition(0);
  scrollCredits.setVisible(credits != null);
  packAndCenter();
}

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

private void prevMacroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevMacroActionPerformed
    Document doc = jCodeExpansionEditorPane.getDocument();
    if (doc == null) {
      return;
    }
    int offset = CsmMacroExpansion.getPrevMacroExpansionStartOffset(doc, jCodeExpansionEditorPane.getCaretPosition());
    if (offset >= 0 && offset < doc.getLength()) {
      jCodeExpansionEditorPane.setCaretPosition(offset);
    }
}//GEN-LAST:event_prevMacroActionPerformed

代码示例来源:origin: com.synaptix/SynaptixSwing

public int showDialog(Component parent, String title, String text) {
  returnValue = CLOSE_OPTION;
  rapportPane.setText(text);
  dialog = new JDialogModel(parent, TEXT_TITLE + " " + title, this, new Action[] { closeAction }, closeAction);
  dialog.setResizable(true);
  rapportPane.setCaretPosition(0);
  dialog.showDialog();
  dialog.dispose();
  return returnValue;
}

代码示例来源:origin: org.codehaus.izpack/izpack-panel

public void panelActivate()
{
  super.panelActivate();
  String nextText = getString("SummaryPanel.next");
  if (nextText == null)
  {
    nextText = getString("installer.next");
  }
  parent.getNavigator().setNextText(nextText);
  textArea.setText(SummaryProcessor.getSummary(this.installData));
  textArea.setCaretPosition(0);
}

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

@Override
  public void run() {
    final SHTMLPanel htmlEditorPanel = getHtmlEditorPanel();
    htmlEditorPanel.getMostRecentFocusOwner().requestFocus();
    if (ResourceController.getResourceController().getBooleanProperty("goto_note_end_on_edit")) {
      final JEditorPane editorPane = htmlEditorPanel.getEditorPane();
      editorPane.setCaretPosition(editorPane.getDocument().getLength());
    }
  }
});

相关文章

JEditorPane类方法