mocarra
asked on
any way to insert newline in checkbox label
hi there,
I have a series of checkboes in an array called boxes. I assign the checkbox a string depending on the number of the checkbox
boxes[i] = new Checkbox(getString(i), boxGroup, false);
the getString function is as follows
public String getString(int index) {
int uid = Integer.parseInt(details[i ndex][UID] ) - 1;
switch (uid) {
case PLAIN:
return "Check " + details[index][URL] + " is updated";
case PHRASE:
return "Check " + details[index][URL] + "for " + details[index][PHRASE1];
case PHRASEPHRASE:
return "Check " + details[index][URL] + " for " + details[index][PHRASE1] + " followed by " + details[index][PHRASE2] + "with " + details[index][DIST] + " characters between them.";
case PHRASEVALUE:
return "Check " + details[index][URL] + " for" + details[index][PHRASE1] + " followed by value " + details[index][OP] + " " + details[index][PHRASE2] + " with " + details[index][DIST] +
" characters between them.";
case VALUEPHRASE:
return "Check " + details[index][URL] + " for value" + details[index][OP] + " " + details[index][PHRASE1] + " followed by " + details[index][PHRASE2] + " with " + details[index][DIST] + " characters between them.";
default:
return "";
}
as you can see some of the strings are very long so I want the strings broken up into lines so it would look something like
O Check http://www.geocities.com
for password
followed by protected
with max chars between them 5
I've tried inserting the newline character \n into the strings where I want them but when the program is run its all on the one line with the square symbol in place of the \n.
any ideas?
thanks
I have a series of checkboes in an array called boxes. I assign the checkbox a string depending on the number of the checkbox
boxes[i] = new Checkbox(getString(i), boxGroup, false);
the getString function is as follows
public String getString(int index) {
int uid = Integer.parseInt(details[i
switch (uid) {
case PLAIN:
return "Check " + details[index][URL] + " is updated";
case PHRASE:
return "Check " + details[index][URL] + "for " + details[index][PHRASE1];
case PHRASEPHRASE:
return "Check " + details[index][URL] + " for " + details[index][PHRASE1] + " followed by " + details[index][PHRASE2] + "with " + details[index][DIST] + " characters between them.";
case PHRASEVALUE:
return "Check " + details[index][URL] + " for" + details[index][PHRASE1] + " followed by value " + details[index][OP] + " " + details[index][PHRASE2] + " with " + details[index][DIST] +
" characters between them.";
case VALUEPHRASE:
return "Check " + details[index][URL] + " for value" + details[index][OP] + " " + details[index][PHRASE1] + " followed by " + details[index][PHRASE2] + " with " + details[index][DIST] + " characters between them.";
default:
return "";
}
as you can see some of the strings are very long so I want the strings broken up into lines so it would look something like
O Check http://www.geocities.com
for password
followed by protected
with max chars between them 5
I've tried inserting the newline character \n into the strings where I want them but when the program is run its all on the one line with the square symbol in place of the \n.
any ideas?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> It is not really necessary, nor are the closing tags.
doesn't hurt though :)
doesn't hurt though :)
ASKER
It doesnt seem to work now I just get
O <html>Check http://....etc
do I need to set anything in the checkbox properties?
O <html>Check http://....etc
do I need to set anything in the checkbox properties?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> you're using AWT checkboxes, no Swing JCheckBox's.
Oops didn't notices that.
You cannot use line breaks using AWT
Oops didn't notices that.
You cannot use line breaks using AWT
with AWT, you'll have to build something yourself.
you can use an empty checkbox and several labels on a panel and add a mouse listener to the labels that toggles the state of the checkbox.
you can use an empty checkbox and several labels on a panel and add a mouse listener to the labels that toggles the state of the checkbox.
Thank you
:)
:)
ASKER
thanks it worked perfectly...sorry about the delay computer crashed and had to reformat it...the joys of it!
>> computer crashed and had to reformat it
I can imagine more pleasant tasks ;)
I can imagine more pleasant tasks ;)
return "<html>Check " + details[index][URL] + " for " + details[index][PHRASE1] + "<br> followed by " + details[index][PHRASE2] + "with " + details[index][DIST] + " characters between them.";
The <html> is just a quick hint to look for HTML in the label, it is not necessarly properly formed.
- Tim