clientframe.java~539~

来自「济南公交管理系统 (不完善,没有解决循环线路问题)」· JAVA~539~ 代码 · 共 1,302 行 · 第 1/4 页

JAVA~539~
1,302
字号
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.io.*;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.*;
import java.text.*;
import java.sql.Time;
import java.util.Vector;
import javax.swing.table.*;

public class clientFrame
    extends JFrame {
  busSearch bs = new busSearch(); //声明公交查询类的一个对象
  connectDB con = new connectDB(); //声明连接数据库类的一个对象
  JPanel contentPane;

  JMenuBar jMenuBar1 = new JMenuBar(); //菜单
  JMenu jMenu1 = new JMenu();
  JMenu jMenu3 = new JMenu();
  JMenuItem jMenuItem1 = new JMenuItem();
  JMenuItem jMenuItem2 = new JMenuItem();
  JMenuItem jMenuItem6 = new JMenuItem();

  JTabbedPane jTabbedPane1 = new JTabbedPane(); //有选项卡的容器
  JPanel jPanel1 = new JPanel();
  JPanel jPanel2 = new JPanel();
  JPanel jPanel3 = new JPanel();
  JPanel jPanel4 = new JPanel();
  JPanel jPanel5 = new JPanel();
  JPanel jPanel6 = new JPanel();
  JPanel jPanel7 = new JPanel();
  JPanel jPanel8 = new JPanel();

  JPanel jPanel9 = new JPanel();
  JTextField jTextField1 = new JTextField();
  JTextField jTextField4 = new JTextField();

  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JButton jButton3 = new JButton();

  JTextArea jTextArea1 = new JTextArea();
  JTextArea jTextArea2 = new JTextArea();
  JTextArea jTextArea3 = new JTextArea();
  JTextArea jTextArea4 = new JTextArea();
  JTextArea jTextArea5 = new JTextArea();
  JTextArea jTextArea6 = new JTextArea();

  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JLabel jLabel5 = new JLabel();
  JLabel jLabel6 = new JLabel();
  JLabel jLabel7 = new JLabel();
  JLabel jLabel8 = new JLabel();
  JLabel jLabel9 = new JLabel();
  JLabel jLabel10 = new JLabel();
  JLabel jLabel11 = new JLabel();
  JLabel jLabel12 = new JLabel();
  JLabel jLabel13 = new JLabel();
  JLabel jLabel14 = new JLabel();
  JLabel jLabel15 = new JLabel();
  JLabel jLabel16 = new JLabel();
  JLabel jLabel17 = new JLabel();
  JLabel jLabel18 = new JLabel();
  JLabel jLabel19 = new JLabel();

  JScrollPane jScrollPane1 = new JScrollPane();
  JScrollPane jScrollPane2 = new JScrollPane();
  JScrollPane jScrollPane3 = new JScrollPane();
  JScrollPane jScrollPane4 = new JScrollPane();

  JComboBox jComboBox1 = new JComboBox();
  JComboBox jComboBox2 = new JComboBox();
//******************************************************//
//*******************时间线程****************************//
  class timeThread
      extends Thread { //功能:求出当前时间
    String s3; //系统当前long日期
    String s4; //系统当前full日期
    String week; //星期
    String currenttime; //当前时间
    public void run() {
      while (true) {
        Date now = new Date();
        DateFormat df3 = DateFormat.getDateInstance(DateFormat.LONG);
        DateFormat df4 = DateFormat.getDateInstance(DateFormat.FULL);
        s3 = df3.format(now); //long日期
        s4 = df4.format(now); //full日期
        week = s4.substring(s3.length(), s4.length()); //星期
        String s = now.toString();
        currenttime = s.substring(11, 19); //时间
        jTextArea5.setText("    " + s3 + " \n" + "         " + week + "\n " +
                           "      " + currenttime); //显示当前时间
        try {
          sleep(1000);
        }
        catch (Exception e) {}
      }
    }
  }

//Construct the frame
  public clientFrame() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

//****************************************************************************//
  String helpline = null; //help文件中每一行的内容
  String helptxt = ""; //help文件的内容
  public void readhelp() { //功能:读出文件help的内容
    try {
      BufferedReader br = new BufferedReader(new FileReader("help.txt")); //输入流
      helpline = br.readLine(); //读文件中的一行
      while (helpline != null) { //判断文件内容是否为空,不为空进行循环
        helptxt = helptxt + helpline + "\n"; //文件内容加上一行
        helpline = br.readLine(); //读文件中的一行
      }
      br.close(); //关闭输入流
    }
    catch (IOException e) {
      System.out.println(e);
    }
  }

//****************************************************************************//
//****************************************************************************//
  String jnbusline = null; //公交公司资料中的一行
  String jnbustxt = "";
  JLabel jLabel20 = new JLabel();
  JButton jButton4 = new JButton();
  JButton jButton5 = new JButton();
  JButton jButton6 = new JButton();
  JButton jButton7 = new JButton();
  JLabel jLabel21 = new JLabel();
  JLabel jLabel22 = new JLabel();
  JLabel jLabel23 = new JLabel();
  JPanel jPanel10 = new JPanel();
  JPanel jPanel11 = new JPanel();
  JPanel jPanel12 = new JPanel();
  JPanel jPanel13 = new JPanel();
  JScrollPane jScrollPane5 = new JScrollPane();
  JTextArea jTextArea7 = new JTextArea();
  JScrollPane jScrollPane6 = new JScrollPane();
  JScrollPane jScrollPane7 = new JScrollPane();
  JScrollPane jScrollPane8 = new JScrollPane();
  JTextArea jTextArea8 = new JTextArea();
  JTextArea jTextArea9 = new JTextArea();
  JTextArea jTextArea10 = new JTextArea();
  //公交公司资料内容
  public void readjnbus() { //读取济南公交公司资料,读出文件jnbus的内容
    try {
      BufferedReader br1 = new BufferedReader(new FileReader("jnbus.txt"));
      jnbusline = br1.readLine();
      while (jnbusline != null) {
        jnbustxt = jnbustxt + jnbusline + "\n";
        jnbusline = br1.readLine();
      }
      br1.close();
    }
    catch (IOException e) {
      System.out.println(e);
    }
  }

//****************************************************************************//
//****************************************************************************//
  //Component initialization
  private void jbInit() throws Exception {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch (Exception ee) {
      ee.printStackTrace();
    }
    timeThread time = new timeThread(); //时间线程一个对象
    time.start(); //启动时间线程
    con.connectDb("jnbus"); //连接数据库
    contentPane = (JPanel)this.getContentPane();
    contentPane.setLayout(null);
    this.setResizable(false); //窗口大小不可改变
    this.setSize(new Dimension(500, 400)); //设置窗口大小
    this.setTitle("济南公交查询系统");

    jMenu1.setText("文件");
    jMenuItem1.setText("管理");
    jMenuItem1.addActionListener(new clientFrame_jMenuItem1_actionAdapter(this));
    jMenuItem2.setText("退出");
    jMenuItem2.addActionListener(new clientFrame_jMenuItem2_actionAdapter(this));
    jMenu3.setText("帮助");
    jMenuItem6.setText("关于系统");
    jMenuItem6.addActionListener(new clientFrame_jMenuItem6_actionAdapter(this));

    jPanel1.setBackground(Color.gray);
    jPanel1.setBounds(new Rectangle(0, 0, 500, 60));
    jPanel2.setBackground(SystemColor.inactiveCaption);
    jPanel2.setBounds(new Rectangle(0, 60, 500, 340));
    jPanel1.setLayout(null);
    jPanel2.setLayout(null);
    jPanel5.setLayout(null);
    jPanel6.setLayout(null);
    jPanel7.setLayout(null);

    /**********************************************************/
    /******************站点查询面板初始化************************/
    jPanel3.setLayout(null);
    jPanel3.setBackground(SystemColor.inactiveCaptionText);
    jPanel3.setAlignmentX( (float) 0.5);

    jTextField1.setBackground(Color.white);
    jTextField1.setFont(new java.awt.Font("Dialog", 0, 15));
    jTextField1.setForeground(SystemColor.activeCaption);
    jTextField1.setBorder(BorderFactory.createLineBorder(Color.black));
    jTextField1.setText("");
    jTextField1.setBounds(new Rectangle(177, 30, 120, 27));

    jButton1.setBackground(Color.white);
    jButton1.setBounds(new Rectangle(240, 60, 46, 21));
    jButton1.setFont(new java.awt.Font("Serif", 1, 16));
    jButton1.setForeground(Color.black);
    jButton1.setBorder(null);
    jButton1.setBorderPainted(true);
    jButton1.setContentAreaFilled(true);
    jButton1.setText("");
    ImageIcon button = new ImageIcon("picture/button.gif");
    jButton1.setIcon(button);
    jButton1.addActionListener(new clientFrame_jButton1_actionAdapter(this));

    jTextArea1.setBackground(SystemColor.activeCaptionText);
    jTextArea1.setFont(new java.awt.Font("Dialog", 0, 14));
    jTextArea1.setForeground(SystemColor.activeCaption);
    jTextArea1.setEditable(false);
    jTextArea1.setText("");

    jLabel1.setBounds(new Rectangle(0, 0, 305, 25));
    jLabel1.addMouseListener(new clientFrame_jLabel1_mouseAdapter(this));
    jLabel1.setFont(new java.awt.Font("Serif", 3, 15));
    jLabel1.setForeground(SystemColor.activeCaption);
    jLabel1.setBorder(BorderFactory.createLineBorder(Color.black));
    jLabel1.setText("JNBus->站点查询");

    jScrollPane1.setBorder(BorderFactory.createLineBorder(Color.black));
    jScrollPane1.setBounds(new Rectangle(2, 86, 285, 219));

    jLabel14.setBounds(new Rectangle(0, 30, 175, 27));
    ImageIcon stationline = new ImageIcon("picture/xianlu.gif");
    jLabel14.setIcon(stationline);
    jLabel15.setFont(new java.awt.Font("Serif", 0, 12));
    jLabel15.setBorder(BorderFactory.createEtchedBorder());
    jLabel15.setText("(输入查询的站点名称,如:山大路)");
    jLabel15.setBounds(new Rectangle(1, 60, 218, 24));

    jButton3.setText("");
    jLabel19.setFont(new java.awt.Font("Serif", 0, 12));
    jLabel19.setBorder(BorderFactory.createEtchedBorder());
    jLabel19.setText("(如:山大---齐鲁)");
    jLabel19.setBounds(new Rectangle(177, 30, 113, 26));

    jButton4.setBorderPainted(true);
    jButton4.addActionListener(new clientFrame_jButton4_actionAdapter(this));
    jButton5.addActionListener(new clientFrame_jButton5_actionAdapter(this));
    jButton6.addActionListener(new clientFrame_jButton6_actionAdapter(this));
    jButton7.addActionListener(new clientFrame_jButton7_actionAdapter(this));
    jPanel10.setForeground(Color.black);
    jTextArea7.setForeground(Color.red);
    jTextArea8.setForeground(Color.red);
    jTextArea9.setForeground(Color.red);
    jTextArea10.setForeground(Color.red);
    jTextArea5.setPreferredSize(new Dimension(4, 22));
    jPanel3.add(jLabel1, null);
    jPanel3.add(jScrollPane1, null);
    jPanel3.add(jLabel14, null);
    jPanel3.add(jTextField1, null);
    jPanel3.add(jButton1, null);
    jPanel3.add(jLabel15, null);
    jScrollPane1.getViewport().add(jTextArea1, null);
    /**********************************************************/
    /**********************************************************/

    /**********************************************************/
    /******************线路查询面板初始化************************/
    jTextField4.setFont(new java.awt.Font("Serif", 0, 15));
    jTextField4.setForeground(SystemColor.activeCaption);
    jTextField4.setBorder(BorderFactory.createLineBorder(Color.black));
    jTextField4.setBounds(new Rectangle(177, 30, 120, 27));

    jLabel16.setText("");
    jLabel16.setBounds(new Rectangle(0, 30, 175, 27));
    jLabel16.setIcon(stationline);
    jLabel17.setFont(new java.awt.Font("Serif", 0, 12));
    jLabel17.setText("(输入要查询的车次号,如:119)");
    jLabel17.setBounds(new Rectangle(1, 60, 218, 24));
    jLabel17.setBorder(BorderFactory.createEtchedBorder());

    jButton2.setText("");
    jButton2.setBackground(Color.white);
    jButton2.setBounds(new Rectangle(240, 60, 46, 21));
    jButton2.setIcon(button);
    jButton2.setBorder(null);
    jButton2.addActionListener(new clientFrame_jButton2_actionAdapter(this));

    jTextArea2.setBackground(SystemColor.activeCaptionText);
    jTextArea2.setForeground(SystemColor.activeCaption);
    jTextArea2.setEditable(false);
    jTextArea2.setText("");

    jLabel2.setBounds(new Rectangle(0, 0, 305, 25));
    jLabel2.setFont(new java.awt.Font("Serif", 3, 15));
    jLabel2.setForeground(SystemColor.activeCaption);
    jLabel2.setBorder(BorderFactory.createLineBorder(Color.black));
    jLabel2.setText("JNBus->线路查询");

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?