-
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);
}
}
-
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
Forum Rules
|
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
|
Bookmarks