本文整理了Java中javax.swing.JTextPane.setCaretPosition()
方法的一些代码示例,展示了JTextPane.setCaretPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.setCaretPosition()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:setCaretPosition
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Scrolls forward one sentence in the text
*/
public void scrollForward() {
highlightSentence(endIndex + 1);
// scroll to highlight location
textPane.setCaretPosition(startIndex);
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Scrolls back one sentence in the text
*/
public void scrollBack() {
highlightSentence(startIndex - 1);
// scroll to highlight location
textPane.setCaretPosition(startIndex);
}
代码示例来源:origin: org.codehaus.groovy/groovy
private void insertComponent(JComponent comp) {
try {
tokenPane.getDocument().insertString(tokenPane.getDocument().getLength(), " ", null);
} catch (BadLocationException ex1) {
// Ignore
}
try {
tokenPane.setCaretPosition(tokenPane.getDocument().getLength() - 1);
} catch (Exception ex) {
tokenPane.setCaretPosition(0);
}
tokenPane.insertComponent(comp);
}
代码示例来源:origin: zzz40500/GsonFormat
public ErrorDialog(String errorInfo) {
setContentPane(contentPane);
setTitle("Error Info");
getRootPane().setDefaultButton(okButton);
this.setAlwaysOnTop(true);
editTP.setText(errorInfo);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
editTP.setCaretPosition(0);
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
forwardButton.setEnabled(endIndex != textPane.getText().length() - 1);
textPane.setCaretPosition(0);
代码示例来源:origin: chewiebug/GCViewer
private void initComponents(String fileName) {
super.initComponents();
JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setContentType("text/html");
textPane.addHyperlinkListener(new HyperlinkAdapter(this));
try {
textPane.setText(readFile(fileName));
textPane.setCaretPosition(0);
}
catch (IOException e) {
e.printStackTrace();
}
JScrollPane scrollPane = new JScrollPane(
textPane,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
getContentPane().add("Center", scrollPane);
pack();
}
代码示例来源:origin: wiztools/rest-client
jtp_help_center.setText(helpText);
jtp_help_center.setPreferredSize(d);
jtp_help_center.setCaretPosition(0);
JScrollPane jsp_center = new JScrollPane(jtp_help_center);
jp_help.add(jsp_center, BorderLayout.CENTER);
代码示例来源:origin: org.codehaus.groovy/groovy
tokenPane.setCaretPosition(0);
reader.close();
代码示例来源:origin: RipMeApp/ripme
/**
* Write a line to the Log section of the GUI
*
* @param text the string to log
* @param color the color of the line
*/
private void appendLog(final String text, final Color color) {
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setForeground(sas, color);
StyledDocument sd = logText.getStyledDocument();
try {
synchronized (this) {
sd.insertString(sd.getLength(), text + "\n", sas);
}
} catch (BadLocationException e) { }
logText.setCaretPosition(sd.getLength());
}
代码示例来源:origin: apache/pdfbox
@Override
public void actionPerformed(ActionEvent e)
{
isFiltering = filter.isSelected();
StringBuilder buffer = new StringBuilder();
stacktrace.setText(generateStackTrace(error, buffer).toString());
stacktrace.setCaretPosition(0);
stacktrace.repaint();
}
});
代码示例来源:origin: magefree/mage
private void drawText(java.util.List<String> strings) {
text.setText("");
StyledDocument doc = text.getStyledDocument();
try {
for (String line : strings) {
doc.insertString(doc.getLength(), line + '\n', doc.getStyle("regular"));
}
} catch (BadLocationException ble) {
}
text.setCaretPosition(0);
}
代码示例来源:origin: magefree/mage
protected void drawText() {
text.setText("");
StyledDocument doc = text.getStyledDocument();
try {
for (String rule : getRules()) {
doc.insertString(doc.getLength(), rule + '\n', doc.getStyle("small"));
}
} catch (BadLocationException e) {
}
text.setCaretPosition(0);
}
代码示例来源:origin: apache/pdfbox
@Override
public void actionPerformed(ActionEvent e)
{
if (showingDetails)
{
main.remove(details);
main.validate();
main.setPreferredSize(MESSAGE_SIZE);
}
else
{
if (details == null)
{
details = createDetailedMessage(error);
StringBuilder buffer = new StringBuilder();
stacktrace.setText(generateStackTrace(error, buffer).toString());
stacktrace.setCaretPosition(0);
stacktrace.setBackground(main.getBackground());
stacktrace.setPreferredSize(STACKTRACE_SIZE);
}
main.add(details, BorderLayout.CENTER);
main.validate();
main.setPreferredSize(TOTAL_SIZE);
}
showingDetails = !showingDetails;
showDetails.setText(showingDetails ? "<< Hide Details" : "Show Details >>");
ErrorDialog.this.pack();
}
});
代码示例来源:origin: RaiMan/SikuliX2
jtp.setText(aText);
jtp.setEditable(false);
jtp.setCaretPosition(0);
代码示例来源:origin: apache/pdfbox
textPane.setCaretPosition(doc.getLength());
代码示例来源:origin: net.sf.ingenias/editor
public void setDescription(String desc){
this.description.setText(desc);
this.description.setCaretPosition(0);
/* scp1.getVerticalScrollBar().setValueIsAdjusting(true);
scp1.getVerticalScrollBar().setValue(0);
scp1.getViewport().toViewCoordinates(new Point(0,0));*/
}
代码示例来源:origin: net.sf.ingenias/editor
public void setRec(String rec){
this.recom.setText(rec);
this.recom.setCaretPosition(0);
/* scp2.getViewport().toViewCoordinates(new Point(0,0));
scp2.getVerticalScrollBar().setValueIsAdjusting(true);
this.scp2.getVerticalScrollBar().setValue(0);*/
}
代码示例来源:origin: ron190/jsql-injection
javaTextPane.getProxy().setCaretPosition(javaTextPane.getProxy().getDocument().getLength());
代码示例来源:origin: beanshell/beanshell
public void run() {
text.insertIcon(icon);
resetCommandStart();
text.setCaretPosition(cmdStart);
}
});
代码示例来源:origin: fr.inria.wimmics/kggui
@Override
public void removeUpdate(DocumentEvent e)
{
editor.setCaretPosition(e.getOffset());
}
内容来源于网络,如有侵权,请联系作者删除!