KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > windows > WindowsUtils


1 /*
2  * @(#)WindowsUtils.java 1.9 04/04/16
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7  
8 package com.sun.java.swing.plaf.windows;
9
10 import javax.swing.plaf.*;
11 import javax.swing.*;
12 import java.awt.*;
13
14 /**
15  * This is a collection of utility methods needed by the Windows L&F
16  *
17  * @version 1.9 04/16/04
18  * @author Brian Beck
19  */

20
21 class WindowsUtils {
22     /*
23      * Convenience function for determining ComponentOrientation. Helps us
24      * avoid having Munge directives throughout the code.
25      */

26     static boolean isLeftToRight( Component c ) {
27         return c.getComponentOrientation().isLeftToRight();
28     }
29
30     /*
31      * Repaints all the components with the mnemonics in the given window and
32      * all its owned windows.
33      */

34     static void repaintMnemonicsInWindow(Window w) {
35         if(w == null || !w.isShowing()) {
36             return;
37         }
38
39         Window[] ownedWindows = w.getOwnedWindows();
40         for(int i=0;i<ownedWindows.length;i++) {
41             repaintMnemonicsInWindow(ownedWindows[i]);
42         }
43
44         repaintMnemonicsInContainer(w);
45     }
46
47     /*
48      * Repaints all the components with the mnemonics in container.
49      * Recursively searches for all the subcomponents.
50      */

51     static void repaintMnemonicsInContainer(Container cont) {
52         Component c;
53         for(int i=0; i<cont.getComponentCount(); i++) {
54             c = cont.getComponent(i);
55             if(c == null || !c.isVisible()) {
56                 continue;
57             }
58             if(c instanceof AbstractButton
59                && ((AbstractButton)c).getMnemonic() != '\0') {
60                 c.repaint();
61                 continue;
62             } else if(c instanceof JLabel
63                       && ((JLabel)c).getDisplayedMnemonic() != '\0') {
64                 c.repaint();
65                 continue;
66             }
67             if(c instanceof Container) {
68                 repaintMnemonicsInContainer((Container)c);
69             }
70         }
71     }
72 }
73
Popular Tags