DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    7

    problem with scroll

    Hi,
    I am writing an application to show a scroll panel attached to a text area
    but it does not appear on the screen. If remove the lines

    JScrollPane scrollText = new JScrollPane(textArea);
    contentPane.add(scrollText);

    and add

    contentPane.add(textField)

    It appears but without scroll?.


    import javax.swing.*;
    import java.awt.*;

    class TestFrame extends JFrame {
    private JTextArea textArea;

    public static void main(String[] args) {
    TestFrame frame = new TestFrame();
    frame.setVisible(true);
    }

    public TestFrame( ) {

    setSize ( 700, 400 );
    setLocation ( 5, 5 );

    Container contentPane = getContentPane();
    contentPane.setBackground(Color.white);
    contentPane.setLayout(null);

    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setBounds(350, 50, 100, 135);
    textArea.setBorder(BorderFactory.createLineBorder(Color.red));
    JScrollPane scrollText = new JScrollPane(textArea);
    contentPane.add(scrollText);

    }



    }

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    theScrollPane.getViewport().add(theTextArea, null);

    but u will have to put this scrollpane in a panel that u put in a JFrame that u display on the screen...
    eschew obfuscation

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