Пример #1
0
  /**
   * Create a line number component for a text component.
   *
   * @param component the related text component
   * @param minimumDisplayDigits the number of digits used to calculate the minimum width of the
   *     component
   */
  public TextLineNumber(JTextComponent component, int minimumDisplayDigits) {
    this.component = component;

    setFont(component.getFont());

    setBorderGap(5);
    setCurrentLineForeground(Color.RED);
    setDigitAlignment(RIGHT);
    setMinimumDisplayDigits(minimumDisplayDigits);

    component.getDocument().addDocumentListener(this);
    component.addCaretListener(this);
    component.addPropertyChangeListener("font", this);
  }
Пример #2
0
 @Override
 public void install(final JTextComponent c) {
   super.install(c);
   isMultiLineEditor = c instanceof JTextArea || c instanceof JEditorPane;
   c.addPropertyChangeListener(this);
 }