📄 busmanageframe.java~258~
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.table.*;
import javax.swing.ButtonGroup;
public class busmanageFrame
extends JFrame {
JPanel contentPane;
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JPanel jPanel7 = new JPanel();
JPanel jPanel8 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
JButton jButton7 = new JButton();
JButton jButton8 = new JButton();
JButton jButton9 = new JButton();
JButton jButton10 = new JButton();
JButton jButton11 = new JButton();
JButton jButton16 = new JButton();
JButton jButton17 = new JButton();
JLabel jLabel7 = 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();
JTextField jTextField1 = new JTextField();
JTextField jTextField6 = new JTextField();
JTextField jTextField7 = new JTextField();
JTextField jTextField8 = new JTextField();
JTextField jTextField9 = new JTextField();
JTextField jTextField10 = new JTextField();
JScrollPane jScrollPane1 = new JScrollPane();
JScrollPane jScrollPane2 = new JScrollPane();
JTextArea jTextArea1 = new JTextArea();
JTextArea jTextArea2 = new JTextArea();
JComboBox jComboBox1 = new JComboBox();
JButton jButton18 = new JButton();
JLabel jLabel17 = new JLabel();
JPanel jPanel11 = new JPanel();
JPanel jPanel12 = new JPanel();
JTextArea jTextArea3 = new JTextArea();
JPanel jPanel6 = new JPanel();
JTextArea jTextArea4 = new JTextArea();
ButtonGroup bg = new ButtonGroup();
//Construct the frame
public busmanageFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
//*************************************************************************//
//********************读写help文件******************************************//
String helpline = null;
String helptxt = "";
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);
}
}
public void writehelp()
{
//编辑帮助
PrintWriter outputhelp = null;
try
{
outputhelp = new PrintWriter(new FileOutputStream("help.txt"));
}
catch (FileNotFoundException e)
{
}
String helptxt = jTextArea2.getText();
outputhelp.write(helptxt);
outputhelp.close();
}
//*************************************************************************//
//*************************读写济南公交公司资料*******************************//
String jnbusline = null;
String jnbustxt = "";
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);
}
}
public void writejnbus()
{
//编辑公交公司资料
PrintWriter outputjnbus = null;
try
{
outputjnbus = new PrintWriter(new FileOutputStream("jnbus.txt"));
}
catch (FileNotFoundException e)
{
}
String jnbustxt = jTextArea1.getText();
outputjnbus.write(jnbustxt);
outputjnbus.close();
}
//*************************************************************************//
//****************连接数据库************************************************//
Connection conn;
Statement stmt;
public void condatabase()
{
//连接数据库的方法
try
{
//Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println(e);
}
try
{
//String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jnbus";
String url = "jdbc:odbc:jnbus";
String user = "";
String password = "";
conn = DriverManager.getConnection(url, user, password);
stmt = conn.createStatement();
}
catch (SQLException e) {
}
}
//*************************************************************************//
//*****************************初始化***************************************//
private void jbInit() throws Exception
{
condatabase(); //连接数据库
contentPane = (JPanel)this.getContentPane();
contentPane.setLayout(null);//设置布局为空
this.setResizable(false);//不可改变大小
this.setSize(new Dimension(600, 400));//设置显示窗口大小
this.setTitle("济南公交管理系统");//设置标题
//********窗口顶部panel,用于显示图片************//
jPanel1.setBackground(Color.gray);//设置背景色
jPanel1.setBounds(new Rectangle(0, 0, 600, 60));
jPanel1.setLayout(null);
//********主容器,用于放置各个panel和菜单************//
jPanel2.setBackground(SystemColor.inactiveCaptionText);
jPanel2.setBounds(new Rectangle(0, 60, 600, 340));
jPanel2.setLayout(null);
//********菜单容器,用于放置菜单按钮************//
jPanel3.setBackground(SystemColor.inactiveCaption);
jPanel3.setBorder(BorderFactory.createLineBorder(Color.black));
jPanel3.setBounds(new Rectangle(0, 0, 600, 30));
jPanel3.setLayout(null);
//********站点管理容器************//
jPanel4.setBackground(SystemColor.inactiveCaptionText);
jPanel4.setBorder(BorderFactory.createLoweredBevelBorder());
jPanel4.setBounds(new Rectangle(0, 30, 600, 245));
jPanel4.setLayout(null);
jPanel4.setVisible(true);
//********线路属性管理容器************//
jPanel5.setBackground(SystemColor.inactiveCaptionText);
jPanel5.setBorder(BorderFactory.createLoweredBevelBorder());
jPanel5.setBounds(new Rectangle(0, 30, 600, 245));
jPanel5.setLayout(null);
jPanel5.setVisible(false);
//********资料编辑容器************//
jPanel7.setBackground(SystemColor.inactiveCaptionText);
jPanel7.setFont(new java.awt.Font("Serif", 0, 12));
jPanel7.setForeground(SystemColor.activeCaption);
jPanel7.setBorder(BorderFactory.createLoweredBevelBorder());
jPanel7.setBounds(new Rectangle(0, 30, 600, 245));
jPanel7.setLayout(null);
jPanel7.setVisible(false);
jPanel8.setBackground(SystemColor.inactiveCaptionText);
jPanel8.setBorder(BorderFactory.createLoweredBevelBorder());
jPanel8.setBounds(new Rectangle(0, 30, 600, 245));
jPanel8.setLayout(null);
jPanel8.setVisible(false);
jButton1.setBackground(SystemColor.inactiveCaption);
jButton1.setBounds(new Rectangle(0, 0, 80, 25));
jButton1.setFont(new java.awt.Font("Dialog", 0, 12));
jButton1.setForeground(Color.green);
jButton1.setBorder(null);
jButton1.setText("站点管理");
jButton1.addActionListener(new busmanageFrame_jButton1_actionAdapter(this));
jButton1.addActionListener(new busmanageFrame_jButton1_actionAdapter(this));
jButton2.setBackground(SystemColor.inactiveCaption);
jButton2.setBounds(new Rectangle(85, 0, 80, 25));
jButton2.setFont(new java.awt.Font("Dialog", 0, 12));
jButton2.setForeground(Color.green);
jButton2.setBorder(null);
jButton2.setBorderPainted(true);
jButton2.setText("线路管理");
jButton2.addActionListener(new busmanageFrame_jButton2_actionAdapter(this));
jButton4.setBackground(SystemColor.inactiveCaption);
jButton4.setBounds(new Rectangle(170, 0, 80, 25));
jButton4.setFont(new java.awt.Font("Dialog", 0, 12));
jButton4.setForeground(Color.green);
jButton4.setBorder(null);
jButton4.setText("公司资料编辑");
jButton4.addActionListener(new busmanageFrame_jButton4_actionAdapter(this));
jButton5.setBackground(SystemColor.inactiveCaption);
jButton5.setBounds(new Rectangle(255, 0, 80, 25));
jButton5.setFont(new java.awt.Font("Dialog", 0, 12));
jButton5.setForeground(Color.green);
jButton5.setBorder(null);
jButton5.setText("帮助编辑");
jButton5.addActionListener(new busmanageFrame_jButton5_actionAdapter(this));
jButton6.setBackground(SystemColor.inactiveCaption);
jButton6.setBounds(new Rectangle(340, 0, 80, 25));
jButton6.setFont(new java.awt.Font("Dialog", 0, 12));
jButton6.setForeground(Color.green);
jButton6.setBorder(null);
jButton6.setText("退出");
jButton6.addActionListener(new busmanageFrame_jButton6_actionAdapter(this));
jButton7.setBackground(SystemColor.inactiveCaptionText);
jButton7.setBounds(new Rectangle(120, 215, 80, 25));
jButton7.setFont(new java.awt.Font("Serif", 0, 13));
jButton7.setForeground(SystemColor.activeCaption);
jButton7.setText("编辑");
jButton7.addActionListener(new busmanageFrame_jButton7_actionAdapter(this));
jButton8.setBackground(SystemColor.inactiveCaptionText);
jButton8.setBounds(new Rectangle(30, 215, 80, 25));
jButton8.setFont(new java.awt.Font("Serif", 0, 13));
jButton8.setForeground(SystemColor.activeCaption);
jButton8.setText("读取");
jButton8.addActionListener(new busmanageFrame_jButton8_actionAdapter(this));
jButton9.setBackground(SystemColor.inactiveCaptionText);
jButton9.setBounds(new Rectangle(30, 215, 80, 25));
jButton9.setFont(new java.awt.Font("Serif", 0, 13));
jButton9.setForeground(SystemColor.activeCaption);
jButton9.setText("读取");
jButton9.addActionListener(new busmanageFrame_jButton9_actionAdapter(this));
jButton10.setBackground(SystemColor.inactiveCaptionText);
jButton10.setBounds(new Rectangle(120, 215, 80, 25));
jButton10.setFont(new java.awt.Font("Serif", 0, 13));
jButton10.setForeground(SystemColor.activeCaption);
jButton10.setText("编辑");
jButton10.addActionListener(new busmanageFrame_jButton10_actionAdapter(this));
jScrollPane1.setBounds(new Rectangle(3, 10, 300, 200));
jTextArea1.setBackground(SystemColor.inactiveCaptionText);
jTextArea1.setFont(new java.awt.Font("Serif", 0, 13));
jTextArea1.setForeground(SystemColor.activeCaption);
jScrollPane2.setBounds(new Rectangle(3, 10, 300, 200));
jTextArea2.setBackground(SystemColor.inactiveCaptionText);
jTextArea2.setFont(new java.awt.Font("Serif", 0, 13));
jTextArea2.setForeground(SystemColor.activeCaption);
jLabel7.setText("");
jLabel7.setBounds(new Rectangle(0, 0, 600, 60));
ImageIcon managetop = new ImageIcon("picture/managetop.jpg");
jLabel7.setIcon(managetop);
jTextField1.setBackground(SystemColor.inactiveCaptionText);
jTextField1.setFont(new java.awt.Font("Serif", 0, 13));
jTextField1.setForeground(SystemColor.activeCaption);
jTextField1.setText("输入车次号");
jTextField1.setBounds(new Rectangle(5, 4, 144, 27));
ImageIcon button=new ImageIcon("picture/button.gif");
jButton11.setBackground(Color.white);
jButton11.setBounds(new Rectangle(163, 6, 46, 21));
jButton11.setFont(new java.awt.Font("Serif", 1, 13));
jButton11.setBorder(BorderFactory.createRaisedBevelBorder());
jButton11.setIcon(button);
jButton11.setText("");
jButton11.addActionListener(new busmanageFrame_jButton11_actionAdapter(this));
jButton12.setBackground(SystemColor.inactiveCaptionText);
jButton12.setBounds(new Rectangle(10, 9, 82, 30));
jButton12.setFont(new java.awt.Font("Serif", 0, 12));
jButton12.setAlignmentY( (float) 0.5);
jButton12.setBorder(BorderFactory.createRaisedBevelBorder());
jButton12.setText("添加站点");
jButton12.addActionListener(new busmanageFrame_jButton12_actionAdapter(this));
jButton13.setBackground(SystemColor.inactiveCaptionText);
jButton13.setBounds(new Rectangle(10, 50, 82, 30));
jButton13.setFont(new java.awt.Font("Serif", 0, 12));
jButton13.setForeground(Color.black);
jButton13.setBorder(BorderFactory.createRaisedBevelBorder());
jButton13.setText("删除站点");
jButton13.addActionListener(new busmanageFrame_jButton13_actionAdapter(this));
jButton14.setBackground(SystemColor.inactiveCaptionText);
jButton14.setBounds(new Rectangle(11, 129, 82, 30));
jButton14.setFont(new java.awt.Font("Serif", 0, 12));
jButton14.setBorder(BorderFactory.createRaisedBevelBorder());
jButton14.setText("修改");
jButton14.addActionListener(new busmanageFrame_jButton14_actionAdapter(this));
jButton15.setBackground(SystemColor.inactiveCaptionText);
jButton15.setBounds(new Rectangle(10, 90, 82, 30));
jButton15.setFont(new java.awt.Font("Serif", 0, 12));
jButton15.setBorder(BorderFactory.createRaisedBevelBorder());
jButton15.setSelectedIcon(null);
jButton15.setText("清空");
jButton15.addActionListener(new busmanageFrame_jButton15_actionAdapter(this));
jPanel9.setBackground(SystemColor.inactiveCaptionText);
jPanel9.setBorder(BorderFactory.createEtchedBorder());
jPanel9.setBounds(new Rectangle(239, 16, 102, 230));
jPanel9.setLayout(null);
jPanel10.setBackground(SystemColor.inactiveCaptionText);
jPanel10.setBorder(BorderFactory.createEtchedBorder());
jPanel10.setBounds(new Rectangle(352, 16, 200, 115));
jPanel10.setLayout(null);
jLabel8.setFont(new java.awt.Font("Serif", 0, 12));
jLabel8.setText("车次号");
jLabel8.setBounds(new Rectangle(3, 5, 50, 25));
jTextField2.setBackground(SystemColor.inactiveCaptionText);
jTextField2.setFont(new java.awt.Font("Serif", 0, 13));
jTextField2.setForeground(SystemColor.activeCaption);
jTextField2.setEditable(false);
jTextField2.setText("");
jTextField2.setBounds(new Rectangle(60, 3, 120, 30));
jLabel9.setFont(new java.awt.Font("Serif", 0, 12));
jLabel9.setText("序号");
jLabel9.setBounds(new Rectangle(3, 40, 50, 25));
jTextField3.setBackground(SystemColor.inactiveCaptionText);
jTextField3.setFont(new java.awt.Font("Serif", 0, 13));
jTextField3.setForeground(SystemColor.activeCaption);
jTextField3.setSelectionStart(11);
jTextField3.setText("");
jTextField3.setBounds(new Rectangle(60, 38, 120, 30));
jLabel10.setFont(new java.awt.Font("Serif", 0, 12));
jLabel10.setText("站点名");
jLabel10.setBounds(new Rectangle(3, 75, 50, 25));
jTextField4.setBackground(SystemColor.inactiveCaptionText);
jTextField4.setFont(new java.awt.Font("Serif", 0, 13));
jTextField4.setForeground(SystemColor.activeCaption);
jTextField4.setText("");
jTextField4.setBounds(new Rectangle(60, 75, 120, 30));
jRadioButton1.setBackground(SystemColor.inactiveCaptionText);
jRadioButton1.setFont(new java.awt.Font("Serif", 0, 12));
jRadioButton1.setText("增加车次");
jRadioButton1.setBounds(new Rectangle(5, 33, 75, 22));
jRadioButton2.setBackground(SystemColor.inactiveCaptionText);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -