글
JAVA
import org.kwis.msp.lcdui.*;
public class CharEx extends Jlet
{
protected void startApp(String args[])
{
Display dp = Display.getDefaultDisplay();
CharCard card = new CharCard();
dp.pushCard(card);
}
protected void destroyApp(boolean b){}
}
class CharCard extends Card
{
protected void paint(Graphics g)
{
char chars[]={'위', '피', '프', '로', '젝', '트'};
g.setColor(0x000000);
//한 문자 그리기
g.drawChar('짱', getWidth()/2, getHeight()/2, g.HCENTER);
//여러 문자 그리기
g.drawChars(chars, 2, 4, 0,10, g.LEFT);
//문자열 그리기
g.drawSubstring("대한민국",0,4,getWidth(),(getHeight()-30),g.RIGHT);
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
public class PolyEx extends Jlet
{
protected void startApp(String args[])
{
Display dp = Display.getDefaultDisplay();
PolyCard card = new PolyCard();
dp.pushCard(card);
}
protected void destroyApp(boolean b){}
}
class PolyCard extends Card
{
protected void paint(Graphics g)
{
int i = 10; //위 아래 좌우 공간을 동일한 비율로 설정
int x[] = {(getWidth()/2), i, (getWidth()-i)};
int y[] = {i, (getHeight()-i), (getHeight()-i)};
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x000000);
//다각형 그리기
g.drawPolygon(x, y);
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class ArcEx extends Jlet
{
protected void startApp(String args[])
{
Display dp = Display.getDefaultDisplay();
ArcCard card = new ArcCard();
dp.pushCard(card);
}
protected void destroyApp(boolean b){}
}
class ArcCard extends Card {
protected void paint(Graphics g) {
int width = 100, height = 150;
int arc = 0;
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0xff0000);
for(int i=1; i<5; i++) {
ack = 90 * i;
if(i % 2 == 0)
//원호 그리기
g.drawArc(10, 5, width, height, arc, 90);
else
//속에 색칠된 원호 그리기
g.fillArc(10, 5, width, height, arc, 90);
}
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
public class RectEx extends Jlet
{
protected void startApp(String args[])
{
Display dp = Display.getDefaultDisplay();
RectClass card = new RectClass();
dp.pushCard(card);
}
protected void destroyApp(boolean b){}
}
class RectClass extends Card
{
protected void paint(Graphics g)
{
int j = 0, height = 0, width = 0;
g.setColor(0xffffff);
//사각형 그리기
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0xffff00);
//둥근 사각형 그리기
g.fillRoundRect(10, 10, getWidth()-20, getHeight()-20, 10, 10);
g.setColor(0x000000);
for(int i=0; i<6; i++) {
j = i*10;
width = getWidth()-(j*2);
height = getHeight()-(j*2);
//짝수면 사각형, 홀수면 둥근 사각형을 그린다.
if(i%2 == 0)
g.drawRect(j, j, width, height);
else {
//마지막 5번째 둥근 사각형을 그릴 때는 색칠된 것으로 그린다.
if(i == 5)
g.fillRoundRect(j, j, width, height,(10+i),(10+i));
else
g.drawRoundRect(j, j, width, height,(10+i),(10+i));
}
}
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
public class LineEx extends Jlet
{
protected void startApp(String args[])
{
Display dp = Display.getDefaultDisplay();
LineClass card = new LineClass();
dp.pushCard(card);
}
protected void destroyApp(boolean b){}
}
class LineClass extends Card
{
protected void paint(Graphics g)
{
g.setColor(0xffffff);
//사각형 그리기
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0, 0, 0); //RGB 값으로 설정
//Line style 설정
g.setStrokeStyle(Graphics.SOLID);
//Line 그리기
g.drawLine(0, 0, getWidth(), getHeight());
g.setStrokeStyle(Graphics.DOTTED);
g.drawLine(getWidth(), 0, 0, getHeight());
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import java.io.IOException;
public class AnchorEx extends Jlet
{
protected void startApp(String args[])
{
Display dp = Display.getDefaultDisplay();
MoveCard card = new MoveCard();
dp.pushCard(card);
}
protected void destroyApp(boolean b){}
}
class MoveCard extends Card {
int anchor = Graphics.VCENTER | Graphics.HCENTER;
int x = 0, y = 0;
int count = 0;
protected void paint(Graphics g) {
Image img = null;
try {
img = Image.createImage("folder.gif");
}catch(IOException e){}
g.translate(x, y);
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
//이미지를 화면에 출력함
g.drawImage(img, getWidth()/2, getHeight()/2, anchor);
}
public boolean keyNotify(int type, int keyCode) {
if(type == EventQueue.KEY_PRESSED) {
switch(count % 3) {
case 0:
x = 20; y = 20;
anchor = Graphics.BOTTOM | Graphics.RIGHT; break;
case 1:
x = 0; y = 0;
anchor = Graphics.TOP | Graphics.LEFT; break;
case 2:
x = 10; y = 10;
anchor = Graphics.VCENTER | Graphics.HCENTER;
break;
}
repaint(); count++;
}
return true;
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class FontEx extends Jlet
{
ShellComponent shell = new ShellComponent();
FontComponent font = new FontComponent();
protected void startApp(String args[])
{
shell.addComponent(font);
shell.show();
}
protected void destroyApp(boolean b){}
}
class FontComponent extends Component
{
public void paintContent(Graphics g)
{
Font font;
//기본값으로 설정
font = Font.getDefaultFont();
g.setFont(font);
g.drawString("WIPT PROJECT.", 10, 10, g.TOP);
//getFont()를 이용하여 속성 설정
font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD | Font.STYLE_UNDERLINED, Font.SIZE_LARGE);
g.setFont(font);
g.drawString("KOREA", getWidth()/2, getHeight()/2, g.HCENTER);
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class TickerEx extends Jlet implements ActionListener {
ShellComponent shell = new ShellComponent();
FormComponent form = new FormComponent();
TickerComponent tick = new TickerComponent("오늘은 2009년 4월 9일 입니다.",null);
ButtonComponent button1 = new ButtonComponent("시작",null);
ButtonComponent button2 = new ButtonComponent("정지",null);
protected void startApp(String args[]) {
button1.setActionListener(this, null);
button2.setActionListener(this, null);
tick.setDelay(1000);
form.addComponent(tick); form.addComponent(button1);
form.addComponent(button2); form.setGab(10);
shell.addComponent(form); shell.show();
}
protected void destroyApp(boolean b){}
public void action(Component c, Object o)
{
if(c == button1)
{
tick.setTickerState(true);
}
else if(c == button2)
{
tick.setTickerState(false);
}
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class ProgressEx extends Jlet implements ActionListener {
ShellComponent shell = new ShellComponent();
FormComponent form = new FormComponent();
ProgressComponent pro = new ProgressComponent(true, 100);
LabelComponent label = new LabelComponent("전송 준비중!!!");
ButtonComponent button = new ButtonComponent("전송하기", null);
protected void startApp(String args[]) {
button.setActionListener(this, null);
pro.setValue(0);
form.addComponent(label); form.addComponent(pro);
form.addComponent(button); form.setGab(5);
shell.addComponent(form);
shell.show();
}
protected void destroyApp(boolean b){}
public void action(Component c, Object o)
{
for(int i=0; i<=pro.getMaxValue(); i++)
{
pro.setValue(i);
label.setLabel(pro.getValue() + "% 진행완료");
try
{
Thread.sleep(200);
}catch(InterruptedException e){}
//화면의 내용을 갱신
shell.repaint();
//갱신된 내용을 즉시 화면에 출력
shell.serviceRepaints();
}
LabelComponent label = new LabelComponent("전송 완료" );
DialogComponent dialog = new DialogComponent(label, "Imformaiton", DialogComponent.TYPE_OK);
dialog.doModal();
label.setLabel("전송 준비중!!!!");
pro.setValue(0);
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
import java.io.IOException;
public class ImageEx extends Jlet implements CommandListener
{
ShellComponent shell = new ShellComponent();
CommandBarComponent combar = new CommandBarComponent();
ImageComponent img = new ImageComponent();
Command cmd1, cmd2;
Image image1, image2;
protected void startApp(String args[])
{
try
{
image1 = Image.createImage("play.gif");
image2 = Image.createImage("stop.gif");
}catch(IOException e){}
img.setImage("ani.gif");
img.setLayout(Component.LAYOUT_HCENTER | Component.LAYOUT_VCENTER);
cmd1 = new Command("시작", image1, cmd1);
cmd2 = new Command("정지", image2, cmd2);
combar.addCommand(cmd1);
combar.addCommand(cmd2);
combar.setCommandListener(this, null);
shell.addComponent(img);
shell.setCommand(combar, false);
shell.show();
}
protected void paseApp(){}
protected void resumeApp(){}
protected void destroyApp(boolean b){}
public void commandAction(Command c, int t, Object o)
{
if(c == cmd1 && t == SELECT)
img.play();
if(c == cmd2 && t == SELECT)
img.stop();
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class DateEx extends Jlet implements ActionListener {
ShellComponent shell = new ShellComponent();
FormComponent form = new FormComponent();
ButtonComponent button = new ButtonComponent("모드 바꾸기", null);
DateFieldComponent date = new DateFieldComponent(DateFieldComponent.MODE_DATE);
protected void startApp(String args[]) {
button.setActionListener(this, null);
form.addComponent(date);
form.addComponent(button);
form.setGab(10);
shell.addComponent(form);
shell.show();
}
protected void destroyApp(boolean b){}
public void action(Component c, Object o) {
switch(date.getMode())
{
case DateFieldComponent.MODE_DATE:
date.setMode(DateFieldComponent.MODE_TIME_DATE);
break;
case DateFieldComponent.MODE_TIME_DATE:
date.setMode(DateFieldComponent.MODE_TIME);
break;
case DateFieldComponent.MODE_TIME:
date.setMode(DateFieldComponent.MODE_DATE);
break;
}
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
import java.io.IOException;
public class CommandEx extends Jlet implements CommandListener {
ShellComponent shell = new ShellComponent();
CommandBarComponent combar = new CommandBarComponent();
Image image1, image2, image3;
Command cmd1, cmd2, cmd3;
protected void startApp(String args[]) {
try
{
image1 = Image.createImage("star.gif");
image2 = Image.createImage("circle.gif");
image3 = Image.createImage("cancel.gif");
}catch(IOException e){}
cmd1 = new Command("별",image1, cmd1);
cmd2 = new Command("원",image2, cmd2);
cmd3 = new Command("취소",image3, cmd3);
combar.addCommand(cmd1);
combar.addCommand(cmd2);
combar.addCommand(cmd3);
combar.setCommandListener(this, null);
shell.setCommand(combar, false);
shell.show();
}
protected void destroyApp(boolean b){}
public void commandAction(Command c, int t, Object o)
{
if(c == cmd1 && t == SELECT)
{
LabelComponent label = new LabelComponent(null, image1);
DialogComponent dialog = new DialogComponent(label, "별 모양 선택", DialogComponent.TYPE_NONE);
dialog.setTimeout(2000);
dialog.doModal();
}
if(c == cmd2 && t == SELECT)
{
LabelComponent label = new LabelComponent(null, image2);
DialogComponent dialog = new DialogComponent(label, "원 모양 선택", DialogComponent.TYPE_OK);
dialog.doModal();
}
if(c == cmd3 && t == SELECT)
{
LabelComponent label = new LabelComponent(null, image3);
DialogComponent dialog = new DialogComponent(label, "취소 선택", DialogComponent.TYPE_NONE);
dialog.setTimeout(2000);
dialog.doModal();
}
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class TextfieldEx extends Jlet {
ShellComponent shell = new ShellComponent();
FormComponent form = new FormComponent();
TextFieldComponent textfield = new TextFieldComponent("",TextComponent.CONSTRAINT_ANY);
TextBoxComponent textbox = new TextBoxComponent("",TextComponent.CONSTRAINT_ANY,100);
protected void startApp(String args[]) {
form.addComponent(textfield);
form.addComponent(textbox);
form.setGab(5);
shell.setTitle("핸드폰 메모장");
shell.addComponent(form);
shell.show();
}
protected void destroyApp(boolean b){}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class TextboxEx extends Jlet implements ActionListener
{
int i;
ShellComponent shell = new ShellComponent();
FormComponent form = new FormComponent();
TextBoxComponent textbox = new TextBoxComponent("",TextBoxComponent.CONSTRAINT_NUMBER);
ButtonComponent button = new ButtonComponent("입력",null);
LabelComponent label = new LabelComponent("0개 입력 완료");
protected void startApp(String args[]) {
button.setActionListener(this, null);
form.addComponent(textbox);
form.addComponent(button);
form.addComponent(label);
shell.setTitle("HP를 입력하세요.");
shell.addComponent(form);
shell.show();
}
protected void destroyApp(boolean b){}
public void action(Component c, Object o) {
i++;
textbox.setString("");
label.setLabel(i + "개 입력 완료");
}
}
글
JAVA
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class AnnunciatorEx extends Jlet {
AnnunciatorComponent ann = new AnnunciatorComponent(false);
ShellComponent shell = new ShellComponent();
FormComponent form = new FormComponent();
ButtonComponent button1 = new ButtonComponent("실행하기",null);
ButtonComponent button2 = new ButtonComponent("취소하기",null);
protected void startApp(String args[]) {
ann.show();
form.addComponent(button1);
form.addComponent(button2);
form.setGab(10);
shell.addComponent(form);
shell.show();
}
protected void destroyApp(boolean b){}
}