Merge /pub/main
[educational.data.git] / Dr.NO / src / drno / swingui / guiController / ColorChooserController.java
blobafdfdbd5df00860dbe87d7b491adf167987a32fb
1 package drno.swingui.guiController;
4 import java.awt.Color;
5 import java.awt.Component;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
9 import javax.swing.JComponent;
11 import drno.swingui.guiView.ColorChooser;
12 import drno.swingui.guiView.MainCalendarView;
14 public class ColorChooserController {
16 private MainCalendarView view;
17 private ColorChooser CCView;
20 public ColorChooserController(final MainCalendarView view){
22 CCView = new ColorChooser();
23 this.view = view;
25 CCView.setAnnullerListener(new ActionListener(){
26 public void actionPerformed(ActionEvent e) {
27 java.awt.EventQueue.invokeLater(new Runnable() {
28 public void run() {
29 // System.out.println("Color Annuller");
30 CCView.setVisible(false);
32 });
35 });
36 CCView.setOKListener(new ActionListener(){
37 public void actionPerformed(ActionEvent e) {
38 java.awt.EventQueue.invokeLater(new Runnable() {
39 public void run() {
40 // System.out.println("Set color");
41 CCView.setVisible(false);
43 });
46 });
47 CCView.setAnvendListener(new ActionListener(){
48 public void actionPerformed(ActionEvent e) {
49 java.awt.EventQueue.invokeLater(new Runnable() {
50 public void run() {
51 anvend();
52 view.getContentPane().repaint();
54 });
57 });
61 public void showCCView(){
62 // System.out.println("Indstille udseende...");
63 CCView.setVisible(true);
66 public void anvend(){
67 Color selectedColor = CCView.getChoosedColor();
68 Component[] c = view.getAllComponents();
70 for(int i=0; i<c.length;i++){
71 System.out.println(c[i].getName());
72 }*/
73 String backgroundElement = CCView.getList1Element();
74 String foregroundElement = CCView.getList2Element();
75 //System.out.println(backgroundElement+" "+foregroundElement);
76 if(!foregroundElement.equals("")){
77 if(foregroundElement.equals("Menu")){
78 view.setMenuForegroundColor(selectedColor);
80 if(foregroundElement.equals("Tabel")){
81 view.setTabelForegroundColor(selectedColor);
83 if(foregroundElement.equals("Ansat")){
84 view.setList1ForegroundColor(selectedColor);
86 if(foregroundElement.equals("Tidsreservation")){
87 view.setList2ForegroundColor(selectedColor);
89 else{
90 for(int i=0; i<c.length;i++){
91 JComponent jcomp = (JComponent)c[i];
92 if(jcomp.getName().equals(foregroundElement)){
93 view.setForegroundColor(jcomp,selectedColor);
100 if(c[i].getName().contains("ScrollPane")){
101 System.out.println(c[i].getComponentAt(0,0).getName());
105 if(!backgroundElement.equals("")){
106 if(backgroundElement.equals("Menu")){
107 view.setMenuBackgroundColor(selectedColor);
109 if(backgroundElement.equals("Tabel")){
110 view.setTabelBackgroundColor(selectedColor);
112 if(backgroundElement.equals("Ansat")){
113 view.setList1BackgroundColor(selectedColor);
115 if(backgroundElement.equals("Tidsreservation")){
116 view.setList2BackgroundColor(selectedColor);
118 else{
119 for(int i=0; i<c.length;i++){
120 JComponent jcomp = (JComponent)c[i];
121 if(jcomp.getName().equals(backgroundElement)){
122 view.setBackgroundColor(jcomp,selectedColor);