亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? popup.java

?? 非常好的JAVA編程的例子
?? JAVA
字號:


package popup;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

public class Popup implements Runnable
{

  public static final char[][] ALT_OK;
  public static final char[][] ALT_CANCEL;
  public static final char[][] ALT_YES_NO;
  public static final char[][] ALT_OK_CANCEL;
  public static final char[][] ALT_YES_NO_CANCEL;

  static
  {
    ALT_OK = new char[1][];
    ALT_OK[0] = "Ok".toCharArray();
    ALT_CANCEL = new char[1][];
    ALT_CANCEL[0] = "Cancel".toCharArray();
    ALT_YES_NO = new char[2][];
    ALT_YES_NO[0] = "YES".toCharArray();
    ALT_YES_NO[1] = "NO".toCharArray();
    ALT_OK_CANCEL = new char[2][];
    ALT_OK_CANCEL[0] = ALT_OK[0];
    ALT_OK_CANCEL[1] = ALT_CANCEL[0];
    ALT_YES_NO_CANCEL = new char[3][];
    ALT_YES_NO_CANCEL[0] = ALT_YES_NO[0];
    ALT_YES_NO_CANCEL[1] = ALT_YES_NO[1];
    ALT_YES_NO_CANCEL[2] = ALT_CANCEL[0];
  }

