Little Help, add editor in JPane

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Little Help, add editor in JPane

Postby Matias22 » Mon Mar 15, 2010 3:26 pm

Hello, i have one question and i really would like to know answer, would be great if someone could help me.

Ok so I have window with JPane called: jPanel22

And i cant or dont have idea how can i add RSyntaxTextArea into this JPane..

I made something like:

Code: Select all
          RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
          textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
          jPanel22.add(new RTextScrollPane(textArea));


but it doesnt work :( (I cant see this RSytntaxtTextArea in my window..)

Please and thanx for ANY help.
Matias22
 
Posts: 13
Joined: Fri Feb 26, 2010 4:46 pm

Re: Little Help, add editor in JPane

Postby Guest » Mon Mar 15, 2010 9:20 pm

/Edit - ok thanx anyway, everything works fine now. But i have only little problem, my editor doest have lines counting, can you tell me how can i add them?
Guest
 

Re: Little Help, add editor in JPane

Postby robert » Tue Mar 16, 2010 3:25 am

Hi Matias,

Glad you got your RSTA showing up in your application! To make line numbers visible, call setLineNumbersEnabled(true) on your RTextScrollPane:

Code: Select all
RSyntaxTextArea textArea = new RSyntaxTextArea(25, 40);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
RTextScrollPane sp = new RTextScrollPane(textArea);
sp.setLineNumbersEnabled(true);
// ...


Please post back if you have any more questions.
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Little Help, add editor in JPane

Postby Matias22 » Tue Mar 16, 2010 1:08 pm

Thanx for reply, but it still doesnt work :(

I have something like this:

Code: Select all
      RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
      textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
      jPanel22.add(new RTextScrollPane(textArea));
      textArea.setFont(new java.awt.Font("Lucida Console", 0, 12));

      

      CompletionProvider provider = createCompletionProvider();


      AutoCompletion ac = new AutoCompletion(provider);
      ac.install(textArea);
      
      
      
        textArea.setColumns(20);
        textArea.setRows(5);
        jScrollPane1.setViewportView(textArea);
Matias22
 
Posts: 13
Joined: Fri Feb 26, 2010 4:46 pm

Re: Little Help, add editor in JPane

Postby robert » Tue Mar 16, 2010 4:30 pm

It doesn't look like you called setLineNumbersEnabled(true) anywhere?
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Little Help, add editor in JPane

Postby Guest » Tue Mar 16, 2010 5:26 pm

Code: Select all
      RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
      textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
      jPanel22.add(new RTextScrollPane(textArea));
      textArea.setFont(new java.awt.Font("Lucida Console", 0, 12));
      RTextScrollPane sp = new RTextScrollPane(textArea);
        sp.setLineNumbersEnabled(true);

      CompletionProvider provider = createCompletionProvider();


      AutoCompletion ac = new AutoCompletion(provider);
      ac.install(textArea);
      
      
      
        textArea.setColumns(20);
        textArea.setRows(5);
        jScrollPane1.setViewportView(textArea);


And still the same results (no line counting) yes im sure it something wrong with this code :P
Guest
 

Re: Little Help, add editor in JPane

Postby robert » Tue Mar 16, 2010 7:05 pm

You're enabling line numbers on an RTextScrollPane, but not the one you've added to jPanel22. You shouldn't create a new scroll pane but rather modify the one you're adding to your GUI. Try this:

Code: Select all
RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
RTextScrollPane sp = new RTextScrollPane(textArea);
sp.setLineNumbersEnabled(true);
jPanel22.add(sp);
textArea.setFont(new java.awt.Font("Lucida Console", 0, 12));
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Little Help, add editor in JPane

Postby Matias22 » Tue Mar 16, 2010 7:15 pm

Still the same : (

Image
Matias22
 
Posts: 13
Joined: Fri Feb 26, 2010 4:46 pm

Re: Little Help, add editor in JPane

Postby robert » Wed Mar 17, 2010 1:13 am

Hmm... please post an SSCCE that demonstrates this problem, so I can reproduce it.

http://sscce.org/
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Little Help, add editor in JPane

Postby Matias22 » Mon Mar 22, 2010 2:07 pm

Check your PM's please.
Matias22
 
Posts: 13
Joined: Fri Feb 26, 2010 4:46 pm

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 4 guests

cron