(String) font color
hi all.
i have a method that returns a 'String' value
how can i change the color of the value before it returns.
eg.
public String getMesage() {
if not valid return red colored string
else
return blue colored string
}
i'd like to use this on a swing component jtextfield.
but i dont want to use jtextfields.setForeground(Color);
Hi,
the Color of a Label shown in view should be a property of the view. Anything defined inside a model class - a class holding data and working with it, should be unrelated to the view itself. If you need some property defining a state of the model needs to be defined view independent. Only if the Color itself is a businessproperty (the color of a car for example) color can be part of your model.
public class Fax{
public static int PRIORITY_SLOW=0;
public static int PRIORITY_NORMAL=1;
public static int PRIORITY_FAST=2;
private String message;
private String sender;
private String receiver;
// priority is a state of a Fax and can be used to
// change the color in some view - no color is needed here!
private int priority;
}
but
public class Car{
// here a Color can be allowed - but maybe a RGB Value in int or a
// String is a better datatype to hold the value
private Color carColor;
}
So your problem is a OO Design problem - review your classes,
lars.