Eclipse,创建Android项目,不会导入javax.swing

时间:2014-02-15 23:51:37

标签: java android eclipse swing netbeans

我通常使用eclipse或NetBeans创建Android应用程序但是当我尝试按下按钮时创建消息框时,Eclipse在这种情况下不会导入javax.swing

activity_main.xml中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="136dp"
        android:text="Button" />

</RelativeLayout>

MainActivity.java:

package com.example.understanding;

import android.os.Bundle;
import android.app.Activity;
import javax.swing;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {



      private void button1_ButtonActionPerformed(View v) {
          JOptionPane.showMessageDialog(null, "Enter Account Details");
      }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

1 个答案:

答案 0 :(得分:1)

Android和is not part of the Android SDK上不存在

javax.swing