• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A (hopefully) simple "Text box" question

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So. I am writing a program for a Psychology study that will track mouse movement. I have not gotten too far into the project and I have already encountered a problem. In one part of the program, a consent message is to be displayed (read from a file) and then the user selects if he/she agrees. I have everything down, including reading in the file, aside from displaying the block of text (The consent message). At first, I tried a JLabel, but apparently you can not return (\n or \r) in a JLabel. Can anyone suggest a simple solution for me as to what I should do in order to get the entire block of text to display? By the way, with the way I am reading the file in, it is doing the returns, which can be checked by printing the read-in file to the console. I will post the program in it's entirety; please be nice, it is a ROUGH work in progress.

MusicMouseMain


MusicMousePanel


Any, and all help would be greatly appreciated.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

a couple of ways
1)
change ReadInConsent:


2)
instead of a JLabel, use a JTextArea (uneditable etc, to look like JLabel)
and its read() method, which will read the file and handle the \r\n for you
 
Justyn Dooley
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very, very much. Have any other general tips for the program?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> Have any other general tips for the program?

haven't actually looked at what it's supposed to do, so not really.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd go for a non-editable JTextArea, probably wrapped in a JScrollPane.
 
You got style baby! More than this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic