2

Possible Duplicate:
Line numbers in jtextpane in Netbeans

I wanted to implement linenumbers.

   JTextpane linenumbers = new JTextPane("1\n2\n3\n4\n");
   // in my project I'm using a function to generate the String with the numbers.
   //I think that this is not important for my problem.

   JTextPane text = new JTextPane();
   JScrollPane scroll = new ScrollPane(text);

   scroll.setRowheaderView(linenumbers);

   // I'm adding my scroll to my extended JFrame-Class
   this.add(scroll, BorderLayout.CENTER);

but I have shift between linenumbers and text. What must I do to have the line text and the linenumbering in one line?

Community
  • 1
  • 1
Alexei
  • 347
  • 2
  • 10
  • no, it isn't a duplicate, but thanks for the link :) – Alexei Jan 15 '13 at 11:44
  • You are welcome; it may help to edit your question as to how the [suggested approach](http://stackoverflow.com/questions/8995431/line-numbers-in-jtextpane-in-netbeans), which also uses `setRowheaderView()`, fails to address the problem. – trashgod Jan 15 '13 at 11:53
  • 1
    Your code does not compile and does not illustrate your issue. I have taken your code, fixed all issues and line numbers are perfectly aligned. Post an [SSCCE](http://sscce.org) if you want to get decent answers. – Guillaume Polet Jan 15 '13 at 12:10
  • thank you for your hint. I used linenumbers.setMargin(new Insets(0, 4, 0, 4)); in my code and did not notice it. – Alexei Jan 15 '13 at 14:21

0 Answers0