怎把java代码变成android代码,该怎么解决

怎把java代码变成android代码
将eclipse下的java代码换成android虚拟机下的代码,代码如下:
JFrame frame = new JFrame();
  JPanel contentPane;
  BorderLayout borderLayout = new BorderLayout();  
  GridLayout gridLayout = new GridLayout(3,1);  
  Panel panel0 = new Panel(); //存放panel1,panel2,panel3
  Panel panel1 = new Panel(); //存放输入的服务器地址
  Panel panel2 = new Panel(); //存放输入的姓名和连接两个按钮
  Panel panel3 = new Panel(); //存放发送信息区域
  Panel panel4 = new Panel(); //存放聊天信息和聊天成员
  Panel panel5 = new Panel(); 
  Label label1 = new Label();
  
  TextField add_txt = new TextField(36);
  Label label2 = new Label();
  TextField name_txt = new TextField(20);
  Button button1 = new Button();
  Button button2 = new Button();
  Label label3 = new Label();
  TextField msg_txt = new TextField(30);
  Button button3 = new Button();
  TextArea chat_txt = new TextArea(15,30);
  java.awt.List list1 = new java.awt.List(16);
  
 
  Socket soc=null; //定义连接套接字
  DataInputStream dis=null; //定义用来实现客户端接受服务器数据的输入流
  DataOutputStream dos=null; //定义用来实现从客户端发送数据到服务器的输出流
  Thread client=null; //定义一个客户端线程

  public ChatClient() //初始化图形界面
  {
  frame.setTitle("客户端");
  contentPane = (JPanel) frame.getContentPane();
  contentPane.setLayout(borderLayout);
  panel0.setLayout(gridLayout);
  label1.setText("服务器地址:");
  add_txt.setText("localhost");
  panel1.add(label1);
  panel1.add(add_txt);
  panel1.setBackground(Color.orange);
  panel0.add(panel1);
  label2.setText("\u8F66 \u8F86 \u540D \u79F0\uFF1A");  
  button1.setBackground(Color.GREEN);
  button1.setLabel("连接");
  button2.setBackground(Color.RED);
  button2.setLabel("断开连接");
  panel2.add(label2);
  name_txt.setText("");
  panel2.add(name_txt);
  panel2.add(button1);
  panel2.add(button2);
  panel2.setBackground(Color.orange);
  panel0.add(panel2);
  label3.setText("\u8C03 \u5EA6 \u5185 \u5BB9\uFF1A");
  button3.setBackground(Color.CYAN);
  button3.setLabel("发送");
  panel3.add(label3);
  panel3.add(msg_txt);
  panel3.add(button3);
  panel3.setBackground(Color.orange);
  panel0.add(panel3);
  panel0.setBackground(Color.ORANGE);
  contentPane.add(panel0, BorderLayout.NORTH);
  chat_txt.setBackground(Color.PINK);
  chat_txt.setEditable(false);
  panel4.add(chat_txt);
  list1.setBackground(Color.GRAY);
  panel4.add(list1);
  panel4.setBackground(Color.orange);
  contentPane.add(panel4, BorderLayout.SOUTH);
  panel5.setBackground(Color.orange);
  contentPane.add(panel5, BorderLayout.CENTER);
  ButtonAction buttonaction = new ButtonAction();
  button1.addActionListener(buttonaction);
  button2.addActionListener(buttonaction);
  button3.addActionListener(buttonaction);
  frame.setSize(450,380); 
  frame.setResizable(false); 
  frame.addWindowListener(new WindowAdapter()
  { public void windowClosing(WindowEvent e)
  { disconnect();
  //System.exit(0);
  dispose();
  }
  });