Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-07-2010, 04:35 AM   #1
LQ Newbie
Registered: Feb 2010
Posts: 6

Rep: Reputation: 0
Java JTextPane

Hello, please can someone show me code to make my JTextArea scrollable ?
I used this code but it doesn't scroll just expand my JTextArea out of JFrame.
Part of code I used(one that doesn't work):
public class GraphicsDemo {
public GraphicsDemo {
/*Previous code*/
JFrame frame = new JFrame("New Frame");
JPanel panel = new JPanel();

output = new JTextArea(5,30);
JScrollPane scrollPane = new JScrollPane(output);

Similar code is in in Java 6 Official Tutorial
Old 02-07-2010, 05:18 AM   #2
Registered: Dec 2008
Distribution: Ubuntu
Posts: 61

Rep: Reputation: 22
import javax.swing.*;
import java.awt.BorderLayout;

public class GraphicsDemo {
  public GraphicsDemo (){
    /*Previous code*/
    JFrame frame = new JFrame("New Frame");
    JTextArea jTextArea = new JTextArea( 30, 50 );
    JScrollPane jScrollPane = new JScrollPane( jTextArea );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setSize( 300, 300);
    frame.add( jScrollPane, BorderLayout.CENTER );
    frame.setVisible( true );
  public static void main(String[] args){
      new GraphicsDemo(); 
1 members found this post helpful.
Old 02-07-2010, 07:05 AM   #3
LQ Newbie
Registered: Feb 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Ach, it's clear now, thanks.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 7.10 64bit - how to set java path to/redirect java to ? Thane Ubuntu 1 03-25-2008 06:52 PM
LXer: Java news met with cautious optimism in free Java community LXer Syndicated Linux News 0 11-14-2006 11:21 PM
Firefox refuses to load Java jnlp files - plugin and java ok Melsync Linux - Software 1 06-25-2006 05:09 PM
JTextPane Won't Resize ElementNine Programming 5 02-28-2004 02:19 PM

All times are GMT -5. The time now is 08:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration