Swing JScrollPane problems....


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Swing JScrollPane problems....

  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.

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center