source: trunk/gcc/libjava/javax/swing/JComponent.java

Last change on this file was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 26.1 KB
Line 
1/* JComponent.java -- Every component in swing inherits from this class.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package javax.swing;
39
40import java.awt.*;
41import java.awt.peer.*;
42import java.awt.event.*;
43import java.io.*;
44
45import javax.swing.event.*;
46import javax.swing.border.*;
47import javax.swing.plaf.*;
48
49import java.util.*;
50import java.beans.*;
51
52import javax.accessibility.*;
53
54/**
55 * Every component in swing inherits from this class (JLabel, JButton, etc).
56 * It contains generic methods to manage events, properties and sizes.
57 * Actual drawing of the component is channeled to a look-and-feel class
58 * that is implemented elsewhere.
59 *
60 * @author Ronald Veldema (rveldema@cs.vu.nl)
61 */
62public abstract class JComponent extends Container implements Serializable
63{
64 /**
65 * accessibleContext
66 */
67 protected AccessibleContext accessibleContext;
68
69 Dimension pref,min,max;
70 Border border;
71 JToolTip tooltip;
72 String tool_tip_text;
73 boolean use_double_buffer, opaque;
74 protected ComponentUI ui;
75
76 Vector ancestor_list;
77 Vector veto_list;
78 Vector change_list;
79 Hashtable prop_hash;
80
81 /**
82 * AccessibleJComponent
83 */
84 public abstract class AccessibleJComponent
85 extends AccessibleAWTContainer {
86
87 //-------------------------------------------------------------
88 // Classes ----------------------------------------------------
89 //-------------------------------------------------------------
90
91 /**
92 * AccessibleFocusHandler
93 */
94 protected class AccessibleFocusHandler implements FocusListener {
95
96 //-------------------------------------------------------------
97 // Variables --------------------------------------------------
98 //-------------------------------------------------------------
99
100
101 //-------------------------------------------------------------
102 // Initialization ---------------------------------------------
103 //-------------------------------------------------------------
104
105 /**
106 * Constructor AccessibleFocusHandler
107 * @param component TODO
108 */
109 protected AccessibleFocusHandler(AccessibleJComponent component) {
110 // TODO
111 } // AccessibleFocusHandler()
112
113
114 //-------------------------------------------------------------
115 // Methods ----------------------------------------------------
116 //-------------------------------------------------------------
117
118 /**
119 * focusGained
120 * @param event TODO
121 */
122 public void focusGained(FocusEvent event) {
123 // TODO
124 } // focusGained()
125
126 /**
127 * focusLost
128 * @param event TODO
129 */
130 public void focusLost(FocusEvent valevent) {
131 // TODO
132 } // focusLost()
133
134
135 } // AccessibleFocusHandler
136
137 /**
138 * AccessibleContainerHandler
139 */
140 protected class AccessibleContainerHandler implements ContainerListener {
141
142 //-------------------------------------------------------------
143 // Variables --------------------------------------------------
144 //-------------------------------------------------------------
145
146
147 //-------------------------------------------------------------
148 // Initialization ---------------------------------------------
149 //-------------------------------------------------------------
150
151 /**
152 * Constructor AccessibleContainerHandler
153 * @param component TODO
154 */
155 protected AccessibleContainerHandler(AccessibleJComponent component) {
156 // TODO
157 } // AccessibleContainerHandler()
158
159
160 //-------------------------------------------------------------
161 // Methods ----------------------------------------------------
162 //-------------------------------------------------------------
163
164 /**
165 * componentAdded
166 * @param event TODO
167 */
168 public void componentAdded(ContainerEvent event) {
169 // TODO
170 } // componentAdded()
171
172 /**
173 * componentRemoved
174 * @param event TODO
175 */
176 public void componentRemoved(ContainerEvent valevent) {
177 // TODO
178 } // componentRemoved()
179
180
181 } // AccessibleContainerHandler
182
183
184 //-------------------------------------------------------------
185 // Variables --------------------------------------------------
186 //-------------------------------------------------------------
187
188 /**
189 * accessibleContainerHandler
190 */
191 protected ContainerListener accessibleContainerHandler;
192
193 /**
194 * accessibleFocusHandler
195 */
196 protected FocusListener accessibleFocusHandler;
197
198
199 //-------------------------------------------------------------
200 // Initialization ---------------------------------------------
201 //-------------------------------------------------------------
202
203 /**
204 * Constructor AccessibleJComponent
205 * @param component TODO
206 */
207 protected AccessibleJComponent(JComponent component) {
208// super((Container)component);
209 // TODO
210 } // AccessibleJComponent()
211
212
213 //-------------------------------------------------------------
214 // Methods ----------------------------------------------------
215 //-------------------------------------------------------------
216
217 /**
218 * addPropertyChangeListener
219 * @param listener TODO
220 */
221 public void addPropertyChangeListener(PropertyChangeListener listener) {
222 // TODO
223 } // addPropertyChangeListener()
224
225 /**
226 * removePropertyChangeListener
227 * @param listener TODO
228 */
229 public void removePropertyChangeListener(PropertyChangeListener listener) {
230 // TODO
231 } // removePropertyChangeListener()
232
233 /**
234 * getAccessibleChildrenCount
235 * @returns int
236 */
237 public int getAccessibleChildrenCount() {
238 return 0; // TODO
239 } // getAccessibleChildrenCount()
240
241 /**
242 * getAccessibleChild
243 * @param value0 TODO
244 * @returns Accessible
245 */
246 public Accessible getAccessibleChild(int value0) {
247 return null; // TODO
248 } // getAccessibleChild()
249
250 /**
251 * getAccessibleStateSet
252 * @returns AccessibleStateSet
253 */
254 public AccessibleStateSet getAccessibleStateSet() {
255 return null; // TODO
256 } // getAccessibleStateSet()
257
258 /**
259 * getAccessibleName
260 * @returns String
261 */
262 public String getAccessibleName() {
263 return null; // TODO
264 } // getAccessibleName()
265
266 /**
267 * getAccessibleDescription
268 * @returns String
269 */
270 public String getAccessibleDescription() {
271 return null; // TODO
272 } // getAccessibleDescription()
273
274 /**
275 * getAccessibleRole
276 * @returns AccessibleRole
277 */
278 public AccessibleRole getAccessibleRole() {
279 return null; // TODO
280 } // getAccessibleRole()
281
282 /**
283 * getBorderTitle
284 * @param value0 TODO
285 * @returns String
286 */
287 protected String getBorderTitle(Border value0) {
288 return null; // TODO
289 } // getBorderTitle()
290
291
292 } // AccessibleJComponent
293
294
295 public JComponent()
296 {
297 super();
298 super.setLayout(new FlowLayout());
299
300 //eventMask |= AWTEvent.COMP_KEY_EVENT_MASK;
301 enableEvents( AWTEvent.KEY_EVENT_MASK );
302
303 //updateUI(); // get a proper ui
304 }
305
306
307 // protected EventListenerList listenerList
308 public boolean contains(int x, int y)
309 {
310 //return dims.contains(x,y);
311 return super.contains(x,y);
312 }
313
314
315 public void addNotify()
316 {
317 //Notification to this component that it now has a parent component.
318 super.addNotify();
319 }
320
321
322 Hashtable get_prop_hash()
323 {
324 if (prop_hash == null)
325 prop_hash = new Hashtable();
326 return prop_hash;
327 }
328 public Vector get_veto_list()
329 {
330 if (veto_list == null)
331 veto_list = new Vector();
332 return veto_list;
333 }
334 public Vector get_change_list()
335 {
336 if (change_list == null)
337 change_list = new Vector();
338 return change_list;
339 }
340 public Vector get_ancestor_list()
341 {
342 if (ancestor_list == null)
343 ancestor_list = new Vector();
344 return ancestor_list;
345 }
346
347 public Object getClientProperty(Object key)
348 { return get_prop_hash().get(key); }
349
350 public void putClientProperty(Object key, Object value)
351 { get_prop_hash().put(key, value); }
352
353
354 public void removeAncestorListener(AncestorListener listener)
355 { get_ancestor_list().removeElement(listener); }
356
357 public void removePropertyChangeListener(PropertyChangeListener listener)
358 { get_change_list().removeElement(listener); }
359
360 public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
361 { /* FIXME */ get_change_list().removeElement(listener); }
362
363 public void removeVetoableChangeListener(VetoableChangeListener listener)
364 { get_veto_list().removeElement(listener); }
365
366 public void addAncestorListener(AncestorListener listener)
367 { get_ancestor_list().addElement(listener); }
368
369 public void addPropertyChangeListener(PropertyChangeListener listener)
370 { get_change_list().addElement(listener); }
371
372 public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
373 { /* FIXME */ get_change_list().addElement(listener); }
374
375 public void addVetoableChangeListener(VetoableChangeListener listener)
376 { get_veto_list().addElement(listener); }
377
378 public void computeVisibleRect(Rectangle rect)
379 {
380 //Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors.
381 //super.computeVisibleRect(rect);
382 }
383
384
385 public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
386 {
387 //Reports a bound property change.
388 }
389 public void firePropertyChange(String propertyName, byte oldValue, byte newValue)
390 {
391 // Reports a bound property change.
392 }
393 public void firePropertyChange(String propertyName, char oldValue, char newValue)
394 {
395 //Reports a bound property change.
396 }
397
398 public void firePropertyChange(String propertyName, double oldValue, double newValue)
399 {
400 //Reports a bound property change.
401 }
402
403 public void firePropertyChange(String propertyName, float oldValue, float newValue)
404 {
405 // Reports a bound property change.
406 }
407 public void firePropertyChange(String propertyName, int oldValue, int newValue)
408 {
409 // Reports a bound property change.
410 }
411 public void firePropertyChange(String propertyName, long oldValue, long newValue)
412 {
413 //Reports a bound property change. protected
414 }
415
416 protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
417 {
418 // Support for reporting bound property changes.
419 }
420 public void firePropertyChange(String propertyName, short oldValue, short newValue)
421 {
422 // Reports a bound property change.
423 }
424
425
426 protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
427 {
428 // Support for reporting constrained property changes.
429 }
430
431 public AccessibleContext getAccessibleContext()
432 {
433 // Get the AccessibleContext associated with this JComponent
434 return null;
435 }
436
437 public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke)
438 {
439 //Return the object that will perform the action registered for a given keystroke.
440 return null;
441 }
442 public float getAlignmentX()
443 {
444 // Overrides Container.getAlignmentX to return the vertical alignment.
445 return 0;
446 }
447
448 public float getAlignmentY()
449 {
450 // Overrides Container.getAlignmentY to return the horizontal alignment.
451 return 0;
452 }
453 public boolean getAutoscrolls()
454 {
455 //Returns true if this component automatically scrolls its contents when dragged, (when contained in a component that supports scrolling, like JViewport
456 return false;
457 }
458
459 public void setBorder(Border border)
460 {
461 //System.out.println("set border called !, new border = " + border);
462 this.border = border;
463 revalidate();
464 repaint();
465 }
466
467 public Border getBorder()
468 { return border; }
469
470
471 public Rectangle getBounds(Rectangle rv)
472 {
473 if (rv == null)
474 return new Rectangle(getX(),getY(),getWidth(),getHeight());
475 else
476 {
477 rv.setBounds(getX(),getY(),getWidth(),getHeight());
478 return rv;
479 }
480 }
481
482 protected Graphics getComponentGraphics(Graphics g)
483 { return g; }
484
485 public int getConditionForKeyStroke(KeyStroke aKeyStroke)
486 {
487 //Return the condition that determines whether a registered action occurs in response to the specified keystroke.
488 return 0;
489 }
490 public int getDebugGraphicsOptions()
491 {
492 return 0;
493 }
494
495 public Graphics getGraphics()
496 { return super.getGraphics(); }
497
498
499 // static MantaNative void DebugMe(Border b);
500
501 public Insets getInsets()
502 {
503 // System.out.println("watch this border");
504 // DebugMe(border);
505 // System.out.println("border = " + border);
506
507 if (border == null)
508 {
509 //System.out.println("compares to null !");
510 return super.getInsets();
511 }
512 // System.out.println("compare failed !");
513 return getBorder().getBorderInsets(this);
514 }
515
516 public Insets getInsets(Insets insets)
517 {
518 Insets t = getInsets();
519
520 if (insets == null)
521 return t;
522
523
524 return new Insets(t.top, t.left, t.bottom, t.right);
525 }
526 public Point getLocation(Point rv)
527 {
528 //Store the x,y origin of this component into "return value" rv and return rv.
529
530 if (rv == null)
531 return new Point(getX(),
532 getY());
533
534 rv.setLocation(getX(),
535 getY());
536 return rv;
537 }
538
539 public Dimension getMaximumSize()
540 {
541 if (max != null)
542 {
543 //System.out.println("HAVE_MAX_SIZE = " + max);
544 return max;
545 }
546 if (ui != null)
547 {
548 Dimension s = ui.getMaximumSize(this);
549 if (s != null)
550 {
551 //System.out.println(" UI-MAX = " + s + ", UI = " + ui + ", IM="+this);
552 return s;
553 }
554 }
555 Dimension p = super.getMaximumSize();
556 //System.out.println(" MAX = " + p + ", COMP="+this);
557 return p;
558 }
559
560 public Dimension getMinimumSize()
561 {
562 if (min != null)
563 {
564 //System.out.println("HAVE_MIN_SIZE = " + min);
565 return min;
566 }
567 if (ui != null)
568 {
569 Dimension s = ui.getMinimumSize(this);
570 if (s != null)
571 {
572 // System.out.println(" UI-MIN = " + s + ", UI = " + ui + ", IM="+this);
573 return s;
574 }
575 }
576 Dimension p = super.getMinimumSize();
577 // System.out.println(" MIN = " + p + ", COMP="+this);
578 return p;
579 }
580
581 public Dimension getPreferredSize()
582 {
583 if (pref != null)
584 {
585 //System.out.println("HAVE_PREF_SIZE = " + pref);
586 return pref;
587 }
588
589 if (ui != null)
590 {
591 Dimension s = ui.getPreferredSize(this);
592 if (s != null)
593 {
594 //System.out.println(" UI-PREF = " + s + ", UI = " + ui + ", IM="+this);
595 return s;
596 }
597 }
598 Dimension p = super.getPreferredSize();
599 // System.out.println(" PREF = " + p + ", COMP="+this);
600 return p;
601 }
602
603 public Component getNextFocusableComponent()
604 {
605 // Return the next focusable component or null if the focus manager should choose the next focusable component automatically
606 return null;
607 }
608
609
610 public KeyStroke[] getRegisteredKeyStrokes()
611 {
612 // Return the KeyStrokes that will initiate registered actions.
613 return null;
614 }
615
616 public JRootPane getRootPane()
617 {
618 JRootPane p = SwingUtilities.getRootPane(this);
619 System.out.println("root = " + p);
620 return p;
621 }
622
623 public Dimension getSize(Dimension rv)
624 {
625 // System.out.println("JComponent, getsize()");
626 if (rv == null)
627 return new Dimension(getWidth(),
628 getHeight());
629 else
630 {
631 rv.setSize(getWidth(),
632 getHeight());
633 return rv;
634 }
635 }
636
637
638
639 /*********************************************************************
640 *
641 *
642 * tooltips:
643 *
644 *
645 **************************************/
646
647 public JToolTip createToolTip()
648 {
649 if (tooltip == null)
650 tooltip = new JToolTip(tool_tip_text);
651 return tooltip;
652 }
653
654 public Point getToolTipLocation(MouseEvent event)
655 { return null; }
656
657 public void setToolTipText(String text)
658 { tool_tip_text = text; }
659
660 public String getToolTipText()
661 { return tool_tip_text; }
662
663 public String getToolTipText(MouseEvent event)
664 { return tool_tip_text; }
665
666 /*********************************************************************
667 *
668 *
669 * things to do with visibility:
670 *
671 *
672 **************************************/
673
674
675 public Container getTopLevelAncestor()
676 {
677 // Returns the top-level ancestor of this component (either the containing Window or Applet), or null if this component has not been added to any container.
678 System.out.println("JComponent, getTopLevelAncestor()");
679 return null;
680 }
681
682 public Rectangle getVisibleRect()
683 {
684 /// Returns the Component's "visible rectangle" - the intersection of this components visible rectangle:
685 System.out.println("JComponent, getVisibleRect()");
686 return null;
687 }
688
689 public void grabFocus()
690 {
691 // Set the focus on the receiving component.
692 }
693
694 public boolean hasFocus()
695 {
696 // Returns true if this Component has the keyboard focus.
697 return false;
698 }
699
700 public boolean isDoubleBuffered()
701 { return use_double_buffer; }
702
703 public boolean isFocusCycleRoot()
704 {
705 // Override this method and return true if your component is the root of of a component tree with its own focus cycle.
706 return false;
707 }
708
709 public boolean isFocusTraversable()
710 {
711 // Identifies whether or not this component can receive the focus.
712 return false;
713 }
714
715 public static boolean isLightweightComponent(Component c)
716 {
717 return c.getPeer() instanceof LightweightPeer;
718 }
719
720 public boolean isManagingFocus()
721 {
722 // Override this method and return true if your JComponent manages focus.
723 return false;
724 }
725
726 public boolean isOpaque()
727 { return opaque; }
728
729 public boolean isOptimizedDrawingEnabled()
730 {
731 // Returns true if this component tiles its children,
732 return true;
733 }
734
735 public boolean isPaintingTile()
736 {
737 // Returns true if the receiving component is currently painting a tile.
738 return false;
739 }
740
741 public boolean isRequestFocusEnabled()
742 {
743 // Return whether the receiving component can obtain the focus by calling requestFocus
744 return false;
745 }
746
747 public boolean isValidateRoot()
748 {
749 // If this method returns true, revalidate() calls by descendants of this component will cause the entire tree beginning with this root to be validated.
750 return false;
751 }
752
753 public void paint(Graphics g)
754 {
755 // System.out.println("SWING_PAINT:" + this);
756
757 paintBorder(g);
758 paintComponent(g);
759 paintChildren(g);
760 }
761
762 protected void paintBorder(Graphics g)
763 {
764 // System.out.println("PAINT_BORDER x XXXXXXX x x x x x x x x x x x x:" + getBorder() + ", THIS="+this);
765
766 // Paint the component's border.
767 if (getBorder() != null)
768 {
769 //System.out.println("PAINT_BORDER x XXXXXXX x x x x x x x x x x x x:" + getBorder() + ", THIS="+this);
770
771 getBorder().paintBorder(this,
772 g,
773 0,
774 0,
775 getWidth(),
776 getHeight());
777 }
778 }
779
780 protected void paintChildren(Graphics g)
781 {
782 // Paint this component's children.
783 //super.paintChildren(g);
784 }
785
786 protected void paintComponent(Graphics g)
787 {
788 // If the UI delegate is non-null, call its paint method.
789 if (ui != null)
790 {
791 ui.paint(g, this);
792 }
793 }
794
795 /**
796 * Paint the specified region in this component and all of
797 * its descendants that overlap the region, immediately.
798 */
799 public void paintImmediately(int x, int y, int w, int h)
800 {
801
802 //Ronald: this shoudld probably redirect to the PLAF ....
803 }
804
805 public void paintImmediately(Rectangle r)
806 {
807 /// Paint the specified region now.
808 paintImmediately((int)r.getX(),
809 (int)r.getY(),
810 (int)r.getWidth(),
811 (int)r.getHeight());
812 }
813 protected String paramString()
814 {
815 // Returns a string representation of this JComponent.
816 return "JComponent";
817 }
818 protected void processComponentKeyEvent(KeyEvent e)
819 {
820 // Process any key events that the component itself recognizes.
821 //System.out.println("COMP_KEY-EVENT: " + e);
822 }
823 protected void processFocusEvent(FocusEvent e)
824 {
825 // Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.
826 //System.out.println("FOCUS_EVENT: " + e);
827 }
828
829 protected void processKeyEvent(KeyEvent e)
830 {
831 // Override processKeyEvent to process events protected
832 //System.out.println("KEY-EVENT: " + e);
833 }
834
835 public void processMouseMotionEvent(MouseEvent e)
836 {
837 // Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.
838 //System.out.println("COMP_MOUSE-EVENT: " + e + ", MEMORY = " + Runtime.getRuntime().freeMemory());
839 }
840
841 public void registerKeyboardAction(ActionListener anAction,
842 KeyStroke aKeyStroke,
843 int aCondition)
844 {
845 registerKeyboardAction(anAction,
846 null,
847 aKeyStroke,
848 aCondition);
849 }
850
851 public void registerKeyboardAction(ActionListener anAction,
852 String aCommand,
853 KeyStroke aKeyStroke,
854 int aCondition)
855 {
856 // Register a new keyboard action.
857 }
858
859
860 public void removeNotify()
861 {
862 // Notification to this component that it no longer has a parent component.
863 }
864
865 public void repaint(long tm, int x, int y, int width, int height)
866 {
867 // Adds the specified region to the dirty region list if the component is showing.
868 //System.out.println("JC: repaint");
869 super.repaint(tm, x,y,width,height);
870 }
871
872 public void repaint(Rectangle r)
873 {
874 // Adds the specified region to the dirty region list if the component is showing.
875 repaint((long)0,
876 (int)r.getX(),
877 (int)r.getY(),
878 (int)r.getWidth(),
879 (int)r.getHeight());
880 }
881
882 public boolean requestDefaultFocus()
883 {
884 // Request the focus for the component that should have the focus by default.
885 return false;
886 }
887
888 public void requestFocus()
889 {
890 // Set focus on the receiving component if isRequestFocusEnabled returns true
891 super.requestFocus();
892 }
893
894 public void resetKeyboardActions()
895 {
896 // Unregister all keyboard actions
897 }
898
899 public void reshape(int x, int y, int w, int h)
900 {
901 /// Moves and resizes this component.
902 super.reshape(x,y,w,h);
903 }
904
905 public void revalidate()
906 {
907 // Support for deferred automatic layout.
908 if (getParent() == null)
909 invalidate();
910 }
911
912 public void scrollRectToVisible(Rectangle aRect)
913 {
914 // Forwards the scrollRectToVisible() message to the JComponent's parent.
915 }
916
917 public void setAlignmentX(float alignmentX)
918 {
919 // Set the the vertical alignment.
920 }
921
922 public void setAlignmentY(float alignmentY)
923 {
924 // Set the the horizontal alignment.
925 }
926
927 public void setAutoscrolls(boolean autoscrolls)
928 {
929 // If true this component will automatically scroll its contents when dragged, if contained in a component that supports scrolling, such as JViewport
930 }
931
932
933 public void setDebugGraphicsOptions(int debugOptions)
934 {
935 // Enables or disables diagnostic information about every graphics operation performed within the component or one of its children.
936 }
937
938 public void setDoubleBuffered(boolean aFlag)
939 {
940 use_double_buffer = aFlag;
941 }
942
943 public void setEnabled(boolean enabled)
944 {
945 // Sets whether or not this component is enabled.
946 super.setEnabled(enabled);
947 repaint();
948 }
949
950 public void setFont(Font font)
951 {
952 super.setFont(font);
953 revalidate();
954 repaint();
955 }
956 public void setBackground(Color bg)
957 {
958 super.setBackground(bg);
959 revalidate();
960 repaint();
961 }
962 public void setForeground(Color fg)
963 {
964 super.setForeground(fg);
965 revalidate();
966 repaint();
967 }
968
969 public void setMaximumSize(Dimension maximumSize)
970 { max = maximumSize; }
971
972 public void setMinimumSize(Dimension minimumSize)
973 { min = minimumSize; }
974
975 public void setPreferredSize(Dimension preferredSize)
976 { pref = preferredSize; }
977
978 public void setNextFocusableComponent(Component aComponent)
979 {
980 // Specifies the next component to get the focus after this one, for example, when the tab key is pressed.
981 }
982
983 public void setOpaque(boolean isOpaque)
984 {
985 opaque = isOpaque;
986 revalidate();
987 repaint();
988 }
989
990
991 public void setRequestFocusEnabled(boolean aFlag)
992 {
993 }
994
995
996 public void setVisible(boolean aFlag)
997 {
998 // Makes the component visible or invisible.
999
1000 super.setVisible(aFlag);
1001 if (getParent() != null)
1002 {
1003 Rectangle dims = getBounds();
1004 getParent().repaint((int)dims.getX(),
1005 (int)dims.getY(),
1006 (int)dims.getWidth(),
1007 (int)dims.getHeight());
1008 }
1009 }
1010
1011 public void unregisterKeyboardAction(KeyStroke aKeyStroke)
1012 {
1013 // Unregister a keyboard action.
1014 }
1015
1016
1017 public void update(Graphics g)
1018 {
1019 paint(g);
1020 }
1021
1022
1023
1024 /******************************************
1025 *
1026 *
1027 * UI management
1028 *
1029 *
1030 *********/
1031
1032 public String getUIClassID()
1033 {
1034 /// Return the UIDefaults key used to look up the name of the swing.
1035 return "JComponent";
1036 }
1037
1038 protected void setUI(ComponentUI newUI)
1039 {
1040 if (ui != null)
1041 {
1042 ui.uninstallUI(this);
1043 }
1044
1045 // Set the look and feel delegate for this component.
1046 ui = newUI;
1047
1048 if (ui != null)
1049 {
1050 ui.installUI(this);
1051 }
1052
1053 revalidate();
1054 repaint();
1055 }
1056
1057 public void updateUI()
1058 {
1059 // Resets the UI property to a value from the current look and feel.
1060 System.out.println("update UI not overwritten in class: " + this);
1061 }
1062
1063}
Note: See TracBrowser for help on using the repository browser.