QQ聊天、带表情、可翻页(Fragment-Activity通讯机制,ViewPager+Fragment+GridView)

这几天在研究QQ表情,闲来无事,从网上下载资源,感觉代码量太大,看的云里雾里,后来果断自己写了一个Demo,虽然功能不全,但是自己体会很深,废话不多说,一步步来把

先看下整体的效果图吧

代码下载地址  http://download.csdn.net/detail/u013210620/8815585

首先看整体界面的布局效果+布局文件吧

布局文件

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <ListView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </ListView>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="#EEE9E9"
        android:gravity="center"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/iv_show"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_marginLeft="5dp"
            android:background="@drawable/selector_show_biaoqing" />

        <EditText
            android:id="@+id/tv_biaoqingkuang"
            android:layout_width="0dp"
            android:layout_height="30dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_weight="1"
            android:background="@drawable/textview_style"
            android:gravity="center_vertical"
            android:hint="选择表情"
            android:inputType="textMultiLine" />

        <TextView
            android:id="@+id/tv_send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:text="发送"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/ll_biaoqing"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:visibility="visible" >

        <android.support.v4.view.ViewPager
            android:id="@+id/biaoqing_viewpager"
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:background="#FFDFD7D7"
            android:visibility="visible" />
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/rl_indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFDFD7D7"
        android:gravity="center" >

        <ImageView
            android:id="@+id/iv_indicator1"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:background="@drawable/flag_online" />

        <!--
        <ImageView
            android:id="@+id/iv_indicator_up1"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_centerVertical="true"
            android:background="@drawable/selector_dot" />
         -->

        <ImageView
            android:id="@+id/iv_indicator2"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_toRightOf="@id/iv_indicator1"
            android:background="@drawable/flag_offline" />
        <!--
         <ImageView
             android:visibility="gone"
             android:layout_toRightOf="@id/iv_indicator_up1"
            android:id="@+id/iv_indicator_up2"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_centerVertical="true"
            android:background="@drawable/flag_online" />

         -->
    </RelativeLayout>

</LinearLayout>

接下来看主布局文件代码

MainActivity.java

package com.example.qqsmiledemo;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.style.ImageSpan;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.qqsmiledemo.MyBiaoQingFragment1.OnArticleSelectedListener;
import com.example.qqsmiledemo.MyBiaoQingFragment2.OnArticleSelectedListener2;

public class MainActivity extends FragmentActivity implements OnClickListener,
		OnArticleSelectedListener, OnArticleSelectedListener2 {

	//切换是否显示表情栏的控件
	private ImageView iv_show;
	//输入、发送表情框控件
	private TextView tv_biaoqingkuang,tv_send;
	//表情框控件
	private LinearLayout ll_biaoqing;
	//viewpager切换时,高亮显示控件
	private RelativeLayout rl_indicator;
	private ImageView iv_indicator1;
	private ImageView iv_indicator2;
	//viewpager
	private ViewPager biaoqing_viewpager;
	//adapter
	private BiaoQingAdapter biaoQingAdapter;

	// 默认表情区域不显示(隐藏状态)
	private boolean isBiaoqingShow = false;
	//目前viewpager所在页面的position
	private int currPos;
	private SpannableStringBuilder spb;

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

	}

	private void initView() {
		iv_show = (ImageView) findViewById(R.id.iv_show);
		tv_biaoqingkuang = (TextView) findViewById(R.id.tv_biaoqingkuang);
		tv_send = (TextView) findViewById(R.id.tv_send);

		ll_biaoqing = (LinearLayout) findViewById(R.id.ll_biaoqing);
		iv_indicator1 = (ImageView) findViewById(R.id.iv_indicator1);
		iv_indicator2 = (ImageView) findViewById(R.id.iv_indicator2);
		rl_indicator = (RelativeLayout) findViewById(R.id.rl_indicator);
		biaoqing_viewpager = (ViewPager) findViewById(R.id.biaoqing_viewpager);
		biaoQingAdapter = new BiaoQingAdapter(getSupportFragmentManager());
		biaoqing_viewpager.setAdapter(biaoQingAdapter);

		// 设置页面改变监听
		biaoqing_viewpager.setOnPageChangeListener(new OnPageChangeListener() {

			@Override
			public void onPageSelected(int position) {
				switch (position) {
				case 0:
					if (currPos == 1) {

						iv_indicator1
								.setBackgroundResource(R.drawable.flag_online);
						iv_indicator2
								.setBackgroundResource(R.drawable.flag_offline);
					}
					break;
				case 1:
					if (currPos == 0) {
						iv_indicator2
								.setBackgroundResource(R.drawable.flag_online);
						iv_indicator1
								.setBackgroundResource(R.drawable.flag_offline);
					}
					break;
				default:
					break;
				}

				currPos = position;
			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {

			}

			@Override
			public void onPageScrollStateChanged(int arg0) {

			}
		});

		iv_show.setOnClickListener(this);
		tv_send.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.iv_show:
			if (!isBiaoqingShow) {
				ll_biaoqing.setVisibility(View.VISIBLE);
				rl_indicator.setVisibility(View.VISIBLE);
				isBiaoqingShow = true;

			} else {
				ll_biaoqing.setVisibility(View.GONE);
				rl_indicator.setVisibility(View.GONE);
				isBiaoqingShow = false;
			}

			break;

		case R.id.tv_send:
			Toast.makeText(MainActivity.this, "聊天界面功能未实现", 0).show();
			break;
		default:
			break;
		}
	}

	//实现接口方法
	@Override
	public void onArticleSelected(int pagePos, int[] imgs, int position) {
		if (pagePos == 0) {
			if (position < imgs.length - 1) {

				spb = new SpannableStringBuilder();
				Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
						imgs[position]);
				bitmap = Bitmap.createScaledBitmap(bitmap, 40, 40, true);
				// imageSpan用来让图片代替字体的
				ImageSpan imageSpan = new ImageSpan(this, bitmap);
				// 用来设置EditText多种样式的类
				SpannableString spanString = new SpannableString("表情");
				// 指定位置替换字体
				spanString.setSpan(imageSpan, 0, spanString.length(),
						Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				spb.append(spanString);
				tv_biaoqingkuang.append(spb);
			} else {
				Toast.makeText(MainActivity.this, "回退删除表情未实现,用系统自带的吧", 0)
						.show();
			}

		} else if (pagePos == 1) {
			if (position < imgs.length - 1) {

				spb = new SpannableStringBuilder();
				Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
						imgs[position]);
				bitmap = Bitmap.createScaledBitmap(bitmap, 40, 40, true);
				ImageSpan imageSpan = new ImageSpan(this, bitmap);

				SpannableString spanString = new SpannableString("表情");
				spanString.setSpan(imageSpan, 0, spanString.length(),
						Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				spb.append(spanString);
				tv_biaoqingkuang.append(spb);
			} else {
				Toast.makeText(MainActivity.this, "回退删除表情未实现,用系统自带的吧", 0)
						.show();

			}

		}

	}

}

