- import javax.swing.*;
- import java.awt.*;
- {
- //Keeps track of the background (highlight) color.
- private int col = 0;
- //The numeric value of the cell
- private int val = 0;
- //Colors for highlight
- public static final int WHITE = 0;
- public static final int YELLOW = 1;
- public static final int PINK = 2;
- public static final int BLUE = 3;
- public static final int GREEN = 4;
- public static final int GRAY = 5;
- public static final int ORANGE = 6;
- public static final int MAGENTA = 7;
- public static final int RED = 8;
- public static final int DARKGRAY = 9;
- public Value(int value, int color)
- {
- val = value;
- col = color;
- paintMe();
- }
- public Value(int value)
- {
- val = value;
- col = 0;
- this.setAlignmentX(CENTER_ALIGNMENT);
- this.setAlignmentY(CENTER_ALIGNMENT);
- this.add(lab);
- paintMe();
- }
- public int getValue()
- {
- return val;
- }
- public int getColor()
- {
- return col;
- }
- public void setValue(int newVal)
- {
- val = newVal;
- paintMe();
- }
- public void setColor(int newCol)
- {
- col = newCol;
- paintMe();
- }
- public void setAll(int newVal, int newCol)
- {
- val = newVal;
- col = newCol;
- paintMe();
- }
- public void paintMe()
- {
- this.setBackground(myColor());
- this.repaint();
- }
- {
- if(col==WHITE)
- else if(col==YELLOW)
- else if(col==PINK)
- else if(col==BLUE)
- else if(col==GREEN)
- else if(col==GRAY)
- else if(col==ORANGE)
- else if(col==MAGENTA)
- else if(col==RED)
- else if(col==DARKGRAY)
- else
- }
- }
Raw Paste