你的分享就是我们的动力 ---﹥

Bus Stop Reminder

时间:2013-06-07 15:56来源:www.chengxuyuans.com 点击:

代码简介

Simple bus stop reminder toolkit.

代码片段

package buser;

import java.awt.*;
import java.awt.event.*;
import java.io.IOException;

import javax.swing.*;
import javax.accessibility.*;

public class Buser extends JFrame implements ActionListener, Accessible {

	private static final long serialVersionUID = 1L;
	JPanel p1 = new JPanel();
	JButton b1 = new JButton("Spring Garden Road"), b2 = new JButton("Dalhousie Terminal");
	Box box = Box.createVerticalBox();

	public Buser() {
		super();
		p1.add(box);
		box.add(b1);
		box.add(new JSeparator());
		box.add(b2);
		add(p1, BorderLayout.CENTER);
		b1.addActionListener(this);
		b2.addActionListener(this);
		validate();
		setTitle("Bus Stop Reminder v1.0");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(200, 100);
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == b1) {
			System.out.println("This stop: Spring Garden Road!");
			try {
				Runtime.getRuntime().exec(
						"cmd.exe /c start C:\\Users\\Sam\\Desktop\\SGR.wav");
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}

		if (e.getSource() == b2) {
			System.out.println("This stop: Dalhousie Terminal!");
			try {
				Runtime.getRuntime().exec(
						"cmd.exe /c start C:\\Users\\Sam\\Desktop\\DT.wav");
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		
	}

	public static void main(String[] args) {

		Buser test = new Buser();

	}
}

转载注明地址:http://www.chengxuyuans.com/code/android/64199.html