基于java+mysql的Swing+Java+MySQL电影院购票电影票管理系统(管理员、用户)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
后台管理员:管理电影、影院、场次等
前台用户:查看电影、购票、评论等
eclipse/myeclipse
idea
后台管理员:
前台用户:
技术框架
Java Swing MySQL
ticktb.setFont(font);
ticktb.getTableHeader().setFont(new Font("楷体", 1, 20));
ticktb.getTableHeader().setBackground(Color.orange);
ticktb.getTableHeader().setReorderingAllowed(false); // 不可交换顺序
ticktb.getTableHeader().setResizingAllowed(false); // 不可拉动表格
ticktb.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
ticktablemousePressed(me);
}
});
JScrollPane ticsPane = new JScrollPane(ticktb);
ticsPane.setBounds(0, 420, 1800, 480);
card8.add(ticsPane);
tabbedPane.addTab("查找电影", card2);
String cName=hallnametext.getText();
Hall hall=new Hall(cName,cId,capacity);
int judge=hallservice.addHall(hall);
if(judge==1) {
JOptionPane.showMessageDialog(null, "添加场厅成功");
halllist=hallservice.queryAllHallcId(cId);
fillhalltableTable(halllist);
}else if(judge==2) {
JOptionPane.showMessageDialog(null, "添加场厅失败");
}else {
JOptionPane.showMessageDialog(null, "已存在此场厅");
}
} catch (NumberFormatException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "输入格式错误");
}
}
int sId=Integer.parseInt(sIdtext.getText());
ticketlist=ticketservice.queryAllTicketsId(sId);
filltickettable(ticketlist);
} catch (NumberFormatException e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "格式错误");
}
}
protected void deletactionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
User user;
UserService userservice=new UserServiceImpl();
SessionService sessionservice=new SessionServiceImpl();
double moneyprice;
if(trow!=-1) {
cineaddrtest = new JTextField();
cineaddrtest.setFont(new Font("楷体", Font.PLAIN, 20));
cineaddrtest.setColumns(10);
JButton addButton = new JButton("添加影院");
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addcinemaactionPerformed(e);
}
});
addButton.setFont(new Font("楷体", Font.PLAIN, 20));
JButton updateButton = new JButton("修改影院");
updateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateactionPerformed(e);
}
});
updateButton.setFont(new Font("楷体", Font.PLAIN, 20));
JButton delButton = new JButton("删除影院");
cinematable.setDefaultRenderer(Object.class, r);
cinematable.setRowHeight(70);
cinematable.setFont(font);
cinematable.getTableHeader().setFont(new Font("楷体", 1, 20));
cinematable.getTableHeader().setBackground(Color.orange);
cinematable.getTableHeader().setReorderingAllowed(false); // 不可交换顺序
cinematable.getTableHeader().setResizingAllowed(false);
cinematable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
cinematablemousePressed(me);
}
});
halltable = new JTable(){
public boolean isCellEditable( int row, int column) {
return false;
}
};
v.add(halllist2.get(i).gethName());
v.add(halllist2.get(i).getcId());
v.add(halllist2.get(i).getCapacity());
dtm.addRow(v);
}
}
public boolean judge() {
if("".equals(jcIdText.getText())) {
JOptionPane.showMessageDialog(null, "影院编号不能为空");
return false;
}
if("".equals(jhallText.getText())) {
JOptionPane.showMessageDialog(null, "场厅编号不能为空");
return false;
}
if("".equals(jmIdText.getText())) {
JOptionPane.showMessageDialog(null, "电影编号不能为空");
return false;
}
if("".equals(jpriceText.getText())) {
JOptionPane.showMessageDialog(null, "电影价格不能为空");
return false;
}
if("".equals(jtimeText.getText())) {
JOptionPane.showMessageDialog(null, "场次时间不能为空");
return false;
private List<Movie> list;
private List<Movie> sciencelist;
private List<Movie> actionlist;
private List<Movie> lovelist;
private JButton isrecharge;//选择充值按钮
private JLabel rechargeinfo;//提示
private JButton recharge;//充值按钮
private JTextField charge;//输入
private JLabel[] card0_label = new JLabel[2];
public UserUi(User u, int defaultcard) {
user = u;
this.defaultcard = defaultcard;
jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);// 点击栏位置
// 选项卡面板类
reFresh.addActionListener(this);
reFresh.setFont(font1);
btnexit.addActionListener(this);
btnexit.setFont(font1);
jf.setJMenuBar(menuBar);
menuBar.add(reFresh);
menuBar.add(btnexit);
tabbedPane.setFont(font);// 左栏字体,字号
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
delActionPerformed(e);
}
});
btnNewButton_1.setFont(new Font("楷体", Font.PLAIN, 20));
JLabel lblNewLabel_6 = new JLabel("类型:");
lblNewLabel_6.setFont(new Font("楷体", Font.PLAIN, 20));
JLabel lblNewLabel_7 = new JLabel("电影名:");
lblNewLabel_7.setFont(new Font("楷体", Font.PLAIN, 20));
serNameText = new JTextField();
serNameText.setFont(new Font("楷体", Font.PLAIN, 20));
serNameText.setColumns(10);
}
if("".equals(jpriceText.getText())) {
JOptionPane.showMessageDialog(null, "电影价格不能为空");
return false;
}
if("".equals(jtimeText.getText())) {
JOptionPane.showMessageDialog(null, "场次时间不能为空");
return false;
}
if("".equals(jremainText.getText())) {
JOptionPane.showMessageDialog(null, "剩余座位不能为空");
return false;
}
return true;
}
public void reset() {
jcIdText.setText("");
jhallText.setText("");
jmIdText.setText("");
jpriceText.setText("");
jtimeText.setText("");
jremainText.setText("");
}
}
});
sessionlist=sessionservice.queryAllSession();
fillsessiontable(sessionlist);
r.setHorizontalAlignment(JLabel.CENTER);
sessiontable.setDefaultRenderer(Object.class, r);
sessiontable.setRowHeight(70);
sessiontable.setFont(new Font("楷体", 0, 10));
sessiontable.getTableHeader().setFont(new Font("楷体", 1, 15));
sessiontable.getTableHeader().setBackground(Color.orange);
sessiontable.getTableHeader().setReorderingAllowed(false); // 不可交换顺序
sessiontable.getTableHeader().setResizingAllowed(false); // 不可拉动表格
sessiontable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(btnNewButton)
.addComponent(btnNewButton_1)))
.addGroup(groupLayout.createSequentialGroup()
.addGap(42)
.addComponent(movieDeText, GroupLayout.PREFERRED_SIZE, 275, GroupLayout.PREFERRED_SIZE)))
.addGap(39))
);
movieList=movieservice.queryAllMovie();
movietable = new JTable(){
public boolean isCellEditable( int row, int column) {
return false;
}
};
JButton addhallButton = new JButton("添加场厅");
addhallButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addactionPerformed(e);
}
});
addhallButton.setFont(new Font("楷体", Font.PLAIN, 20));
JButton updatehallButton = new JButton("修改场厅");
updatehallButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateactionPerformed(e);
}
});
updatehallButton.setFont(new Font("楷体", Font.PLAIN, 20));
JButton delhallButton = new JButton("删除场厅");
delhallButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
delactionPerformed(e);
}
});
delhallButton.setFont(new Font("楷体", Font.PLAIN, 20));
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(mlocaText, GroupLayout.PREFERRED_SIZE, 92, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lblNewLabel_4)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(movieTypeText, GroupLayout.PREFERRED_SIZE, 91, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblNewLabel_9)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(scoreText, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)))
.addGap(57)
.addComponent(movieDeText, GroupLayout.PREFERRED_SIZE, 484, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addGap(135)
.addComponent(btnNewButton))
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 1201, GroupLayout.PREFERRED_SIZE)))
.addGap(1079)
.addComponent(txtrDetailtest, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
private JLabel jIscomment=new JLabel();//是否评论
private JTextArea jcommentcontent=new JTextArea(30,30);//评论内容
private JLabel moviebtn_label;
private JButton moviecard1_btn;
private JButton delTicket;
private JLabel moviename;
private JLabel movielocality_language;
private JLabel movietype_grade;
private JTextField jsearch_nametext=new JTextField();
private JButton jsearch_jbutton=new JButton("搜索电影");
//评分前十
private JLabel[][] btn_label;
private JButton[] card1_btn;
private JLabel[][] dname;
private JLabel[][] locality_language;
private JLabel[][] type_grade;
//科幻部分
private JLabel[][] btn_label1;
private JButton[] card1_btn1;
private JLabel[][] dname1;
private JLabel[][] locality_language1;
private JLabel[][] type_grade1;
sessiontable.setRowHeight(70);
sessiontable.setFont(font);
sessiontable.getTableHeader().setFont(new Font("楷体", 1, 20));
sessiontable.getTableHeader().setBackground(Color.orange);
sessiontable.getTableHeader().setReorderingAllowed(false); // 不可交换顺序
sessiontable.getTableHeader().setResizingAllowed(false); // 不可拉动表格
sessiontable.getColumnModel().getColumn(4).setPreferredWidth(200);
sessiontable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
sessiontablemousePressed(me);
}
});
scrollPane_2.setViewportView(sessiontable);
getContentPane().setLayout(groupLayout);
this.setVisible(true);