problem with scroll


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: problem with scroll

  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

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