接下来看BiaoQingAdapter

package com.example.qqsmiledemo;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class BiaoQingAdapter extends FragmentPagerAdapter {

private List<Fragment> Filmfragments = new ArrayList<>();

	public BiaoQingAdapter(FragmentManager fm) {
		super(fm);
		Filmfragments.add(new MyBiaoQingFragment1());
		Filmfragments.add(new MyBiaoQingFragment2());
	}

	@Override
	public Fragment getItem(int pos) {
		return Filmfragments.get(pos);
	}

	@Override
	public int getCount() {
		return Filmfragments.size();
	}

}

接下来看2个Fragment

MyBiaoQingFragment1

package com.example.qqsmiledemo;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class MyBiaoQingFragment1 extends Fragment {
	private View biaoqing1View;
	private GridView gv_biaoqing1;
	private BiaoQingFragment1Adapter biaoQingFragment1Adapter;

	private OnArticleSelectedListener mListener;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		biaoqing1View = View.inflate(getActivity(), R.layout.biaoqing1, null);
		initView();
		return biaoqing1View;
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);

		try {
			//强转换
			mListener = (OnArticleSelectedListener) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ "must implement OnArticleSelectedListener");
		}
	}

	private void initView() {
		gv_biaoqing1 = (GridView) biaoqing1View.findViewById(R.id.gv_biaoqing1);
		biaoQingFragment1Adapter = new BiaoQingFragment1Adapter(getActivity());
		gv_biaoqing1.setAdapter(biaoQingFragment1Adapter);

		gv_biaoqing1.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// 每个条目的点击监听事件

				mListener.onArticleSelected(0,imgs, position);
			}

		});
	}

	private int[] imgs = { R.drawable.emoji_0, R.drawable.emoji_1,
			R.drawable.emoji_2, R.drawable.emoji_3, R.drawable.emoji_4,
			R.drawable.emoji_5, R.drawable.emoji_6, R.drawable.emoji_7,
			R.drawable.emoji_8, R.drawable.emoji_9, R.drawable.emoji_10,
			R.drawable.emoji_11, R.drawable.emoji_12, R.drawable.emoji_13,
			R.drawable.emoji_14, R.drawable.emoji_15, R.drawable.emoji_16,
			R.drawable.emoji_17, R.drawable.emoji_18, R.drawable.emoji_19,
			R.drawable.top_return_n,

	};

	class BiaoQingFragment1Adapter extends BaseAdapter {
		private Context context;

		BiaoQingFragment1Adapter(Context context) {
			this.context = context;
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return imgs.length;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return imgs[position];
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View view = View.inflate(context, R.layout.picture_item, null);
			ImageView imageView = (ImageView) view.findViewById(R.id.image);
			imageView.setBackgroundResource(imgs[position]);
			return view;
		}

	}

	/**
	 * 回调接口--每个表情被选中调用接口
	 *
	 */
	public interface OnArticleSelectedListener {
		public void onArticleSelected(int pagePos,int[] imgs, int position);
	}
}

