DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Posts
    2

    Question Swing JScrollPane problems....

    the following is the code i am using to set up a JTextArea within a JScrollPane:

    private void setupOutputScrollPane() {
    final int rows = 10, columns = 10;
    outputTextArea = new JTextArea(rows, columns);
    outputTextArea.setWrapStyleWord(true);
    outputTextArea.setLineWrap(true);
    outputTextArea.setEditable(false);

    outputScrollPane = new JScrollPane(outputTextArea);
    outputScrollPane.setHorizontalScrollBarPolicy(outputScrollPane.HORIZONTAL_SCROLLBAR_NEVER) ;
    outputScrollPane.setVerticalScrollBarPolicy(outputScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED) ;
    }

    after this i use the JFrame's getContentPane() method to retrieve the content pane of the frame, then use the content panes add() method to add the above JScrollPane. However every time i add it, the pane is at the minimum possible size - ie just big enough to fit the up and down buttons on its scroll bar - not nearly big enough to fit the rows and columns of the JTextArea...

    i am using a grid bag layout and have tried using various sets of constraints in case it helps, but no difference. I have also tried setting the size, and preffered size of both the JTextArea and the JScrollPane, but still no difference....

    what am i doing wrong!?!? how can i control the size of the JScrollPane?
    ++ Jonskichov ++
    www.jonskichov.co.uk

  2. #2
    Join Date
    Mar 2003
    Posts
    86

    setPreferredSize

    Try setPreferredSize for the frame.

    Sharbov.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links