JAL-1807 still testing
[jalviewjs.git] / unused / appletgui / UserDefinedColours.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)\r
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors\r
4  * \r
5  * This file is part of Jalview.\r
6  * \r
7  * Jalview is free software: you can redistribute it and/or\r
8  * modify it under the terms of the GNU General Public License \r
9  * as published by the Free Software Foundation, either version 3\r
10  * of the License, or (at your option) any later version.\r
11  *  \r
12  * Jalview is distributed in the hope that it will be useful, but \r
13  * WITHOUT ANY WARRANTY; without even the implied warranty \r
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
15  * PURPOSE.  See the GNU General Public License for more details.\r
16  * \r
17  * You should have received a copy of the GNU General Public License\r
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
19  * The Jalview Authors are detailed in the 'AUTHORS' file.\r
20  */\r
21 package jalview.appletgui;\r
22 \r
23 import jalview.bin.JalviewLite;\r
24 import jalview.datamodel.SequenceGroup;\r
25 import jalview.schemes.ColourSchemeI;\r
26 import jalview.schemes.GraduatedColor;\r
27 import jalview.schemes.ResidueProperties;\r
28 import jalview.schemes.UserColourScheme;\r
29 import jalview.util.MessageManager;\r
30 \r
31 import javax.swing.JButton;\r
32 import java.awt.Color;\r
33 import java.awt.Component;\r
34 import java.awt.Container;\r
35 import javax.swing.JDialog;\r
36 import java.awt.Font;\r
37 import javax.swing.JFrame;\r
38 import java.awt.GridLayout;\r
39 import javax.swing.JLabel;\r
40 import javax.swing.JPanel;\r
41 import java.awt.Rectangle;\r
42 import javax.swing.JScrollBar;\r
43 import javax.swing.JTextField;\r
44 import java.awt.event.ActionEvent;\r
45 import java.awt.event.ActionListener;\r
46 import java.awt.event.AdjustmentEvent;\r
47 import java.awt.event.AdjustmentListener;\r
48 import java.awt.event.FocusEvent;\r
49 import java.awt.event.FocusListener;\r
50 import java.awt.event.MouseEvent;\r
51 import java.util.Vector;\r
52 \r
53 public class UserDefinedColours extends JPanel implements ActionListener,\r
54         AdjustmentListener, FocusListener\r
55 {\r
56 \r
57   AlignmentPanel ap;\r
58 \r
59   SequenceGroup seqGroup;\r
60 \r
61   JButton selectedButton;\r
62 \r
63   Vector oldColours = new Vector();\r
64 \r
65   ColourSchemeI oldColourScheme;\r
66 \r
67   JFrame frame;\r
68 \r
69   MCview.AppletPDBCanvas pdbcanvas;\r
70 \r
71   AppletJmol jmol;\r
72 \r
73   JDialog dialog;\r
74 \r
75   Object caller;\r
76 \r
77   String originalLabel;\r
78 \r
79   Object originalColour;\r
80 \r
81   int R = 0, G = 0, B = 0;\r
82 \r
83   public ColourSchemeI loadDefaultColours()\r
84   {\r
85     // NOT IMPLEMENTED YET IN APPLET VERSION\r
86     return null;\r
87   }\r
88 \r
89   public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg)\r
90   {\r
91     this.ap = ap;\r
92     seqGroup = sg;\r
93 \r
94     if (seqGroup != null)\r
95     {\r
96       oldColourScheme = seqGroup.cs;\r
97     }\r
98     else\r
99     {\r
100       oldColourScheme = ap.av.getGlobalColourScheme();\r
101     }\r
102 \r
103     init();\r
104   }\r
105 \r
106   public UserDefinedColours(MCview.AppletPDBCanvas pdb)\r
107   {\r
108     this.pdbcanvas = pdb;\r
109     init();\r
110   }\r
111 \r
112   public UserDefinedColours(AppletJmol jmol)\r
113   {\r
114     this.jmol = jmol;\r
115     init();\r
116   }\r
117 \r
118   public UserDefinedColours(FeatureRenderer fr, JFrame alignframe)\r
119   {\r
120     caller = fr;\r
121     originalColour = fr.colourPanel.getBackground();\r
122     originalLabel = "Feature Colour";\r
123     setForDialog("Select Feature Colour", alignframe);\r
124     setTargetColour(fr.colourPanel.getBackground());\r
125     dialog.setVisible(true);\r
126   }\r
127 \r
128   public UserDefinedColours(Component caller, Color col1, JFrame alignframe)\r
129   {\r
130     this(caller, col1, alignframe, "Select Colour");\r
131   }\r
132 \r
133   /**\r
134    * Makes a dialog to choose the colour\r
135    * \r
136    * @param caller\r
137    *          - handles events\r
138    * @param col1\r
139    *          - original colour\r
140    * @param alignframe\r
141    *          - the parent Frame for the dialog\r
142    * @param title\r
143    *          - window title\r
144    */\r
145   public UserDefinedColours(Component caller, Color col1, JFrame alignframe,\r
146           String title)\r
147   {\r
148     this.caller = caller;\r
149     originalColour = col1;\r
150     originalLabel = title;\r
151     setForDialog(title, alignframe);\r
152     setTargetColour(col1);\r
153     dialog.setVisible(true);\r
154   }\r
155 \r
156   /**\r
157    * feature colour chooser\r
158    * \r
159    * @param caller\r
160    * @param label\r
161    * @param colour\r
162    */\r
163   public UserDefinedColours(Object caller, String label, Color colour)\r
164   {\r
165     this(caller, label, colour, colour);\r
166   }\r
167 \r
168   /**\r
169    * feature colour chooser when changing style to single color\r
170    * \r
171    * @param me\r
172    * @param type\r
173    * @param graduatedColor\r
174    */\r
175   public UserDefinedColours(FeatureSettings me, String type,\r
176           GraduatedColor graduatedColor)\r
177   {\r
178     this(me, type, graduatedColor, graduatedColor.getMaxColor());\r
179   }\r
180 \r
181   private UserDefinedColours(Object caller, String label, Object ocolour,\r
182           Color colour)\r
183   {\r
184     this.caller = caller;\r
185     originalColour = ocolour;\r
186     originalLabel = label;\r
187     init();\r
188     remove(buttonPanel);\r
189 \r
190     setTargetColour(colour);\r
191 \r
192     okcancelPanel.setBounds(new Rectangle(0, 113, 400, 35));\r
193     frame.setTitle(MessageManager.getString("label.user_defined_colours") + " - " + label);\r
194     frame.setSize(420, 200);\r
195   }\r
196 \r
197   void setForDialog(String title, Container alignframe)\r
198   {\r
199     init();\r
200     frame.setVisible(false);\r
201     remove(buttonPanel);\r
202     if (alignframe instanceof JFrame)\r
203     {\r
204       dialog = new JDialog((JFrame) alignframe, title, true);\r
205     }\r
206     else\r
207     {\r
208       // if (alignframe instanceof JVDialog){\r
209       // // not 1.1 compatible!\r
210       // dialog = new Dialog(((JVDialog)alignframe), title, true);\r
211       // } else {\r
212       throw new Error(MessageManager.getString("label.error_unsupported_owwner_user_colour_scheme"));\r
213     }\r
214 \r
215     dialog.add(this);\r
216     this.setSize(400, 123);\r
217     okcancelPanel.setBounds(new Rectangle(0, 123, 400, 35));\r
218     int height = 160 + alignframe.getInsets().top + getInsets().bottom;\r
219     int width = 400;\r
220 \r
221     dialog.setBounds(alignframe.getBounds().x\r
222             + (alignframe.getSize().width - width) / 2,\r
223             alignframe.getBounds().y\r
224                     + (alignframe.getSize().height - height) / 2, width,\r
225             height);\r
226 \r
227   }\r
228 \r
229   public void actionPerformed(ActionEvent evt)\r
230   {\r
231     final Object source = evt.getSource();\r
232     if (source == okButton)\r
233     {\r
234       okButton_actionPerformed();\r
235     }\r
236     else if (source == applyButton)\r
237     {\r
238       applyButton_actionPerformed();\r
239     }\r
240     else if (source == cancelButton)\r
241     {\r
242       cancelButton_actionPerformed();\r
243     }\r
244     else if (source == rText)\r
245     {\r
246       rText_actionPerformed();\r
247     }\r
248     else if (source == gText)\r
249     {\r
250       gText_actionPerformed();\r
251     }\r
252     else if (source == bText)\r
253     {\r
254       bText_actionPerformed();\r
255     }\r
256   }\r
257 \r
258   public void adjustmentValueChanged(AdjustmentEvent evt)\r
259   {\r
260     if (evt.getSource() == rScroller)\r
261     {\r
262       rScroller_adjustmentValueChanged();\r
263     }\r
264     else if (evt.getSource() == gScroller)\r
265     {\r
266       gScroller_adjustmentValueChanged();\r
267     }\r
268     else if (evt.getSource() == bScroller)\r
269     {\r
270       bScroller_adjustmentValueChanged();\r
271     }\r
272   }\r
273 \r
274   void init()\r
275   {\r
276     try\r
277     {\r
278       jbInit();\r
279     } catch (Exception e)\r
280     {\r
281       e.printStackTrace();\r
282     }\r
283     frame = new JFrame();\r
284     frame.add(this);\r
285     JalviewLite.addFrame(frame,\r
286             MessageManager.getString("label.user_defined_colours"), 420,\r
287             345);\r
288 \r
289     if (seqGroup != null)\r
290     {\r
291       frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")");\r
292     }\r
293 \r
294     for (int i = 0; i < 20; i++)\r
295     {\r
296       makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i])\r
297               + "", ResidueProperties.aa[i]);\r
298     }\r
299 \r
300     makeButton("B", "B");\r
301     makeButton("Z", "Z");\r
302     makeButton("X", "X");\r
303     makeButton("Gap", "'.','-',' '");\r
304 \r
305     validate();\r
306   }\r
307 \r
308   protected void rText_actionPerformed()\r
309   {\r
310     try\r
311     {\r
312       int i = Integer.parseInt(rText.getText());\r
313       rScroller.setValue(i);\r
314       rScroller_adjustmentValueChanged();\r
315     } catch (NumberFormatException ex)\r
316     {\r
317     }\r
318   }\r
319 \r
320   protected void gText_actionPerformed()\r
321   {\r
322     try\r
323     {\r
324       int i = Integer.parseInt(gText.getText());\r
325       gScroller.setValue(i);\r
326       gScroller_adjustmentValueChanged();\r
327     } catch (NumberFormatException ex)\r
328     {\r
329     }\r
330 \r
331   }\r
332 \r
333   protected void bText_actionPerformed()\r
334   {\r
335     try\r
336     {\r
337       int i = Integer.parseInt(bText.getText());\r
338       bScroller.setValue(i);\r
339       bScroller_adjustmentValueChanged();\r
340     } catch (NumberFormatException ex)\r
341     {\r
342     }\r
343 \r
344   }\r
345 \r
346   protected void rScroller_adjustmentValueChanged()\r
347   {\r
348     R = rScroller.getValue();\r
349     rText.setText(R + "");\r
350     colourChanged();\r
351   }\r
352 \r
353   protected void gScroller_adjustmentValueChanged()\r
354   {\r
355     G = gScroller.getValue();\r
356     gText.setText(G + "");\r
357     colourChanged();\r
358   }\r
359 \r
360   protected void bScroller_adjustmentValueChanged()\r
361   {\r
362     B = bScroller.getValue();\r
363     bText.setText(B + "");\r
364     colourChanged();\r
365   }\r
366 \r
367   public void colourChanged()\r
368   {\r
369     Color col = new Color(R, G, B);\r
370     target.setBackground(col);\r
371     target.repaint();\r
372 \r
373     if (selectedButton != null)\r
374     {\r
375       selectedButton.setBackground(col);\r
376       selectedButton.repaint();\r
377     }\r
378   }\r
379 \r
380   void setTargetColour(Color col)\r
381   {\r
382     R = col.getRed();\r
383     G = col.getGreen();\r
384     B = col.getBlue();\r
385 \r
386     rScroller.setValue(R);\r
387     gScroller.setValue(G);\r
388     bScroller.setValue(B);\r
389     rText.setText(R + "");\r
390     gText.setText(G + "");\r
391     bText.setText(B + "");\r
392     colourChanged();\r
393   }\r
394 \r
395   public void colourButtonPressed(MouseEvent e)\r
396   {\r
397     selectedButton = (JButton) e.getSource();\r
398     setTargetColour(selectedButton.getBackground());\r
399   }\r
400 \r
401   void makeButton(String label, String aa)\r
402   {\r
403     final JButton button = new JButton();\r
404     Color col = Color.white;\r
405     if (oldColourScheme != null)\r
406     {\r
407       try\r
408       {\r
409         col = oldColourScheme.findColour(aa.charAt(0), -1, null);\r
410       } catch (Exception ex)\r
411       {\r
412       }\r
413     }\r
414     button.setBackground(col);\r
415     oldColours.addElement(col);\r
416     button.setLabel(label);\r
417     button.setForeground(col.darker().darker().darker());\r
418     button.setFont(new java.awt.Font("Verdana", 1, 10));\r
419     button.addMouseListener(new java.awt.event.MouseAdapter()\r
420     {\r
421       public void mousePressed(MouseEvent e)\r
422       {\r
423         colourButtonPressed(e);\r
424       }\r
425     });\r
426 \r
427     buttonPanel.add(button, null);\r
428   }\r
429 \r
430   protected void okButton_actionPerformed()\r
431   {\r
432     applyButton_actionPerformed();\r
433     if (dialog != null)\r
434     {\r
435       dialog.setVisible(false);\r
436     }\r
437 \r
438     frame.setVisible(false);\r
439   }\r
440 \r
441   public Color getColor()\r
442   {\r
443     return new Color(R, G, B);\r
444   }\r
445 \r
446   protected void applyButton_actionPerformed()\r
447   {\r
448     if (caller != null)\r
449     {\r
450       if (caller instanceof FeatureSettings)\r
451       {\r
452         ((FeatureSettings) caller).setUserColour(originalLabel, getColor());\r
453       }\r
454       else if (caller instanceof AnnotationColourChooser)\r
455       {\r
456         if (originalLabel.equals("Min Colour"))\r
457         {\r
458           ((AnnotationColourChooser) caller)\r
459                   .minColour_actionPerformed(getColor());\r
460         }\r
461         else\r
462         {\r
463           ((AnnotationColourChooser) caller)\r
464                   .maxColour_actionPerformed(getColor());\r
465         }\r
466       }\r
467       else if (caller instanceof FeatureRenderer)\r
468       {\r
469         ((FeatureRenderer) caller).colourPanel.updateColor(getColor());\r
470       }\r
471       else if (caller instanceof FeatureColourChooser)\r
472       {\r
473         if (originalLabel.indexOf("inimum") > -1)\r
474         {\r
475           ((FeatureColourChooser) caller)\r
476                   .minColour_actionPerformed(getColor());\r
477         }\r
478         else\r
479         {\r
480           ((FeatureColourChooser) caller)\r
481                   .maxColour_actionPerformed(getColor());\r
482         }\r
483       }\r
484 \r
485       return;\r
486     }\r
487 \r
488     Color[] newColours = new Color[24];\r
489     for (int i = 0; i < 24; i++)\r
490     {\r
491       JButton button = (JButton) buttonPanel.getComponent(i);\r
492       newColours[i] = button.getBackground();\r
493     }\r
494 \r
495     UserColourScheme ucs = new UserColourScheme(newColours);\r
496     if (ap != null)\r
497     {\r
498       ucs.setThreshold(0, ap.av.isIgnoreGapsConsensus());\r
499     }\r
500 \r
501     if (ap != null)\r
502     {\r
503       if (seqGroup != null)\r
504       {\r
505         seqGroup.cs = ucs;\r
506       }\r
507       else\r
508       {\r
509         ap.av.setGlobalColourScheme(ucs);\r
510       }\r
511       ap.seqPanel.seqCanvas.img = null;\r
512       ap.paintAlignment(true);\r
513     }\r
514     else if (jmol != null)\r
515     {\r
516       jmol.setJalviewColourScheme(ucs);\r
517     }\r
518     else if (pdbcanvas != null)\r
519     {\r
520       pdbcanvas.setColours(ucs);\r
521     }\r
522   }\r
523 \r
524   protected void cancelButton_actionPerformed()\r
525   {\r
526     if (caller != null)\r
527     {\r
528       if (caller instanceof FeatureSettings)\r
529       {\r
530         ((FeatureSettings) caller).setUserColour(originalLabel,\r
531                 originalColour);\r
532       }\r
533       else if (caller instanceof AnnotationColourChooser)\r
534       {\r
535         if (originalLabel.equals("Min Colour"))\r
536         {\r
537           ((AnnotationColourChooser) caller)\r
538                   .minColour_actionPerformed((Color) originalColour);\r
539         }\r
540         else\r
541         {\r
542           ((AnnotationColourChooser) caller)\r
543                   .maxColour_actionPerformed((Color) originalColour);\r
544         }\r
545       }\r
546       else if (caller instanceof FeatureRenderer)\r
547       {\r
548         ((FeatureRenderer) caller).colourPanel.updateColor(originalColour);\r
549 \r
550       }\r
551 \r
552       else if (caller instanceof FeatureColourChooser)\r
553       {\r
554         if (originalLabel.indexOf("inimum") > -1)\r
555         {\r
556           ((FeatureColourChooser) caller)\r
557                   .minColour_actionPerformed((Color) originalColour);\r
558         }\r
559         else\r
560         {\r
561           ((FeatureColourChooser) caller)\r
562                   .maxColour_actionPerformed((Color) originalColour);\r
563         }\r
564       }\r
565       if (dialog != null)\r
566       {\r
567         dialog.setVisible(false);\r
568       }\r
569 \r
570       frame.setVisible(false);\r
571       return;\r
572     }\r
573 \r
574     Color[] newColours = new Color[24];\r
575     for (int i = 0; i < 24; i++)\r
576     {\r
577       newColours[i] = (Color) oldColours.elementAt(i);\r
578       buttonPanel.getComponent(i).setBackground(newColours[i]);\r
579     }\r
580 \r
581     UserColourScheme ucs = new UserColourScheme(newColours);\r
582 \r
583     if (ap != null)\r
584     {\r
585       if (seqGroup != null)\r
586       {\r
587         seqGroup.cs = ucs;\r
588       }\r
589       else\r
590       {\r
591         ap.av.setGlobalColourScheme(ucs);\r
592       }\r
593       ap.paintAlignment(true);\r
594     }\r
595     else if (jmol != null)\r
596     {\r
597       jmol.setJalviewColourScheme(ucs);\r
598     }\r
599     else if (pdbcanvas != null)\r
600     {\r
601       pdbcanvas.pdb.setColours(ucs);\r
602     }\r
603 \r
604     frame.setVisible(false);\r
605   }\r
606 \r
607   protected JPanel buttonPanel = new JPanel();\r
608 \r
609   protected GridLayout gridLayout = new GridLayout();\r
610 \r
611   JPanel okcancelPanel = new JPanel();\r
612 \r
613   protected JButton okButton = new JButton();\r
614 \r
615   protected JButton applyButton = new JButton();\r
616 \r
617   protected JButton cancelButton = new JButton();\r
618 \r
619   protected JScrollBar rScroller = new JScrollBar();\r
620 \r
621   JLabel label1 = new JLabel();\r
622 \r
623   protected JTextField rText = new JTextField();\r
624 \r
625   JLabel label4 = new JLabel();\r
626 \r
627   protected JScrollBar gScroller = new JScrollBar();\r
628 \r
629   protected JTextField gText = new JTextField();\r
630 \r
631   JLabel label5 = new JLabel();\r
632 \r
633   protected JScrollBar bScroller = new JScrollBar();\r
634 \r
635   protected JTextField bText = new JTextField();\r
636 \r
637   protected JPanel target = new JPanel();\r
638 \r
639   private void jbInit() throws Exception\r
640   {\r
641     this.setLayout(null);\r
642     buttonPanel.setLayout(gridLayout);\r
643     gridLayout.setColumns(6);\r
644     gridLayout.setRows(4);\r
645     okButton.setFont(new java.awt.Font("Verdana", 0, 11));\r
646     okButton.setLabel(MessageManager.getString("action.ok"));\r
647     okButton.addActionListener(this);\r
648     applyButton.setFont(new java.awt.Font("Verdana", 0, 11));\r
649     applyButton.setLabel(MessageManager.getString("action.apply"));\r
650     applyButton.addActionListener(this);\r
651     cancelButton.setFont(new java.awt.Font("Verdana", 0, 11));\r
652     cancelButton.setLabel(MessageManager.getString("action.cancel"));\r
653     cancelButton.addActionListener(this);\r
654     this.setBackground(new Color(212, 208, 223));\r
655     okcancelPanel.setBounds(new Rectangle(0, 265, 400, 35));\r
656     buttonPanel.setBounds(new Rectangle(0, 123, 400, 142));\r
657     rScroller.setMaximum(256);\r
658     rScroller.setMinimum(0);\r
659     rScroller.setOrientation(0);\r
660     rScroller.setUnitIncrement(1);\r
661     rScroller.setVisibleAmount(1);\r
662     rScroller.setBounds(new Rectangle(36, 27, 119, 19));\r
663     rScroller.addAdjustmentListener(this);\r
664     label1.setAlignmentX(JLabel.RIGHT);\r
665     label1.setText("R");\r
666     label1.setBounds(new Rectangle(19, 30, 16, 15));\r
667     rText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10));\r
668     rText.setText("0        ");\r
669     rText.setBounds(new Rectangle(156, 27, 53, 19));\r
670     rText.addActionListener(this);\r
671     rText.addFocusListener(this);\r
672     label4.setAlignmentX(JLabel.RIGHT);\r
673     label4.setText("G");\r
674     label4.setBounds(new Rectangle(15, 56, 20, 15));\r
675     gScroller.setMaximum(256);\r
676     gScroller.setMinimum(0);\r
677     gScroller.setOrientation(0);\r
678     gScroller.setUnitIncrement(1);\r
679     gScroller.setVisibleAmount(1);\r
680     gScroller.setBounds(new Rectangle(35, 52, 120, 20));\r
681     gScroller.addAdjustmentListener(this);\r
682     gText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10));\r
683     gText.setText("0        ");\r
684     gText.setBounds(new Rectangle(156, 52, 53, 20));\r
685     gText.addActionListener(this);\r
686     gText.addFocusListener(this);\r
687     label5.setAlignmentX(JLabel.RIGHT);\r
688     label5.setText("B");\r
689     label5.setBounds(new Rectangle(14, 82, 20, 15));\r
690     bScroller.setMaximum(256);\r
691     bScroller.setMinimum(0);\r
692     bScroller.setOrientation(0);\r
693     bScroller.setUnitIncrement(1);\r
694     bScroller.setVisibleAmount(1);\r
695     bScroller.setBounds(new Rectangle(35, 78, 120, 20));\r
696     bScroller.addAdjustmentListener(this);\r
697     bText.setFont(new java.awt.Font("Dialog", Font.PLAIN, 10));\r
698     bText.setText("0        ");\r
699     bText.setBounds(new Rectangle(157, 78, 52, 20));\r
700     bText.addActionListener(this);\r
701     bText.addFocusListener(this);\r
702     target.setBackground(Color.black);\r
703     target.setBounds(new Rectangle(229, 26, 134, 79));\r
704     this.add(okcancelPanel, null);\r
705     okcancelPanel.add(okButton, null);\r
706     okcancelPanel.add(applyButton, null);\r
707     okcancelPanel.add(cancelButton, null);\r
708     this.add(rText);\r
709     this.add(gText);\r
710     this.add(bText);\r
711     this.add(buttonPanel, null);\r
712     this.add(target, null);\r
713     this.add(gScroller);\r
714     this.add(rScroller);\r
715     this.add(bScroller);\r
716     this.add(label5);\r
717     this.add(label4);\r
718     this.add(label1);\r
719   }\r
720 \r
721   @Override\r
722   public void focusGained(FocusEvent e)\r
723   {\r
724     // noop\r
725   }\r
726 \r
727   /**\r
728    * This method applies any change to an RGB value if the user tabs out of the\r
729    * field instead of pressing Enter\r
730    */\r
731   @Override\r
732   public void focusLost(FocusEvent e)\r
733   {\r
734     Component c = e.getComponent();\r
735     if (c == rText)\r
736     {\r
737       rText_actionPerformed();\r
738     }\r
739     else\r
740     {\r
741       if (c == gText)\r
742       {\r
743         gText_actionPerformed();\r
744       }\r
745       else\r
746       {\r
747         if (c == bText)\r
748         {\r
749           bText_actionPerformed();\r
750         }\r
751       }\r
752     }\r
753   }\r
754 \r
755 }\r