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

x
?
Solved

JTextArea fixed size in JTabbedPane

Posted on 2006-05-01
2
Medium Priority
?
2,158 Views
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?

Code
------

        addressText = new JTextArea("Enter address here");
        addressText.setBorder(BorderFactory.createTitledBorder("Address"));
        addressText.setLineWrap(true);
       
        scrollPane = new JScrollPane();
        scrollPane.getViewport().add(addressText);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
       
        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);
0
Comment
Question by:Mr_A_Smith
2 Comments
 
LVL 4

Accepted Solution

by:
jfredrickson earned 1000 total points
ID: 16581036
0
 
LVL 92

Expert Comment

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

try changing that to:

        scrollPane = new JScrollPane(addressText);

0

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