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

Hi,

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.setContentPane(jScrollPane);

frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
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,

Christian
Christian9
 

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
robert
 
Posts: 760
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
rScrollPane.setPreferredSize(newDimension(20,600));
Christian9
 


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests