?? manager.java
字號(hào):
package com.j2medev.numbergame;
import java.util.*;
import javax.microedition.lcdui.*;
// A subclass of Area that can act as
// the parent for other components.
public class Manager extends Area
{
protected Vector children = new Vector();
protected Area focus = null;
public Manager()
{
super(0, 0, 0, 0, null);
w = getCanvasWidth();
h = getCanvasHeight();
}
public void add(Area child)
{
if (!children.contains(child))
{
children.addElement(child);
child.setParent(this);
repaintArea(child, false);
}
}
protected Area getFocus()
{
if (focus == null && children.size() > 0)
{
focus = (Area) children.elementAt(0);
}
return focus;
}
public void keyPressed(int keyCode)
{
Area focus = getFocus();
if (focus != null && focus != this)
{
focus.keyPressed(keyCode);
}
}
public void keyReleased(int keyCode)
{
}
public void keyRepeated(int keyCode)
{
}
// Called to move the focus to the next
// or previous component
protected void moveFocus(boolean forward)
{
Area oldFocus = getFocus();
if (oldFocus != null)
{
int i = children.indexOf(oldFocus);
int last = children.size() - 2;
if (forward)
{
if (++i > last)
i = 0;
} else
{
if (--i < 0)
i = last;
}
focus = (Area) children.elementAt(i);
repaintArea(oldFocus, false);
repaintArea(focus, true);
}
}
public void remove(Area child)
{
if (children.removeElement(child))
{
child.setParent(null);
repaintArea(child, false);
}
}
protected void paint(Graphics g)
{
if (focus == null)
getFocus();
eraseBackground(g);
g.setColor(getForeColor());
int n = children.size();
for (int i = n - 1; i >= 0; --i)
{
try
{
Area area = (Area) children.elementAt(i);
area.paint(g, (focus == area));
} catch (Exception e)
{
e.printStackTrace();
}
}
}
protected void paintArea(Graphics g, boolean hasFocus)
{
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -