新浪微博数据采集界面

package cc.home.chy.Main;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 * 
 * @author Administrator
 * 
 */
public class MainJFrame extends JFrame {
	static int event;
	static String access_token;
	String message = "";
	static String str;// 原始数据
	static String UserId;// 指定对象的id
	static String[] strArr = new String[] { "",
			"statuses/public_timeline.json",
			"trends/weekly.json", "statuses/friends_timeline.json",
			"friendships/friends/ids.json" };
	JPanel p1, p2, p3;// 建立3个面板
	static JTextArea ta = new JTextArea(18, 58);
	static JTextArea tr = new JTextArea(18, 58);
	// static JTextField juserId = new JTextField();
	JButton btn1, btn2, btn3;
	JLabel be;
	@SuppressWarnings("rawtypes")
	JComboBox combo;// 下拉框
	private static final long serialVersionUID = 1L;

	public MainJFrame(String title) {
		super(title);
		initUI();
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	private void initUI() {
		this.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
		ta.setText("采集到的新浪微博原始数据:");
		JScrollPane ps = new JScrollPane(ta);
		combo = new JComboBox(strArr);
		combo.setEditable(true);
		combo.addItemListener(new MyItemListener());// 添加事件

		p1 = new JPanel();
		be = new JLabel();
		be.setText("Method(可选&可填):");
		p1.add(be);
		p1.add(combo);
		btn1 = new JButton("invoke");
		btn1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				if (event == 1) {
					message = GetData.GetMsgFromSina(event).toString();
				} else if (event == 2) {
					message = GetData.GetMsgFromSina(event).toString();
				} else if(event==3){
					message = GetData.GetMsgFromSina(event).toString();
				} else if (event == 4) {
					message = GetData.GetMsgFromWeb(event, "true").toString();
				} else {
					// BigInteger uid = new BigInteger(UserId);
					// Double uid = Double.parseDouble(UserId);
					message = GetData.GetMsgFromWeb(5, UserId).toString();
				}
				ta.setText(message);
			}
		});
		btn2 = new JButton("stop");
		btn2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {


			}

		});

		btn1.setSize(20, 10);
		p1.add(btn1);
		p1.add(btn2);
		this.add(p1);

		p2 = new JPanel();
		p2.add(ps);
		p2.setBackground(Color.PINK);
		p2.setSize(200, 100);
		this.add(p2);

		p3 = new JPanel();
		p3.add(tr);
		p3.setBackground(Color.GREEN);
		p3.setSize(200, 100);
		this.add(p3);

		this.setBounds(50, 0, 400, 600);
		this.setSize(680, 700);
		this.setResizable(false);// 窗口大小不可改变
		this.setBackground(Color.black);
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	static class MyItemListener implements ItemListener {

		@Override
		public void itemStateChanged(ItemEvent e) {
			@SuppressWarnings("rawtypes")
			JComboBox cb = (JComboBox) e.getSource();
			String clr = (String) cb.getSelectedItem();// 取得被选中事件选项的名称
			if (clr == strArr[1]) {
				System.out.println("clr->str[0]--------->" + clr);
				event = 1;
			} else if (clr == strArr[2]) {
				System.out.println("clr->str[1]--------->" + clr);
				event = 2;
			} else if (clr == strArr[3]) {
				System.out.println("clr->str[2]--------->" + clr);
				event = 3;
			} else if (clr == strArr[4]) {
				System.out.println("clr->str[3]--------->" + clr);
				event = 4;
			} else {
				UserId = clr;// 用户填写指定对象的id
				System.out.println("clr->str[5]--------->" + clr);
			}
		}
	}

	public static void main(String args[]) {
		new MainJFrame("微博数据采集");

	}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值