• Post Reply Bookmark Topic Watch Topic
  • New Topic

A (hopefully) simple "Text box" question  RSS feed

 
Justyn Dooley
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Rob Spoor
Sheriff
Posts: 21050
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd go for a non-editable JTextArea, probably wrapped in a JScrollPane.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!