  protected char[] text;
  protected byte alternatives;
  protected char[][] altTexts;
  protected byte timeOut;
  protected byte timeOutAlt;
  protected byte curAlt;
  protected PopupListener listener;
  protected volatile boolean active = false;
  protected int w;
  protected int h;
  protected int[][] breakTextData;
  protected int visibleLines;
  protected int curLine;
  protected int maxLine;
  protected int yoffset;
  protected long endTime;
  protected Font font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,
      Font.SIZE_LARGE);
  protected int fontHeight = font.getHeight();
  protected int borderColor = 0xdd0000;
  protected int backgroundColor = 0xcc440000;
  protected int textColor = 0xffffff;
  protected int alternativeColor = 0xff2200;
  protected int selectedAlternativeColor = 0xffffff;
  protected static int[] rgbData;
  protected static final int OFFSET_POPUP = 8;
  protected static final int OFFSET_TEXT = 2;
  protected static final int OFFSET_ALT = 4;
  protected static final int SB_WIDTH = 5;
  protected static final char[] TEXTBREAKS =
    { ' ', '?', ';', ',', '.', '!',
      ':', '-', '=', '(', ')', '[', ']' };
  protected static final char NEWLINE = '\n';
  public Popup() {}
  public void init(char[] text, char[][] altTexts, byte timeOut,
      byte defaultAlt, byte timeOutAlt, PopupListener listener, int width,
      int height)
  {
    this.text = text;
    this.altTexts = altTexts;
    if (altTexts != null)
    {
      alternatives = (byte) altTexts.length;
    }
    else
    {
      alternatives = 0;
    }
    this.timeOut = timeOut;
    this.timeOutAlt = timeOutAlt;
    this.listener = listener;
    curAlt = defaultAlt;
    w = width - (OFFSET_POPUP << 1);
    h = height - (OFFSET_POPUP << 1);
    active = true;
    if (timeOut > 0)
    {
      endTime = System.currentTimeMillis() + (timeOut * 1000);
    }
    else if (alternatives > 0)
    {
      endTime = 0;
    }
    else
    {
      endTime = System.currentTimeMillis();
    }

    visibleLines =
      Math.max(1, ((h - (OFFSET_TEXT << 1)) / fontHeight) - 1);
    int w = this.w - (OFFSET_TEXT << 1) - (SB_WIDTH << 1);
    curLine = 0;

    breakTextData = breakString(text, w);

    yoffset = 0;
    maxLine = breakTextData.length - visibleLines + 1;
    if (breakTextData.length < visibleLines)
    {
      int newH = breakTextData.length * fontHeight;
      if (alternatives > 0)
        newH += fontHeight;
      newH += OFFSET_TEXT + OFFSET_ALT;
      yoffset = (h - newH) >> 1;
      h = newH;
    }

    if (rgbData == null || rgbData.length != this.w * 8)
    {
      rgbData = new int[this.w * 8];
      for (int i = 0; i < rgbData.length; i++)
      {
        rgbData[i] = backgroundColor;
      }
    }

    new Thread(this, "PopupPoll").start();
  }
  protected int[][] breakString(char[] text, int width)
  {
    int offset = 0;
    int lines = 0;
    int newOffset;

    while (offset < text.length)
    {
      newOffset = 
        findNextBreak(text, offset, text.length - offset, width, font);
      offset = newOffset;
      lines++;
    }

    int[][] indices = new int[lines][2];

    lines = 0;
    offset = 0;
    while (offset < text.length)
    {
      newOffset =
        findNextBreak(text, offset, text.length - offset, width, font);
      indices[lines][0] = offset;
      indices[lines][1] = newOffset - offset;
      lines++;
      offset = newOffset;
    }

    return indices;
  }

  public int findNextBreak(char[] text, int offset, int len, int w, Font f)
  {
    int breakOffset = offset;
    int textW = 0;
    int niceB = -1;
    char c;
    charLoop: while (breakOffset <= offset + len && textW < w)
    {
      if (breakOffset == offset + len)
        c = TEXTBREAKS[0]; 
      else
        c = text[breakOffset];
      if (c == NEWLINE)
      {
        niceB = breakOffset;
        break charLoop;
      }

      breakCharLoop:
      for (int i = TEXTBREAKS.length - 1; i >= 0; i--)
      {
        if (c == TEXTBREAKS[i])
        {
          niceB = breakOffset;
          break breakCharLoop;
        }
      }
      if (breakOffset == offset + len - 1)
      {
        niceB = breakOffset + 1;
      }
      breakOffset++;
      textW += f.charWidth(c);
    }
    if (niceB > offset && niceB < offset + len - 2 && (text[niceB + 1] == ' '))
      return niceB + 2;        
    else if (niceB > offset && niceB < offset + len)
      return niceB + 1;        
    else if (breakOffset > offset + 1)
      return breakOffset - 1; 
    else if (breakOffset == offset)
      return breakOffset + 1; 
    else
      return breakOffset;     
  }
  public void paint(Graphics g)
  {
    if (active)
    {
      for (int y = OFFSET_POPUP + yoffset; y < OFFSET_POPUP + yoffset + h; y += 8)
      {
        g.drawRGB(rgbData, 0, w, OFFSET_POPUP, y, w, Math.min(8,
            OFFSET_POPUP + yoffset + h - y), true);
      }
      g.setColor(borderColor);
      g.drawRect(OFFSET_POPUP, OFFSET_POPUP + yoffset, w, h);
      g.setColor(textColor);
      g.setFont(font);
      int y = OFFSET_POPUP + OFFSET_TEXT + yoffset;
      int maxLine =
        Math.min(curLine + visibleLines, breakTextData.length);
      for (int i = curLine; i < maxLine; i++)
      {
        int offset = breakTextData[i][0];
        int len = breakTextData[i][1];
        if (len == 1 && text[offset] == NEWLINE)
        {
          y += fontHeight;
        }
        else
        {
          if (text[offset + len - 1] == NEWLINE)
          {
            len--;
          }
          g.drawChars(text, offset, len, OFFSET_POPUP + OFFSET_TEXT
              + (w >> 1), y, Graphics.TOP | Graphics.HCENTER);
          y += fontHeight;
        }
      }

      if (visibleLines < breakTextData.length)
      {
        int sbh = visibleLines * fontHeight;   // Scrollbar max height
        int sbstep = ((sbh - 4) << 8) / maxLine; // Scrollbar height * 256
        int sbX =
          OFFSET_POPUP + w - SB_WIDTH - (SB_WIDTH >> 1); // Scrollbar x-coordinate
        g.setColor(textColor);
        g.fillRect(sbX, OFFSET_POPUP + OFFSET_TEXT + ((curLine * sbstep) >> 8),
          SB_WIDTH, 4 + (sbstep >> 8));
      }

      if (alternatives > 0)
      {
        y =
          OFFSET_POPUP + OFFSET_TEXT + h + yoffset - OFFSET_TEXT - fontHeight;
        int dx = (w / (alternatives + 1));
        int x = OFFSET_POPUP + OFFSET_TEXT;
        for (int i = 0; i < alternatives; i++)
        {
          char[] t = altTexts[i];
          x += dx;
          int xx = x - (font.charsWidth(t, 0, t.length) >> 1);
          if (curAlt != i)
          {
            g.setColor(alternativeColor);
            g.drawChars(t, 0, t.length, xx, y, Graphics.TOP | Graphics.LEFT);
          } 
          else
          {
            g.setColor(alternativeColor);
            g.drawChars(t, 0, t.length, xx + 1, y + 1,
                Graphics.TOP | Graphics.LEFT);
            g.setColor(selectedAlternativeColor);
            g.drawChars(t, 0, t.length, xx, y, Graphics.TOP | Graphics.LEFT);
          }
        }
      }
    }
  }

  public void keyPressed(int keyCode, int gameCode)
  {
    if (active)
    {
      if (alternatives < 1)
      {
        active = false;
        if (listener != null)
          listener.selectedChoice(curAlt, false);
      }
      else
      {
        switch (gameCode)
        {
        case Canvas.DOWN:
        {
          curLine++;
          if (curLine >= maxLine)
            curLine = 0;
          break;
        }
        case Canvas.UP:
        {
          if (maxLine > 0)
            curLine--;
          if (curLine < 0)
            curLine = maxLine - 1;
          break;
        }
        case Canvas.RIGHT:
        {
          curAlt++;
          if (curAlt >= alternatives)
            curAlt = 0;
          break;
        }
        case Canvas.LEFT:
        {
          curAlt--;
          if (curAlt < 0)
            curAlt = (byte) (alternatives - 1);
          break;
        }
        case Canvas.FIRE:
        {

          if (curAlt >= 0)
          {
            active = false;
            if (listener != null)
              listener.selectedChoice(curAlt, false);
          }
          break;
        }
        case -11:
        {
          active = false;
          if (listener != null)
            listener.selectedChoice(timeOutAlt, false);
          break;
        }
        }
      }
    }
  }

  /**
   * Disposes all resources held by this popup and closes it.
   */
  public void dispose()
  {
    active = false;
    text = null;
    altTexts = null;
    listener = null;
    breakTextData = null;
    System.gc();
  }

  /**
   * Returns whether this popup is active or not.
   * 
   * @return true if active, false otherwise.
   */
  public boolean isActive()
  {
    return active;
  }

  /**
   * Returns alternative index on timeout
   * 
   * @return timeout alternative
   */
  public byte getTimeOutChoice()
  {
    return timeOutAlt;
  }

  /**
   * Called by framework to check if popup reached its' timeout.
   * 
   * @return true if timeout, false otherwise.
   */
  protected boolean pollTimeout()
  {
    if (active)
    {
      if (endTime > 0 && System.currentTimeMillis() > endTime)
      {
        active = false;
        if (listener != null)
        {
          listener.selectedChoice(timeOutAlt, true);
          return true;
        }
      }
    }
    return false;
  }

  // Runnable impl to poll this popup
  public void run()
  {
    while (isActive())
    {
      // Poll popup timeout
      try
      {
        Thread.sleep(1000);
        pollTimeout();
      } catch (InterruptedException e) {}
    }
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久99久久久精品网站| 91麻豆精品久久久久蜜臀| 国产精品电影一区二区| 日韩精品视频网| 蜜桃久久久久久久| 久久久亚洲午夜电影| 成人精品免费网站| 不卡电影一区二区三区| 亚洲人成亚洲人成在线观看图片 | 午夜视频一区二区| 制服.丝袜.亚洲.中文.综合| 激情图区综合网| 蜜桃精品视频在线| 韩国av一区二区三区在线观看| 美日韩一区二区| 久久久国产精品麻豆| 国产成人午夜99999| 一区二区高清在线| 久久视频一区二区| 精品日韩一区二区| 久久一留热品黄| 色综合咪咪久久| 北条麻妃一区二区三区| 在线欧美日韩精品| 国产日韩视频一区二区三区| 一区二区激情小说| 久久精品国产秦先生| 国产精品一级黄| 国产一区二区看久久| 欧美日韩色一区| 久久人人爽爽爽人久久久| 韩国理伦片一区二区三区在线播放| 欧美成人国产一区二区| 99视频一区二区三区| 喷水一区二区三区| 国产精品久久久久久久久免费桃花 | 蜜桃久久久久久久| 亚洲欧洲美洲综合色网| 欧美一级片在线观看| 9l国产精品久久久久麻豆| 免费在线看成人av| 亚洲女女做受ⅹxx高潮| 337p日本欧洲亚洲大胆色噜噜| 色悠悠亚洲一区二区| 国内外成人在线| 亚洲成人激情社区| 国产精品人妖ts系列视频| 欧美一区二区三区视频免费播放| 成人综合在线观看| 蜜桃一区二区三区四区| 一区二区三区四区av| 国产亚洲制服色| 91精品国产91综合久久蜜臀| 色综合色狠狠综合色| 国产sm精品调教视频网站| 日本不卡一二三| 曰韩精品一区二区| 中文字幕日本不卡| 国产亚洲精品精华液| 欧美一区二区三区在线观看视频| 日本黄色一区二区| 成人av免费在线播放| 成人毛片在线观看| 国产1区2区3区精品美女| 韩国av一区二区三区四区| 美女视频一区二区三区| 婷婷久久综合九色综合绿巨人| 亚洲精品中文在线| 亚洲女人的天堂| 亚洲人成精品久久久久久| 亚洲欧洲成人自拍| 国产精品久久久久久久久免费相片| 欧美精品一区二区三区高清aⅴ | 欧美亚洲综合色| 99r国产精品| 99国产精品久久久久久久久久 | 亚洲精品日产精品乱码不卡| 国产精品免费视频一区| 国产精品天美传媒| 国产精品国模大尺度视频| 国产精品动漫网站| 亚洲欧美福利一区二区| 樱花影视一区二区| 亚洲国产日韩在线一区模特| 亚洲一二三四区| 亚洲国产综合视频在线观看| 午夜精品久久久久| 日本亚洲三级在线| 久久成人免费网站| 国产成人啪午夜精品网站男同| 国产成人av在线影院| 成人av综合在线| 日本久久精品电影| 欧美喷水一区二区| 欧美不卡视频一区| 欧美国产一区在线| 亚洲精品老司机| 日韩中文字幕一区二区三区| 老司机一区二区| 国产经典欧美精品| 色婷婷精品久久二区二区蜜臂av | 国产在线精品一区二区不卡了| 国模无码大尺度一区二区三区| 国产精品综合二区| 成人黄动漫网站免费app| 99精品黄色片免费大全| 欧美另类高清zo欧美| 久久嫩草精品久久久久| 亚洲男帅同性gay1069| 日韩av一二三| 国产精品乡下勾搭老头1| 色呦呦国产精品| 日韩一区二区三区观看| 中文字幕欧美激情一区| 一区二区三区四区激情| 久久se精品一区精品二区| www.一区二区| 日韩一区二区在线观看视频| 欧美国产日韩a欧美在线观看| 亚洲精品日日夜夜| 国产精品资源在线| 欧洲一区二区av| 久久精品亚洲精品国产欧美| 亚洲自拍偷拍图区| 国产成人午夜精品影院观看视频| 欧洲色大大久久| 欧美国产在线观看| 麻豆精品视频在线| 91蝌蚪porny成人天涯| 精品国产一区久久| 亚洲一二三四在线观看| 成人久久久精品乱码一区二区三区| 欧美日韩成人在线一区| 亚洲日本韩国一区| 国产一区二区三区综合| 欧洲精品一区二区| 国产精品国产三级国产普通话三级| 青青草原综合久久大伊人精品| 99re成人精品视频| 久久免费精品国产久精品久久久久 | 一本色道亚洲精品aⅴ| 精品国产乱码久久久久久老虎| 亚洲一区二区三区小说| 成人手机在线视频| 欧美精品一区二区三区在线| 日韩不卡一区二区三区| 色婷婷久久久久swag精品 | 亚洲成人av免费| 色呦呦一区二区三区| 国产精品剧情在线亚洲| 国产凹凸在线观看一区二区| 日韩欧美一二三四区| 日韩国产一二三区| 欧美色倩网站大全免费| 亚洲精品国产a久久久久久 | 中文字幕精品—区二区四季| 久久综合综合久久综合| 日韩三级.com| 日本在线不卡一区| 91精品在线观看入口| 亚洲电影视频在线| 欧美视频中文字幕| 亚洲国产wwwccc36天堂| 在线区一区二视频| 亚洲福中文字幕伊人影院| 亚洲免费看黄网站| 国产精品私房写真福利视频| 在线视频国内一区二区| 国产一区二区三区免费播放| 香蕉久久夜色精品国产使用方法 | 成人丝袜高跟foot| 久久嫩草精品久久久久| 韩国精品免费视频| 久久先锋影音av| 国产精选一区二区三区| 久久久久久久久久电影| 国产精品66部| 国产精品久久久久久久久久久免费看 | 欧美日本在线观看| 石原莉奈一区二区三区在线观看| 欧美日韩激情一区| 奇米四色…亚洲| 久久久久久久性| 成人av网站免费观看| 亚洲色图都市小说| 精品视频在线看| 91麻豆精品国产自产在线 | 久久99精品一区二区三区| 亚洲欧美视频在线观看| 欧美一级一区二区| 91美女精品福利| 欧美三级视频在线观看| 91丨porny丨首页| 国产乱码精品1区2区3区| 秋霞成人午夜伦在线观看| 国产一区美女在线| 欧美调教femdomvk| 亚洲色图制服诱惑| 欧美嫩在线观看| 岛国av在线一区|