상세 컨텐츠

본문 제목

사각형, 둥근사각형

청강컴정/소프트웨어공학

by luckey 2009. 5. 4. 15:07

본문

import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;

public class RectEx extends Jlet
{
 ShellComponent shell = new ShellComponent();
 RectComponent rect = new RectComponent();
 protected void startApp(String args[])
 {
  shell.addComponent(rect);
  shell.show();
  //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
   {
    if(i == 5)
    {
     g.fillRoundRect(j, j, width, height, (10 + i), (10 + i));
    }
    else
    {
     g.drawRoundRect(j, j, width, height, (10 + i), (10 + i));
    }
   }
  }
 }
}

class RectComponent extends Component
{
 public void paintContent(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 == 1)
   {
    g.drawRect(j, j, width, height);
   }
   else
   {
    if(i == 5)
    {
     g.fillRoundRect(j, j, width, height, (10 + i), (10 + i));
    }
    else
    {
     g.drawRoundRect(j, j, width, height, (10 + i), (10 + i));
    }
   }
  }
 }
}

관련글 더보기

댓글 영역