MyBiaoQingFragment2

package com.example.qqsmiledemo;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class MyBiaoQingFragment2 extends Fragment {
	private View biaoqing2View;
	private GridView gv_biaoqing2;
	private BiaoQingFragment2Adapter biaoQingFragment2Adapter;
	private OnArticleSelectedListener2 mListener;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		biaoqing2View = View.inflate(getActivity(), R.layout.biaoqing2, null);
		initView();
		return biaoqing2View;
	}
	private void initView() {
		gv_biaoqing2 = (GridView) biaoqing2View.findViewById(R.id.gv_biaoqing2);
		biaoQingFragment2Adapter = new BiaoQingFragment2Adapter(getActivity());
		gv_biaoqing2.setAdapter(biaoQingFragment2Adapter);

		gv_biaoqing2.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				mListener.onArticleSelected(1,imgs, position);
			}

		});
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			mListener = (OnArticleSelectedListener2) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ "must implement OnArticleSelectedListener");
		}
	}
	private int[] imgs = {
			R.drawable.emoji_20, R.drawable.emoji_21, R.drawable.emoji_22,
			R.drawable.emoji_23, R.drawable.emoji_24, R.drawable.emoji_25,
			R.drawable.emoji_26, R.drawable.emoji_27, R.drawable.emoji_28,
			R.drawable.emoji_29, R.drawable.emoji_30, R.drawable.emoji_31,
			R.drawable.emoji_32, R.drawable.emoji_33, R.drawable.emoji_34,
			R.drawable.top_return_n,  

	};
	class BiaoQingFragment2Adapter extends BaseAdapter{
		private Context context;

		BiaoQingFragment2Adapter(Context context){
			this.context = context;
		}
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return imgs.length;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return imgs[position];
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View view = View.inflate(context, R.layout.picture_item, null);
			ImageView imageView = (ImageView) view.findViewById(R.id.image);
			imageView.setBackgroundResource(imgs[position]);
			return view;
		}

	}

	public interface OnArticleSelectedListener2 {
		public void onArticleSelected(int pagePos,int[] imgs, int position);
	}
}

然后还有2个Fragment的布局文件

biaoqing1.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <GridView
        android:padding="10dp"
        android:id="@+id/gv_biaoqing1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

        android:columnWidth="35dp"
        android:gravity="center"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"

        android:horizontalSpacing="10dp"
        android:verticalSpacing="10dp" >
    </GridView>	

</LinearLayout>

biaoqing2.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <GridView
        android:padding="10dp"
        android:id="@+id/gv_biaoqing2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

        android:columnWidth="35dp"
        android:gravity="center"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"

        android:horizontalSpacing="10dp"
        android:verticalSpacing="10dp" >
    </GridView>	

</LinearLayout>

另外GridView里面的每个Item

picture_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/image"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_gravity="center"
        android:padding="4dp"
        android:scaleType="fitXY" />

</LinearLayout>

另外还有那个输入表情的文本框的圆角布局文件

selector_show_biaoqing.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_pressed="true" android:drawable="@drawable/ic_open_emoji_pressed"/>
    <item android:state_pressed="false" android:drawable="@drawable/ic_open_emoji_unpress"/>
    <item android:drawable="@drawable/ic_open_emoji_unpress"/>
</selector>

textview_style.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <solid android:color="#ffffff" />
    <corners android:radius="5dp" />
      <padding
          	android:left="0dp"
          	android:top="0dp"
          	android:right="0dp"
          	android:bottom="0dp" />
</shape>
时间: 2024-10-09 20:08:52

QQ聊天、带表情、可翻页(Fragment-Activity通讯机制,ViewPager+Fragment+GridView)的相关文章

Android UI【android 仿微信、QQ聊天,带表情,可翻页,带翻页拖动缓冲】

http://blog.csdn.net/lnb333666/article/details/8546497 如题,这是公司项目的一个功能模块,先上个效果图: 其次大致说说原理: 1,首先判断输入的字符,是否包含表情的文字,比如   这个表情对应的文件名为 emoji_1.png,它对应的文字描述 :[可爱],如果我们在输出的是输出这么一句话:老婆,我想你了.  那么我们对应的根本文字就是:老婆,我想你了[可爱]. 2,具体的转换过程就是用正则表达式比配文字中是否含有[xxx]这类的文字,如果有

