JTextArea fixed size in JTabbedPane

Posted on 2006-05-01
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
    LVL 4

    Accepted Solution

    LVL 92

    Expert Comment

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

    try changing that to:

            scrollPane = new JScrollPane(addressText);


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    canBalance challenge 34 55
    hasOne  challenge 59 64
    JVM encoding. How to change encoding. 27 52
    Increment alphanumeric sequence 6 55
    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    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 …
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now