Reputation: 4094
I'm stuck on something silly (it feels that way). I'm trying to create a Java TitledBorder with a specific Color for the border and the Title.
Border varBorder;
// this works (creates red border with black text)
varBorder = BorderFactory.createLineBorder(Color.RED);
varBorder = BorderFactory.createTitledBorder(lv_border, "Info");
// this crashes
varBorder.setTitleColor(Color.RED);
varBorder.setBorder(lv_border);
What is the correct way to set the color of a TitleBorder?
Upvotes: 1
Views: 994
Reputation: 66
In your code varBorder is of Border type. You may cast it to TitledBorder or change the type of variable. In Border class there is no such method like setTitleColor.
Upvotes: 5