-3

我正在运行一个 android 应用程序,它只是弹出一个窗口说“你好”。当我在模拟器中运行它时,它显示“不幸的是,HelloAndroid 已停止。” 我的代码有错误吗?

package com.example.helloandroid;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class HelloAndroid {

  public static void main(String[] args) {
    JFrame window = new JFrame();
    window.setVisible(true);
    window.setSize(200, 300);

    JLabel text = new JLabel();
    text.setText("Hello");
    text.setForeground(Color.RED);
    window.add(text);
  }

}
4

1 回答 1

2

Android 不支持 Swing/(IIRC) awt 或完整的桌面 Java API。对不起。

于 2012-05-21T05:57:35.773 回答