Results 1 to 3 of 3
  1. #1
    monkey04 is offline Member
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

    Question jscrollpane problem

    Hey, I'm having trouble getting scrolling to work properly with a jtextarea. Any help would be appreciated. What I have is basically:

    Java Code:
    JTextArea test = new JTextArea();
    for (int i = 0; i < 50; ++i) {
        test.append(i + "\tstrings!!! \n");
    }
    test.setPreferredSize(new Dimension(200, 200));
    JScrollPane testScroller = new JScrollPane(test);
    testScroller.setVerticalScrollBar(new JScrollBar());
    testScroller.setPreferredSize(test.getPreferredSize());
    mainPanel.add(testScroller);
    This doesn't work right, it only lets me scroll the first 13 or so lines, if at all. How can I set it to work right and handle all the lines of text that may appear??
    Thanks! :)

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
            JTextArea test = new JTextArea();
            for (int i = 0; i < 50; ++i) {
                test.append(i + "\tstrings!!! \n");
            }
    //        test.setPreferredSize(new Dimension(200, 200));
            JScrollPane testScroller = new JScrollPane(test);
            testScroller.setPreferredSize(new Dimension(200, 200));
    //        testScroller.setVerticalScrollBar(new JScrollBar());
    //        testScroller.setPreferredSize(test.getPreferredSize());
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setLayout(new GridBagLayout());
            f.add(testScroller, new GridBagConstraints());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);

  3. #3
    monkey04 is offline Member
    Join Date
    Jan 2008
    Posts
    3
    Rep Power
    0

Similar Threads

  1. JScrollPane with HTML
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 11:32 AM
  2. help with JScrollPane
    By tommy in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 07:58 PM
  3. how to draw an image inside of jscrollpane
    By paty in forum Java Applets
    Replies: 1
    Last Post: 07-24-2007, 12:44 AM
  4. JScrollPane not scrolling
    By Riftwalker in forum Advanced Java
    Replies: 2
    Last Post: 07-17-2007, 08:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •