u014341580
SomeAody
2015-03-09 02:14

JAVA程序的执行入口怎么看?

  • jdk
  • adt
  • java
  • android

我用ADT新建了一个工程,默认的有一个叫MainActivity.java的文档:

 package com.example.m_note0305;

import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;


public class MainActivity extends ActionBarActivity {

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

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
    }

    @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;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }

}

然后我用网上COPY的代码又新建了一个文档SlNotepad.java:

 package com.example.m_note0305;//把SlNotepad类纳入到m_note0305包内

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import javax.swing.event.*;
import java.util.*;
import java.awt.datatransfer.*;

class text implements Serializable{
    /**/
    private static final long serialVersionUID = -5303411698842652024L;//序列化版本对象控制
    String keyword;//密码
    String textmain;//文本部分
}
public class SlNotepad extends JFrame implements ActionListener,ListSelectionListener{//公共类名必须和文件名一致
    /**/
    private static final long serialVersionUID = -1229804758759177927L;
    //extends表示继承
    MenuBar bar;//菜单栏
    Menu file,edit,format,help;
    MenuItem open,dsave,save,newwork,quit,about,fontchoose,colorchoose,backchoose,timeadd,keyopen,keysave,zcancel,copy,paste,cut,delete,selectall,search,autoline;
    MenuShortcut opencut,dsavecut,savecut,newworkcut,quitcut,aboutcut,fontchoosecut,colorchoosecut,backchoosecut,timeaddcut,keyopencut,keysavecut,zcancelcut,copycut,pastecut,cutcut,deletecut,selectallcut,searchcut,autolinecut;

    Toolkit tool=this.getToolkit();
    Clipboard clip;//剪贴版
    Image image=tool.getImage("data/icon.jpg");//框架图标
    JTextArea textarea;//文本区域

    //此处省略一万字

public static void main(String[] args){
        SlNotepad SlNotepad=new SlNotepad("亮亮记事本1.0正式版");
        SlNotepad.setVisible(true);//show();
    }
}

程序跑起来的效果是,就仿佛后面的文档不存在一样。
MainActivity.java里面没有main函数啊,它是怎样开始执行的?
我不知道怎样把自定义的那个记事本类型用起来,求大神指点~~

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答

为你推荐

换一换