Bonjour,
Je possède une liste de couleur. Le fichier est de la forme suivante :
1 2 3 4 5 6 7 8 9 10 11 12 13
|
public class ConstantColor {
public static final int AliceBlue =0xFFF0F8FF;
public static final int AntiqueWhite =0xFFFAEBD7;
public static final int Aqua =0xFF00FFFF ;
public static final int Aquamarine =0xFF7FFFD4;
public static final int Azure =0xFFF0FFFF;
public static final int Beige =0xFFF5F5DC;
public static final int Bisque =0xFFFFE4C4;
public static final int Gainsboro =0xFFDCDCDC;
...
} |
Dans une table je souhaite changer la couleur de fond des lignes (suivant le type de données fournis par la ligne). J'arrive a créer un nouvel item et y mettre mes données mais je n'arrive pas a utiliser la méthode setBackground. L'interface graphique est faite avec RCP. Pour le paramètre de la méthode setBackground je dois avoir un objet de la classe
org.eclipse.swt.graphics.Color
mais je n'arrive pas a transformer mes entiesr dans ce type de couleurs.
Voici la méthode ou le problème est présent :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
public static void update(ArrayList<DecodedPacket> packets){
try {
int size = packets.size();
for(int i = 0; i < size; i++){
TableItem item = new TableItem(tablePacket, SWT.RIGHT);
item.setBackground(packets.get(i).getCOLOR()); // ERROR need to use an swt.graphic.Color object
item.setText(new String[] {
String.valueOf(numberPacket),
packets.get(i).getTime(),
"",
"",
packets.get(i).getProtocol(),
packets.get(i).getInfo()});
numberPacket++;
}
} catch (Exception e) {
System.out.println("problem with updating..");
e.printStackTrace();
}
} |
Merci de votre aide.
Partager