Android 聊天表情输入、表情翻页带效果、下拉刷新聊天记录

经过一个星期的折腾,终于做完了这个Android 聊天表情输入.表情翻页带效果.下拉刷新聊天记录.这只是一个单独聊天表情的输入,以及聊天的效果实现.因为我没有写服务器,所以没有双方聊天的效果.主要是聊天中表情的选择,发送.表情翻页带有不同的效果.我在主要代码中都写了注释.下面看代码实现.附上本文源码,代码较多. 下载地址:点击 一.先看实现的效果图 二.调用接口以及设置MainActivity package com.example.activity; import java.util.Arra

Android特效专辑(六)——仿QQ聊天撒花特效,无形装逼,最为致命

Android特效专辑(六)--仿QQ聊天撒花特效,无形装逼,最为致命 我的关于特效的专辑已经在CSDN上申请了一个专栏--http://blog.csdn.net/column/details/liuguilin.html 日后我所写的特效专辑也会以一添加在这个专栏上,今天写的这个特效,是关于聊天的,你肯定遇到过,就是你跟人家聊天的时候,比如发送应(么么哒),然后屏幕上全部就是表情了,今天我们就是做这个,撒花的特效,国际惯例,上图 截图 实现这样的效果,你要知道贝塞尔曲线,何谓贝塞尔曲线?其实

QQ聊天界面的输入法顶起界面底部输入框效果的实现

转载请注明:http://www.cnblogs.com/frank-zouxu/p/4127115.html 今天在公司做项目的时候遇到一个需求:需要做一个界面,效果类似QQ聊天界面,如图1,当我们点击内容输入框准备输入内容的时候,底部的表情框的那一栏会被输入法的软键盘给顶起来,默认状态下,输入法会覆盖掉我们的表情输入框.起初,百思不得解的我费尽了心思,未果,偶然看到此篇博客http://blog.csdn.net/twoicewoo/article/details/7384398.其实,欲达

qq聊天机器人 群发工具 (java版) (三)

本篇简单讲解一下如何接收QQ消息. 在成功登陆QQ后,要每隔一段时间发一个POST请求,用来维持登陆状态,同时也是用来接收消息的,请求如下: Request URL:http://d.web2.qq.com/channel/poll2 Request Method:POST Content-Type:application/x-www-form-urlencoded Referer:http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&a

仿QQ聊天软件2.0版

仿QQ聊天软件2.0版 转载请标明出处:牟尼的专栏 http://blog.csdn.net/u012027907     上次课设做了Java版的仿QQ聊天程序,这次软件实训,我们继续完善了仿QQ聊天程序,将上次未完成及不完善的地方进行完善和改进,还新加了部分功能:表情输入.气泡模式.文件传输.截屏.语音聊天.逐步向QQ的基本功能靠齐.通过这次软件实训,又有了很多收获. 一.设计内容及要求 1.1综述 A.系统概述 我们要做的就是类似QQ这样的面向企业内部的聊天软件,基本功能和QQ类似.首先,

Objective-c——UI基础开发第八天(QQ聊天界面)

一.知识点: QQ聊天界面 双模型的使用(dataModel和frameModel) UITextField的使用 通知的使用 拉伸图片的两种方法(slicing/image对象的resizeableImageWithCapInsets属性) 枚举 方法的抽取(相同的拿出,不同的部分作为参数) 二.设置tableview的基本格式 1)定义tableview基本 numberOfSectionsInTableView:设置块 numberOfRowsInSection:设置每块对应的行数 cel

QQ聊天原理初识

1:qq之间文件的传输是通过p2p通信进行的. 2:qq之间的表情发送实际上就是文字的发送,是client再接受到文字之后在本地自己进行转换 3:qq之间的通信既能够通过udp也能够通过Tcp 尽管udp数据传输的时候数据可能会丢失,可是腾讯公司做了对应的操作,保证的数据传输的稳定性.主要用udp是由于udp传输效率高. 同一时候qq发送消息不是点对点的是client-server-client.由于qq须要查询消息记录. 4:两个局域网之间的p2p通信是有一定难度的 iOS QQ推送聊天原理

亲身体验用Java写的仿qq聊天界面

Java开发工具有许多种,新手用记事本写Java程序,有些人用NetBean,jbuilder,高手用eclipse,下面介绍用eclipse开发qq聊天界面. 代码如下: package Myjava_QQ; import java.awt.*; import javax.swing.*; import Myjava_QQ.truess; import java.awt.event.*; import java.applet.*; import java.io.BufferedReader;