CounterItem.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:2k
源码类别:
J2ME
开发平台:
Java
- import javax.microedition.lcdui.*;
- // A custom component for MIDP 2.0 that wraps
- // a CounterArea instance.
- public class CounterItem extends CustomItem
- implements CounterArea.Callback {
- public CounterItem(){
- super( null );
- _area = new CounterArea();
- _area.setCallback( this );
- }
- public Font getFont(){
- return _area.getFont();
- }
- public int getMinContentHeight(){
- return _area.getMinHeight();
- }
- public int getMinContentWidth(){
- return _area.getMinWidth();
- }
- public int getPrefContentHeight( int width ){
- return getMinContentHeight();
- }
- public int getPrefContentWidth( int height ){
- return getMinContentWidth();
- }
- public int getValue(){
- return _area.getValue();
- }
- protected void hideNotify(){
- _area.stop();
- }
- public void invalidateCounter( CounterArea counter ){
- if( counter == _area ){
- invalidate();
- }
- }
- protected void paint( Graphics g, int width, int height ){
- _area.paint( g );
- }
- public void repaintCounter( CounterArea counter ){
- if( counter == _area ){
- repaint();
- }
- }
- public void resizeCounter( CounterArea counter ){
- if( counter == _area ){
- invalidate();
- }
- }
- protected void sizeChanged( int w, int h ){
- _area.setWidth( w );
- _area.setHeight( h );
- }
- public void setFont( Font f ){
- _area.setFont( f );
- }
- public void setValue( int value ){
- _area.setValue( value );
- }
- protected void showNotify(){
- _area.start();
- }
- public boolean traverse( int dir, int vw, int vh,
- int[] vrect ){
- return false;
- }
- private CounterArea _area;
- }