KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > microedition > lcdui > Item


1
2 /*
3  * MicroEmulator
4  * Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contributor(s):
21  * 3GLab
22  */

23  
24 package javax.microedition.lcdui;
25
26
27 public abstract class Item
28 {
29
30     static final int OUTOFITEM = Integer.MAX_VALUE;
31
32   StringComponent labelComponent;
33   Screen owner = null;
34     private boolean focus = false;
35   
36   
37   Item(String label)
38   {
39         labelComponent = new StringComponent(label);
40   }
41   
42   
43     public String getLabel()
44     {
45         return labelComponent.getText();
46     }
47
48
49     public void setLabel(String label)
50     {
51         labelComponent.setText(label);
52     }
53
54     
55   int getHeight()
56     {
57         return labelComponent.getHeight();
58     }
59     
60     
61     boolean isFocusable()
62     {
63         return false;
64     }
65     
66     
67   void keyPressed(int keyCode)
68   {
69   }
70   
71     
72   abstract int paint(Graphics g);
73     
74     
75     void paintContent(Graphics g)
76     {
77         labelComponent.paint(g);
78     }
79     
80     
81     void repaint()
82     {
83         if (owner != null) {
84             owner.repaint();
85         }
86     }
87     
88   
89     boolean hasFocus()
90     {
91         return focus;
92     }
93   
94   
95     void setFocus(boolean state)
96     {
97         focus = state;
98     }
99   
100   
101   Screen getOwner()
102   {
103     return owner;
104   }
105     
106     
107   void setOwner(Screen owner)
108   {
109     this.owner = owner;
110   }
111     
112     
113     boolean select()
114     {
115         return false;
116     }
117   
118
119     int traverse(int gameKeyCode, int top, int bottom, boolean action)
120     {
121         return 0;
122     }
123     
124 }
125
Popular Tags