Grabbing infinity space in BorderLayout?

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Grabbing infinity space in BorderLayout?

Postby Christian9 » Fri Aug 17, 2012 11:23 am


I am using the RSyntaxTextArea within several BorderLayouts and ScrollPanes. In certain conditions when setting setLineWrap(true) it looks like it grabs infinite width in a loop. I reduced my code to the following main-method, so anyone, who wants to proof this, can easily do it:

java code:

public static void main(String[] args) {
RSyntaxTextArea textArea = new RSyntaxTextArea();
RTextScrollPane rScrollPane = new RTextScrollPane(textArea);

// JTextArea textArea = new JTextArea();
// JScrollPane rScrollPane = new JScrollPane(textArea);

textArea.setLineWrap(true); // This line produces the abnormal behaviour

JPanel layoutPanel1 = new JPanel(new BorderLayout());
layoutPanel1.add(rScrollPane, BorderLayout.CENTER);

JPanel layoutPanel2 = new JPanel(new BorderLayout());
layoutPanel2.add(layoutPanel1, BorderLayout.CENTER);
JScrollPane jScrollPane = new JScrollPane(layoutPanel2);

JFrame frame = new JFrame();

// frame.setContentPane(layoutPanel2);

frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);

The RSyntaxTextArea behaves normal, when setLineWrap is set to false (see line 7) or when it is not inside a JScrollPane, see code in line 17 in the main method.
A Swing JTextArea behaves normal. You can check this, by commenting out the first two lines in the main methode and removing the slashes in lines 4 and 5.

Does anyone have recommendations how to avoid this?

Thanks in advance and best regards,


Re: Grabbing infinity space in BorderLayout?

Postby robert » Tue Aug 21, 2012 4:16 am

Thanks for reporting this, I'll take a look.
User avatar
Posts: 852
Joined: Sat May 10, 2008 5:16 pm

Re: Grabbing infinity space in BorderLayout?

Postby Christian9 » Tue Aug 21, 2012 10:58 am

Setting a preferredSize to rScrollPane solves the problem in my case
Code: Select all

Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest