38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package xl.gui;
|
|
|
|
import java.awt.Color;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import javax.swing.SwingConstants;
|
|
import xl.model.XLModel;
|
|
import xl.controller.EditorController;
|
|
import xl.controller.SlotLabelController;
|
|
|
|
public class SlotLabels extends GridPanel {
|
|
|
|
private List<SlotLabel> labelList;
|
|
|
|
public SlotLabels(int rows, int cols, XLModel xlModel, SlotLabelController slotLabelController,
|
|
EditorController editorController) {
|
|
super(rows + 1, cols);
|
|
labelList = new ArrayList<SlotLabel>(rows * cols);
|
|
for (char ch = 'A'; ch < 'A' + cols; ch++) {
|
|
add(new ColoredLabel(Character.toString(ch), Color.LIGHT_GRAY, SwingConstants.CENTER));
|
|
}
|
|
|
|
for (int row = 1; row <= rows; row++) {
|
|
for (char ch = 'A'; ch < 'A' + cols; ch++) {
|
|
SlotLabel label = new SlotLabel(slotLabelController, row, ch);
|
|
xlModel.addObserver(label);
|
|
add(label);
|
|
labelList.add(label);
|
|
}
|
|
}
|
|
|
|
SlotLabel firstLabel = labelList.get(0);
|
|
firstLabel.setBackground(Color.YELLOW);
|
|
xlModel.setCurrentAddress("A1");
|
|
slotLabelController.setCurrentSlot(firstLabel);
|
|
editorController.setCurrentSlot(firstLabel);
|
|
}
|
|
}
|