⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sccanvas.java

📁 J2ME手机游戏编程入门源码 16事例源码 可用手机顽童软件测试
💻 JAVA
字号:
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;

public class SCCanvas extends Canvas {
  private Display  display;
  
  public SCCanvas(Display d) {
    super();
    display = d;
  }

  void start() {
    display.setCurrent(this);
    repaint();
  }

  public void paint(Graphics g) {
    // Clear the canvas
    g.setColor(0, 0, 0);        // black
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(255, 255, 255);  // white

    // Get the supported sound content types
    String[] contentTypes = Manager.getSupportedContentTypes(null);

    // Draw the supported sound content types
    int y = 0;
    for (int i = 0; i < contentTypes.length; i++) {
      // Draw the content type
      g.drawString(contentTypes[i], 0, y, Graphics.TOP | Graphics.LEFT);
      y += Font.getDefaultFont().getHeight();

      // Play a tone if tone generation is supported
      if (contentTypes[i] == "audio/x-tone-seq") {
        try {
          // play middle C (C4) for two seconds (2000ms) at maximum volume (100)
          Manager.playTone(ToneControl.C4, 2000, 100);
        }
        catch(MediaException me) {
        }
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -