package Ship;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.Calendar;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.border.Border;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import Boot.Check;
import Boot.Date;
import Boot.MyDocument;
import Boot.Mysql;
@SuppressWarnings("serial")
public class NewShip extends JPanel implements ActionListener, ItemListener,
ListSelectionListener {
JPanel centerPanel = new JPanel();// 中部面板
JPanel northPanel = new JPanel();// 北部面板
JPanel southPanel = new JPanel();// 南部面板
JPanel newshipPanel = new JPanel();// 船舶新增
JPanel labelPanel = new JPanel();// 船舶新增输入部分
JPanel buttonPanel = new JPanel();// 船舶新增保存部分
JPanel datePanel = new JPanel();// 日期组合框
JDialog newShipDialog, deleteShipdDialog;// 新增船舶对话框,删除确认对话框
DefaultTableModel tableModel;
ListSelectionModel listSelectionModel = null;// 列表监听
JTable table;// 表格定义
JButton[] jButtons = { new JButton("新增"), new JButton("修改"),
new JButton("处理"), new JButton("删除") };// 北部面板功能按钮
JLabel[] newshipLabels = {
new JLabel("船舶序号", JLabel.CENTER),// 船舶对话框提示标签
new JLabel("船舶名称", JLabel.CENTER),
new JLabel("申请日期", JLabel.CENTER),
new JLabel("船舶类型", JLabel.CENTER),
new JLabel("船舶状态", JLabel.CENTER),
new JLabel("企业编号", JLabel.CENTER),
new JLabel("审批状态", JLabel.CENTER) };
String[] shipTypeStrings = { "客运", "货运" };// 船舶类型下拉框
@SuppressWarnings({ "unchecked", "rawtypes" })
JComboBox shipType = new JComboBox(shipTypeStrings);
String[] shipStateStrings = { "驻港", "航行", "抵达", "返航" };// 船舶状态下拉框
@SuppressWarnings({ "unchecked", "rawtypes" })
JComboBox shipState = new JComboBox(shipStateStrings);
String[] examStateStrings = { "待审核", "已批准" };// 审批状态下拉框
@SuppressWarnings({ "unchecked", "rawtypes" })
JComboBox examState = new JComboBox(examStateStrings);
String[] tableName = { " 船舶序号", " 船舶名称", " 申请日期", " 船舶类型", " 船舶状态",// 表头设置
" 企业编号", " 审批状态" };
JTextField[] newshipField = new JTextField[4];// 需要4个文本框
JButton confirmButton = new JButton("保存");
JButton changeButton = new JButton("更改");
Border border = BorderFactory.createEtchedBorder();// 边界样式设置
Calendar cal = Calendar.getInstance();// 获取日期
JLabel jLabel_flag1 = new JLabel(" 开发小组:", JLabel.LEFT);// 南部面板显示内容
JLabel jLabel_flag2 = new JLabel("国内航运管理系统 " + cal.get(Calendar.YEAR)
+ "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DATE),
JLabel.RIGHT);
Mysql mysql;// 定义数据库连接
String addValue[] = new String[7];// 7列数据
Check check = new Check();// 检测类
boolean flag = true;// 检测标志
int row;// 行号
Date date = new Date();// 日期
JScrollPane jScrollPane;
int judge = 0;// 新增、修改、处理判断标志
String stmt_string = "select ship_num,ship_name,apply_date,ship_type,ship_state,firm_num,examine_state from new_ship";
public NewShip() {
this.setLayout(new BorderLayout());
try {
centerPanelInit();// 中部面板初始化
northPanelInit();// 北部面板初始化
southPanelInit();// 南部面板初始化
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 北部面板设置,即处理按钮的设置。
* */
public void northPanelInit() throws Exception {
northPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
for (int j = 0; j < jButtons.length; j++) {
northPanel.add(jButtons[j]);
jButtons[j].addActionListener(this);
}
JLabel label1 = new JLabel(" ");
northPanel.add(label1);
label1.add(Box.createRigidArea(new Dimension(50, 90)));
jButtons[1].setEnabled(false);
jButtons[2].setEnabled(false);
jButtons[3].setEnabled(false);
newShipDialog = new JDialog();// 初始化船舶新增对话框
newShipDialog.setSize(650, 300);
newshipPanelInit();
newShipDialog.add(newshipPanel);
this.add(northPanel, BorderLayout.NORTH);
}
/**
* 中部面板设置,显示信息表格。
* */
public void centerPanelInit() throws Exception {
mysql = new Mysql();
mysql.select(stmt_string);
tableModel = new DefaultTableModel(mysql.data, tableName);// 添加数据和表头
table = new JTable(tableModel) {
public boolean isCellEditable(int row, int column) {// 设置表格的不可编辑模式
return false;
}
};
table.setPreferredScrollableViewportSize(new Dimension(1150, 600));
table.setRowHeight(50);
listSelectionModel = table.getSelectionModel();// 监听行选择状态
listSelectionModel
.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listSelectionModel.addListSelectionListener(this);
jScrollPane = new JScrollPane(table);
jScrollPane.setPreferredSize(new Dimension(1150, 600));
centerPanel.add(jScrollPane);
this.add(centerPanel, BorderLayout.CENTER);
}
/**
* 南部面板设置,显示开发组信息,系统时间。
* */
public void southPanelInit() throws Exception {
JLabel label = new JLabel("");
southPanel.setLayout(new GridLayout(2, 2));
southPanel.add(jLabel_flag1);
southPanel.add(jLabel_flag2);
southPanel.add(label);
this.add(southPanel, BorderLayout.SOUTH);
}
/**
* 船舶新增对话框
*
* @throws ParseException
* */
public void newshipPanelInit() throws ParseException {
for (int i = 0; i < newshipField.length; i++) {
newshipField[i] = new JTextField();
}
GridLayout gridLayout = new GridLayout(4, 4);
labelPanel.setLayout(gridLayout);
gridLayout.setVgap(20);
labelPanel.add(newshipLabels[0]);// 船舶序号
labelPanel.add(newshipField[0]);
newshipField[0].setDocument(new MyDocument(4));// 限制长度为4位
labelPanel.add(newshipLabels[1]);// 船舶名称
labelPanel.add(newshipField[1]);
newshipField[1].setDocument(new MyDocument(20));// 限制长度为4位
labelPanel.add(newshipLabels[2]);// 申请日期
labelPanel.add(newshipField[2]);
labelPanel.add(newshipLabels[3]);// 船舶类型
labelPanel.add(shipType);
labelPanel.add(newshipLabels[4]);// 船舶状态
labelPanel.add(shipState);
labelPanel.add(newshipLabels[5]);// 企业编号
labelPanel.add(newshipField[3]);
newshipField[3].setDocument(new MyDocument(4));// 限制长度为4位
labelPanel.add(newshipLabels[6]);// 审批状态
labelPanel.add(examState);
labelPanel.setBorder(border);
newshipPanel.setLayout(new BorderLayout());
shipType.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addValue[3] = shipType.getSelectedItem().toString();// 船舶类型
}
});
shipState.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addValue[4] = shipState.getSelectedItem().toString();// 船舶状态
}
});
examState.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addValue[6] = examState.getSelectedItem().toString();// 审批状态
}
});
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(confirmButton);
confirmButton.addActionListener(this);
newshipPanel.add(labelPanel, BorderLayout.NORTH);
newshipPanel.add(buttonPanel, BorderLayout.CENTER);
}
没有合适的资源?快使用搜索试试~ 我知道了~
国内航运企业船舶管理系统
共68个文件
class:38个
java:20个
jar:3个
需积分: 30 31 下载量 107 浏览量
2015-08-13
20:54:20
上传
评论 5
收藏 19.46MB ZIP 举报
温馨提示
基于MyEclipse开发的软件工程课设
资源推荐
资源详情
资源评论
收起资源包目录
国内航运企业船舶管理系统.zip (68个子文件)
data.xls 8KB
BootMS1
.project 382B
src
Company
Licence.java 3KB
CompanyOpen.java 6KB
CompanyChange.java 9KB
CompanyFile.java 7KB
CompanyPrepare.java 7KB
CompanyCheck.java 5KB
Boot
BootMS.java 1KB
Check.java 3KB
CMysql.java 3KB
MyDocument.java 702B
BootMain.java 8KB
Mysql.java 4KB
BackGrondJPanel.java 979B
Date.java 506B
LoginFrame.java 9KB
Ship
ChangeShip.java 5KB
ShipStateChange.java 4KB
NewShip.java 14KB
ExaminedShip.java 5KB
RecordShip.java 3KB
Image
icon.png 10KB
MainFrame.jpg 18KB
background.jpg 25KB
lib
rt.jar 57.19MB
edtftpj.jar 200KB
mysql-connector-java-5.1.22-bin.jar 813KB
.settings
org.eclipse.jdt.core.prefs 598B
.classpath 547B
bin
Company
CompanyOpen.class 7KB
Licence.class 4KB
CompanyCheck$1.class 726B
CompanyPrepare.class 8KB
CompanyChange$2.class 732B
CompanyOpen$1.class 720B
Licence$1.class 696B
CompanyFile$2.class 720B
CompanyFile$1.class 715B
CompanyCheck.class 6KB
CompanyChange$1.class 917B
CompanyChange.class 9KB
CompanyFile.class 8KB
CompanyPrepare$1.class 738B
Boot
LoginFrame.class 5KB
Date.class 932B
MyDocument.class 993B
BackGrondJPanel.class 1KB
Check.class 3KB
LoginFrame$ButtonAction.class 3KB
Mysql.class 5KB
BootMain.class 8KB
BootMS.class 2KB
BootMain$1.class 646B
CMysql.class 3KB
Ship
ShipStateChange$1.class 769B
NewShip$4.class 865B
NewShip$2.class 863B
NewShip$3.class 864B
RecordShip$1.class 699B
RecordShip.class 4KB
ExaminedShip$1.class 711B
ExaminedShip.class 6KB
NewShip$1.class 681B
NewShip.class 12KB
ChangeShip.class 7KB
ChangeShip$1.class 739B
ShipStateChange.class 6KB
共 68 条
- 1
资源评论
qq_30584851
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功