import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import javax.swing.Timer;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.SwingConstants;
import java.awt.GridBagLayout;
public class TaxiMain extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jTitle = null;
private JLabel jStatement = null;
private JLabel jSpeed = null;
private JLabel jSpeed1 = null;
public static JLabel jS = null;
public static JLabel jS1 = null;
private JLabel jRunStatement = null;
private JLabel jRunStatement1 = null;
private JRadioButton jOn = null;
private JRadioButton jOff = null;
public static JLabel jTotalPrice = null;
private JButton jStart = null;
private JButton jStop = null;
private JRadioButton jDaytime = null;
private JRadioButton jNight = null;
private JLabel jPrice = null;
public static JLabel jPrice1 = null;
JLabel jWait = null;
public static JLabel jWait1 = null;
private JButton jRedLight1 = null;
private JButton jGreenLight1 = null;
private JLabel jCurrentTime = null;
private JLabel jCurrentTime1 = null;
public Timeprinter tp=null;
public MileThread mt=null;
public ToPriceThread tpt=null;
public static boolean flag3=true;
public Queue q=null;
public static boolean isRuning1=true;
public static boolean isRuning2=false;
public static int time=0;
private JPanel jPanel = null;
private JLabel jMove = null;
// @jve:decl-index=0:
private JRadioButton getJOn() {
if (jOn == null) {
jOn = new JRadioButton();
jOn.setBounds(new Rectangle(23, 272, 72, 31));
jOn.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jOn.setForeground(Color.black);
jOn.setText("上客");
jOn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(jOn.isSelected())
{
jStatement.setText("载客");
if(jDaytime.isSelected())
{
jTotalPrice.setText("5.0");
}
else if(jNight.isSelected())
{
jTotalPrice.setText("6.0");
}
}
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
}
});
}
return jOn;
}
private JRadioButton getJOff() {
if (jOff == null) {
jOff = new JRadioButton();
jOff.setBounds(new Rectangle(100, 272, 72, 31));
jOff.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jOff.setForeground(Color.black);
jOff.setText("下客 ");
jOff.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(jOff.isSelected())
{
jStatement.setText("空车");
jTotalPrice.setText("0.00");
jS1.setText("0.00");
}
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
}
});
}
return jOff;
}
private JButton getJStart() {
if (jStart == null) {
jStart = new JButton();
jStart.setBounds(new Rectangle(193, 274, 71, 29));
jStart.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jStart.setForeground(Color.black);
jStart.setText("启动");
jStart.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent e) {
jStart.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
public void mouseClicked(java.awt.event.MouseEvent e) {
jGreenLight1.setEnabled(true);
jRedLight1.setEnabled(true);
jStart.setEnabled(false);
jStop.setEnabled(true);
jRunStatement1.setText("开车");
jSpeed1.setText("80km/h");
if(jOn.isSelected())
{
q=new Queue();
q.setQ(q);
mt=new MileThread(q);
mt.setMt(mt);
mt.start();
tpt=new ToPriceThread(q);
tpt.setTpt(tpt);
tpt.start();
}
else
{
jStart.setEnabled(true);
}
}
});
}
return jStart;
}
private JButton getJStop() {
if (jStop == null) {
jStop = new JButton();
jStop.setBounds(new Rectangle(280, 274, 71, 29));
jStop.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jStop.setForeground(Color.black);
jStop.setText("停车");
jStop.setEnabled(false);
jStop.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent e) {
jStop.setCursor(new Cursor(Cursor.HAND_CURSOR));
System.out.println("mouseEntered()"); // TODO Auto-generated Event stub mouseEntered()
}
public void mouseClicked(java.awt.event.MouseEvent e) {
jGreenLight1.setEnabled(false);
jRedLight1.setEnabled(false);
jStop.setEnabled(false);
jStart.setEnabled(true);
mt.stopMile();
tpt.stopPrice();
//String.for
double mon=Double.parseDouble(TaxiMain.jTotalPrice.getText());
double tip=Double.parseDouble((TaxiMain.jWait1.getText()))*0.25;
TaxiMain.jTotalPrice.setText(String.valueOf(mon+tip));
jRunStatement1.setText("停车");
TaxiMain.jWait1.setText("0s");
jSpeed1.setText("0km/h");
}
});
}
return jStop;
}
private JRadioButton getJDaytime() {
if (jDaytime == null) {
jDaytime = new JRadioButton("白天",true);
jDaytime.setBounds(new Rectangle(365, 275, 66, 28));
jDaytime.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jDaytime.setForeground(Color.black);
jDaytime.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(jDaytime.isSelected())
{
jPrice1.setText("5元/公里");
}
if(jOn.isSelected())
{
if(jDaytime.isSelected())
{
jTotalPrice.setText("5.0");
}
}
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
}
});
}
return jDaytime;
}
private JRadioButton getJNight() {
if (jNight == null) {
jNight = new JRadioButton();
jNight.setBounds(new Rectangle(434, 275, 66, 28));
jNight.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jNight.setForeground(Color.black);
jNight.setText("晚上");
jNight.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(jNight.isSelected())
{
if(jOn.isSelected())
{
jTotalPrice.setText("6.0");
}
}
if(jNight.isSelected())
{
jPrice1.setText("7元/公里");
}
}
});
}
return jNight;
}
private JButton getJRedLight1() {
if (jRedLight1 == null) {
jRedLight1 = new JButton();
jRedLight1.setBounds(new Rectangle(191, 87, 71, 33));
jRedLight1.setFont(new Font("\u6977\u4f53_GB2312", Font.BOLD, 14));
jRedLight1.setForeground(Color.black);
jRedLight1.setText("红灯");
jRedLight1.setEnabled(false);
jRedLight1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent e) {
jRedLight1.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
public void mouseClicked(java.awt.event.MouseEvent e) {
q=q.getQ();
tp=new Timeprinter(q);
//if(TaxiMain.flag3)
//{
System.out.println("aaaaaa");
tp.start();
//}
tp.startTime();
tp.setTp(tp);
q.setQ(q);
mt=mt.getMt();
mt.suspend();
mt.setMt(mt);
tpt=tpt.getTpt();
//tpt.stopPrice();
//tpt.setTpt(tpt);
//tpt.suspend();
jRedLight1.setEnabled
评论4
最新资源