Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


JTextArea fixed size in JTabbedPane

Posted on 2006-05-01
Medium Priority
Last Modified: 2008-01-09
Dear java experts,

I have a JTextArea that I put into a JScrollPane, the JScrollPane then goes into a JPanel and finally the JPanel goes into a JTabbedPane.

The problem is that when I hold the enter key down in the JTextArea the curser moves down to the next line and when it reaches the end of the JTextArea (last visible line) and I press enter again, the JTextArea resizes (height increases) so eventually it does not fit into the JFrame.

What could be causing this? Isnt the JTextArea suppose to be fixed size?


        addressText = new JTextArea("Enter address here");
        scrollPane = new JScrollPane();
        addressPanel = new JPanel();
        addressPanel.setLayout(new BorderLayout());
        addressPanel.add(scrollPane, BorderLayout.CENTER);

        tabbedPane = new JTabbedPane();
        tabbedPane.addTab("Details", detailsPanel); //This is another panel that im adding as the first tab
        tabbedPane.addTab("Address Details", addressPanel);
Question by:Mr_A_Smith

Accepted Solution

jfredrickson earned 1000 total points
ID: 16581036
LVL 92

Expert Comment

ID: 16581221
>        scrollPane = new JScrollPane();
>        scrollPane.getViewport().add(addressText);

try changing that to:

        scrollPane = new JScrollPane(addressText);


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question