/** * Repaints a single line in this list. * * @param line The line to repaint. */ private void repaintLine(int line) { int y = textArea.getInsets().top; y += line*cellHeight; repaint(0,y, cellWidth,cellHeight); }
/** * Sets the starting line's line number. The default value is * <code>1</code>. Applications can call this method to change this value * if they are displaying a subset of lines in a file, for example. * * @param index The new index. * @see #getLineNumberingStartIndex() */ public void setLineNumberingStartIndex(int index) { if (index!=lineNumberingStartIndex) { lineNumberingStartIndex = index; updateCellWidths(); repaint(); } }
/** * {@inheritDoc} */ @Override void handleDocumentEvent(DocumentEvent e) { int newLastLine = calculateLastVisibleLineNumber(); if (newLastLine!=lastVisibleLine) { // Adjust the amount of space the line numbers take up, // if necessary. if (newLastLine/10 != lastVisibleLine/10) { updateCellWidths(); } lastVisibleLine = newLastLine; repaint(); } }
/** * Changes the height of the cells in the JList so that they are as tall as * font. This function should be called whenever the user changes the Font * of <code>textArea</code>. */ private void updateCellHeights() { if (textArea!=null) { cellHeight = textArea.getLineHeight(); ascent = textArea.getMaxAscent(); } else { cellHeight = 20; // Arbitrary number. ascent = 5; // Also arbitrary } repaint(); }
currentLine = textArea.getDocument(). getDefaultRootElement().getElementIndex(dot); repaint(); // *Could* be optimized...
/** * Repaints a single line in this list. * * @param line The line to repaint. */ private void repaintLine(int line) { int y = textArea.getInsets().top; y += line*cellHeight; repaint(0,y, cellWidth,cellHeight); }
/** * Repaints a single line in this list. * * @param line The line to repaint. */ private void repaintLine(int line) { int y = textArea.getInsets().top; y += line*cellHeight; repaint(0,y, cellWidth,cellHeight); }
/** * Repaints a single line in this list. * * @param line The line to repaint. */ private void repaintLine(int line) { int y = textArea.getInsets().top; y += line*cellHeight; repaint(0,y, cellWidth,cellHeight); }
/** * Sets the starting line's line number. The default value is * <code>1</code>. Applications can call this method to change this value * if they are displaying a subset of lines in a file, for example. * * @param index The new index. * @see #getLineNumberingStartIndex() */ public void setLineNumberingStartIndex(int index) { if (index!=lineNumberingStartIndex) { lineNumberingStartIndex = index; updateCellWidths(); repaint(); } }
public void propertyChange(PropertyChangeEvent e) { String name = e.getPropertyName(); // If they changed the background color of the text area. if ("background".equals(name)) { Color bg = textArea.getBackground(); setBackground(bg==null ? Color.WHITE : bg); repaint(); } // If they changed the background to an image. else if (RTextArea.BACKGROUND_IMAGE_PROPERTY.equals(name)) { setBackground(Color.WHITE); repaint(); } // If they change the current line highlight in any way... else if (RTextArea.HIGHLIGHT_CURRENT_LINE_PROPERTY.equals(name) || RTextArea.CURRENT_LINE_HIGHLIGHT_COLOR_PROPERTY.equals(name)) { repaintLine(currentLine); } }
/** * {@inheritDoc} */ void handleDocumentEvent(DocumentEvent e) { int newLineCount = textArea!=null ? textArea.getLineCount() : 0; if (newLineCount!=currentLineCount) { // Adjust the amount of space the line numbers take up, // if necessary. if (newLineCount/10 != currentLineCount/10) { updateCellWidths(); } currentLineCount = newLineCount; repaint(); } }
/** * {@inheritDoc} */ void handleDocumentEvent(DocumentEvent e) { int newLineCount = textArea!=null ? textArea.getLineCount() : 0; if (newLineCount!=currentLineCount) { // Adjust the amount of space the line numbers take up, // if necessary. if (newLineCount/10 != currentLineCount/10) { updateCellWidths(); } currentLineCount = newLineCount; repaint(); } }
/** * Changes the height of the cells in the JList so that they are as tall as * font. This function should be called whenever the user changes the Font * of <code>textArea</code>. */ private void updateCellHeights() { if (textArea!=null) { cellHeight = textArea.getLineHeight(); ascent = textArea.getMaxAscent(); } else { cellHeight = 20; // Arbitrary number. ascent = 5; // Also arbitrary } repaint(); }
/** * {@inheritDoc} */ @Override void handleDocumentEvent(DocumentEvent e) { int newLastLine = calculateLastVisibleLineNumber(); if (newLastLine!=lastVisibleLine) { // Adjust the amount of space the line numbers take up, // if necessary. if (newLastLine/10 != lastVisibleLine/10) { updateCellWidths(); } lastVisibleLine = newLastLine; repaint(); } }
/** * Changes the height of the cells in the JList so that they are as tall as * font. This function should be called whenever the user changes the Font * of <code>textArea</code>. */ private void updateCellHeights() { if (textArea!=null) { cellHeight = textArea.getLineHeight(); ascent = textArea.getMaxAscent(); } else { cellHeight = 20; // Arbitrary number. ascent = 5; // Also arbitrary } repaint(); }
/** * Changes the height of the cells in the JList so that they are as tall as * font. This function should be called whenever the user changes the Font * of <code>textArea</code>. */ private void updateCellHeights() { if (textArea!=null) { cellHeight = textArea.getLineHeight(); ascent = textArea.getMaxAscent(); } else { cellHeight = 20; // Arbitrary number. ascent = 5; // Also arbitrary } repaint(); }
currentLine = textArea.getDocument(). getDefaultRootElement().getElementIndex(dot); repaint(); // *Could* be optimized...
currentLine = textArea.getDocument(). getDefaultRootElement().getElementIndex(dot); repaint(); // *Could* be optimized...
currentLine = textArea.getDocument(). getDefaultRootElement().getElementIndex(dot); repaint(); // *Could* be optimized...