Saturday, 15 August 2015

java - How to change border colour run-time? -



java - How to change border colour run-time? -

i'm trying alter jscrollpane's border colour:

jscrollpane scroll = new jscrollpane (textpane, jscrollpane.vertical_scrollbar_as_needed, jscrollpane.horizontal_scrollbar_never); color color = new color(150, 255, 243); scroll.setborder(new compoundborder(new emptyborder(3, 3, 4, 4), new lineborder(color, 7))); //some other code //if smth happens then: color = color.red;

but "scroll" same.. how can see border color changes?

changing color variable not alter border. you'd have set border again, not alter color variable.

think simpler example, jlabel contains text.

string text = "example"; jlabel label = new jlabel(text); text = "changed";

the jlabel still show "example" though variable has changed.

you still have set text of jlabel again:

string text = "example"; jlabel label = new jlabel(text); text = "changed"; label.settext(text);

similarly, have set border again.

java swing colors border jscrollpane

No comments:

Post a Comment