Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

No scroll in a frame???  RSS feed

 
Tyler Selby
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working in a project for class and i am trying to get a JTextArea to scroll but all the example I can find are not in frames and I was wondering if it is possible and if so what am I doing wrong? So i attached my code for you to look at. I appriciate any and all help you can give.


frame.getContentPane().add(new JLabel("What did you like about this course?"));
qw1 = new JTextArea();
qw1.setFont(new Font("Serif", Font.ITALIC, 16));
qw1.setLineWrap(true);
qw1.setWrapStyleWord(true);
JScrollPane areaScrollPane = new JScrollPane(qw1);
areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
areaScrollPane.setPreferredSize(new Dimension(250, 250));
areaScrollPane.setBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Plain Text"),
BorderFactory.createEmptyBorder(5,5,5,5)),
areaScrollPane.getBorder()));
frame.getContentPane().add(qw1);


thanks
tyler
 
Tyler Selby
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i figured it out thanks for the help
 
Campbell Ritchie
Sheriff
Posts: 55293
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you sort it out?
 
Tyler Selby
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
qw1 = new JTextArea(3, 15);
qw1.setFont(new Font("Serif", Font.ITALIC, 16));
qw1.setLineWrap(true);
qw1.setWrapStyleWord(true);
JScrollPane areaScrollPane = new JScrollPane(qw1);
areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
areaScrollPane.setPreferredSize(new Dimension(250, 50));
frame.getContentPane().add(areaScrollPane);
 
Campbell Ritchie
Sheriff
Posts: 55293
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you and well done
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!