/** * Scrolls forward one sentence in the text */ public void scrollForward() { highlightSentence(endIndex + 1); // scroll to highlight location textPane.setCaretPosition(startIndex); }
/** * Scrolls back one sentence in the text */ public void scrollBack() { highlightSentence(startIndex - 1); // scroll to highlight location textPane.setCaretPosition(startIndex); }
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); }
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); } }
forwardButton.setEnabled(endIndex != textPane.getText().length() - 1); textPane.setCaretPosition(0);
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(); }
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);
tokenPane.setCaretPosition(0); reader.close();
/** * 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()); }
@Override public void actionPerformed(ActionEvent e) { isFiltering = filter.isSelected(); StringBuilder buffer = new StringBuilder(); stacktrace.setText(generateStackTrace(error, buffer).toString()); stacktrace.setCaretPosition(0); stacktrace.repaint(); } });
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); }
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); }
@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(); } });
jtp.setText(aText); jtp.setEditable(false); jtp.setCaretPosition(0);
textPane.setCaretPosition(doc.getLength());
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));*/ }
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);*/ }
javaTextPane.getProxy().setCaretPosition(javaTextPane.getProxy().getDocument().getLength());
public void run() { text.insertIcon(icon); resetCommandStart(); text.setCaretPosition(cmdStart); } });
@Override public void removeUpdate(DocumentEvent e) { editor.setCaretPosition(e.getOffset()); }