经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 软件/图像 » Eclipse » 查看文章
Eclipse+Java+Swing+Mysql实现电影购票系统(详细代码)
来源:jb51  时间:2022/1/18 13:28:14  对本文有异议

一、系统介绍

1.开发环境

开发工具:Eclipse2021

JDK版本:jdk1.8

Mysql版本:8.0.13

2.技术选型

Java+Swing+Mysql

3.系统功能

注册系统,登录系统;

3.1.用户

  • 1.欢迎页:修改用户姓名和密码;
  • 2.碟片排行榜:影片的详细信息;
  • 3.购票信息:已购买车票的信息;
  • 4.场次信息:电影场次的详细信息;
  • 5.充值:充值余额;
  • 6.搜索电影:搜索电影的详细信息;

3.2.管理员

  • 1.对用户进行操作:用户信息的查询、删除;
  • 2.对影院进行操作:影院信息的查询、删除、增加;
  • 3.对场厅进行操作:场厅信息的查询、删除、增加;
  • 4.对场次进行操作:场次信息的查询、删除、增加;
  • 5.对电影进行操作:电影信息的查询、删除、增加;

4.数据库

  1. /*
  2. ?Navicat Premium Data Transfer
  3. ?Source Server ? ? ? ? : MySQL
  4. ?Source Server Type ? ?: MySQL
  5. ?Source Server Version : 80013
  6. ?Source Host ? ? ? ? ? : 127.0.0.1:3306
  7. ?Source Schema ? ? ? ? : swing_movie_house
  8. ?Target Server Type ? ?: MySQL
  9. ?Target Server Version : 80013
  10. ?File Encoding ? ? ? ? : 65001
  11. ?Date: 21/09/2021 12:33:55
  12. */
  13. ?
  14. SET NAMES utf8mb4;
  15. SET FOREIGN_KEY_CHECKS = 0;
  16. ?
  17. -- ----------------------------
  18. -- Table structure for cinema
  19. -- ----------------------------
  20. DROP TABLE IF EXISTS `cinema`;
  21. CREATE TABLE `cinema` ?(
  22. ? `cinema_id` int(11) NOT NULL AUTO_INCREMENT,
  23. ? `cname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  24. ? `address` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  25. ? PRIMARY KEY (`cinema_id`) USING BTREE
  26. ) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  27. ?
  28. -- ----------------------------
  29. -- Records of cinema
  30. -- ----------------------------
  31. INSERT INTO `cinema` VALUES (6, '光明影院', '湖北武汉');
  32. INSERT INTO `cinema` VALUES (7, '大同影院', '湖南长沙');
  33. ?
  34. -- ----------------------------
  35. -- Table structure for comment
  36. -- ----------------------------
  37. DROP TABLE IF EXISTS `comment`;
  38. CREATE TABLE `comment` ?(
  39. ? `comment_id` int(11) NOT NULL AUTO_INCREMENT,
  40. ? `user_id` int(11) NOT NULL,
  41. ? `movie_id` int(11) NOT NULL,
  42. ? `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  43. ? `datetime` datetime(0) NULL DEFAULT NULL,
  44. ? PRIMARY KEY (`comment_id`) USING BTREE,
  45. ? INDEX `comment_ibfk_1`(`user_id`) USING BTREE,
  46. ? INDEX `comment_ibfk_2`(`movie_id`) USING BTREE,
  47. ? CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE RESTRICT,
  48. ? CONSTRAINT `comment_ibfk_2` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE CASCADE ON UPDATE RESTRICT
  49. ) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  50. ?
  51. -- ----------------------------
  52. -- Records of comment
  53. -- ----------------------------
  54. ?
  55. -- ----------------------------
  56. -- Table structure for hall
  57. -- ----------------------------
  58. DROP TABLE IF EXISTS `hall`;
  59. CREATE TABLE `hall` ?(
  60. ? `hall_id` int(11) NOT NULL AUTO_INCREMENT,
  61. ? `hname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  62. ? `capacity` int(11) NULL DEFAULT NULL,
  63. ? `cinema_id` int(11) NOT NULL,
  64. ? PRIMARY KEY (`hall_id`) USING BTREE,
  65. ? INDEX `hall_ibfk_1`(`cinema_id`) USING BTREE,
  66. ? CONSTRAINT `hall_ibfk_1` FOREIGN KEY (`cinema_id`) REFERENCES `cinema` (`cinema_id`) ON DELETE CASCADE ON UPDATE CASCADE
  67. ) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  68. ?
  69. -- ----------------------------
  70. -- Records of hall
  71. -- ----------------------------
  72. INSERT INTO `hall` VALUES (12, '1厅', 50, 6);
  73. ?
  74. -- ----------------------------
  75. -- Table structure for movie
  76. -- ----------------------------
  77. DROP TABLE IF EXISTS `movie`;
  78. CREATE TABLE `movie` ?(
  79. ? `movie_id` int(11) NOT NULL AUTO_INCREMENT,
  80. ? `mname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  81. ? `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '电影类型',
  82. ? `detail` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  83. ? `duration` int(11) NULL DEFAULT NULL,
  84. ? `img` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '保存图片名称',
  85. ? PRIMARY KEY (`movie_id`) USING BTREE
  86. ) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  87. ?
  88. -- ----------------------------
  89. -- Records of movie
  90. -- ----------------------------
  91. INSERT INTO `movie` VALUES (12, '八佰', '抗战', '八佰', 120, NULL);
  92. INSERT INTO `movie` VALUES (13, '春秋', '历史', '春秋', 150, NULL);
  93. INSERT INTO `movie` VALUES (15, '1', '1', '1', 1, NULL);
  94. ?
  95. -- ----------------------------
  96. -- Table structure for session
  97. -- ----------------------------
  98. DROP TABLE IF EXISTS `session`;
  99. CREATE TABLE `session` ?(
  100. ? `session_id` int(11) NOT NULL AUTO_INCREMENT,
  101. ? `hall_id` int(11) NOT NULL,
  102. ? `cinema_id` int(11) NOT NULL,
  103. ? `movie_id` int(11) NOT NULL,
  104. ? `starttime` varchar(11) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  105. ? `price` double NULL DEFAULT NULL,
  106. ? `remain` int(11) NULL DEFAULT NULL,
  107. ? PRIMARY KEY (`session_id`) USING BTREE,
  108. ? INDEX `hall_id`(`hall_id`) USING BTREE,
  109. ? INDEX `cinema_id`(`cinema_id`) USING BTREE,
  110. ? INDEX `movie_id`(`movie_id`) USING BTREE,
  111. ? CONSTRAINT `session_ibfk_1` FOREIGN KEY (`hall_id`) REFERENCES `hall` (`hall_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  112. ? CONSTRAINT `session_ibfk_2` FOREIGN KEY (`cinema_id`) REFERENCES `cinema` (`cinema_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  113. ? CONSTRAINT `session_ibfk_3` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  114. ) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  115. ?
  116. -- ----------------------------
  117. -- Records of session
  118. -- ----------------------------
  119. INSERT INTO `session` VALUES (14, 12, 6, 12, '09:00:00', 50, 47);
  120. ?
  121. -- ----------------------------
  122. -- Table structure for ticket
  123. -- ----------------------------
  124. DROP TABLE IF EXISTS `ticket`;
  125. CREATE TABLE `ticket` ?(
  126. ? `ticket_id` int(11) NOT NULL AUTO_INCREMENT,
  127. ? `user_id` int(11) NOT NULL,
  128. ? `movie_id` int(11) NOT NULL,
  129. ? `session_id` int(11) NOT NULL,
  130. ? `seat` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  131. ? PRIMARY KEY (`ticket_id`) USING BTREE,
  132. ? INDEX `ticket_ibfk_1`(`user_id`) USING BTREE,
  133. ? INDEX `ticket_ibfk_2`(`movie_id`) USING BTREE,
  134. ? INDEX `ticket_ibfk_3`(`session_id`) USING BTREE,
  135. ? CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  136. ? CONSTRAINT `ticket_ibfk_2` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`movie_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  137. ? CONSTRAINT `ticket_ibfk_3` FOREIGN KEY (`session_id`) REFERENCES `session` (`session_id`) ON DELETE CASCADE ON UPDATE CASCADE
  138. ) ENGINE = InnoDB AUTO_INCREMENT = 64 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  139. ?
  140. -- ----------------------------
  141. -- Records of ticket
  142. -- ----------------------------
  143. INSERT INTO `ticket` VALUES (64, 1, 12, 14, '3');
  144. ?
  145. -- ----------------------------
  146. -- Table structure for user
  147. -- ----------------------------
  148. DROP TABLE IF EXISTS `user`;
  149. CREATE TABLE `user` ?(
  150. ? `user_id` int(11) NOT NULL AUTO_INCREMENT,
  151. ? `uname` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  152. ? `passwd` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  153. ? `type` int(11) NULL DEFAULT 0 COMMENT '0代表普通用户,1代表管理员',
  154. ? `balance` double NULL DEFAULT NULL,
  155. ? `level` int(11) NULL DEFAULT NULL,
  156. ? PRIMARY KEY (`user_id`) USING BTREE
  157. ) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;
  158. ?
  159. -- ----------------------------
  160. -- Records of user
  161. -- ----------------------------
  162. INSERT INTO `user` VALUES (1, 'user', 'user', 0, 161, 1);
  163. INSERT INTO `user` VALUES (2, 'admin', 'admin', 1, 1, 1);
  164. ?
  165. SET FOREIGN_KEY_CHECKS = 1;

5.工程截图

二、系统展示 

1.注册系统

2.登录系统

3.用户-欢迎界面

4.用户-影片排行榜

5.用户-购票信息

6.用户-场次信息

7.用户-充值余额

8.用户-搜索电影

9.管理员-首页

10.管理员-对用户进行操作

11.管理员-对影院进行操作

12.管理员-对场厅进行操作

13.管理员-对场次进行操作

14.管理员-对电影进行操作

三、部分代码

AdminMainView.java

  1. package view;
  2. ?
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.EventQueue;
  6. import java.awt.Font;
  7. import java.awt.GridLayout;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. ?
  11. import javax.swing.BorderFactory;
  12. import javax.swing.ImageIcon;
  13. import javax.swing.JButton;
  14. import javax.swing.JDesktopPane;
  15. import javax.swing.JFrame;
  16. import javax.swing.JLabel;
  17. import javax.swing.JPanel;
  18. ?
  19. import entity.User;
  20. ?
  21. public class AdminMainView extends JFrame {
  22. ?? ?private JPanel main_panel = null;
  23. ?? ?private JPanel fun_panel = null;
  24. ?? ?private JDesktopPane fundesk = null;
  25. ?
  26. ?? ?private JButton oper_User = null;
  27. ?? ?private JButton oper_Cinema = null;
  28. ?? ?private JButton oper_Hall = null;
  29. ?? ?private JButton oper_Session = null;
  30. ?? ?private JButton oper_Movie = null;
  31. ?? ?private JButton back = null;
  32. ?
  33. ?? ?private JLabel lb_welcome = null;
  34. ?? ?private JLabel lb_image = null;
  35. ?? ?private User admin = null;
  36. ?
  37. ?? ?public AdminMainView() {
  38. ?? ??? ?init();
  39. ?? ??? ?RegisterListener();
  40. ?? ?}
  41. ?
  42. ?? ?public AdminMainView(User admin) {
  43. ?? ??? ?this.admin = admin;
  44. ?? ??? ?init();
  45. ?? ??? ?RegisterListener();
  46. ?? ?}
  47. ?
  48. ?? ?private void init() {
  49. ?? ??? ?main_panel = new JPanel(new BorderLayout());
  50. ?? ??? ?fun_panel = new JPanel(new GridLayout(8, 1, 0, 18));
  51. ?? ??? ?oper_User = new JButton("对用户进行操作");
  52. ?? ??? ?oper_Cinema = new JButton("对影院进行操作");
  53. ?? ??? ?oper_Hall = new JButton("对场厅进行操作");
  54. ?? ??? ?oper_Session = new JButton("对场次进行操作");
  55. ?? ??? ?oper_Movie = new JButton("对电影进行操作");
  56. ?? ??? ?back = new JButton("返回");
  57. ?
  58. ?? ??? ?fun_panel.add(new JLabel());
  59. ?? ??? ?fun_panel.add(oper_User);
  60. ?? ??? ?fun_panel.add(oper_Cinema);
  61. ?? ??? ?fun_panel.add(oper_Hall);
  62. ?? ??? ?fun_panel.add(oper_Session);
  63. ?? ??? ?fun_panel.add(oper_Movie);
  64. ?? ??? ?fun_panel.add(back);
  65. ?? ??? ?fun_panel.add(new JLabel());
  66. ?
  67. ?? ??? ?// 设置面板外观
  68. ?? ??? ?fun_panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createRaisedBevelBorder(), "功能区"));
  69. ?
  70. ?? ??? ?lb_welcome = new JLabel("欢 迎 " + admin.getUname() + " 进 入 管 理 员 功 能 界 面");
  71. ?? ??? ?lb_welcome.setFont(new Font("楷体", Font.BOLD, 34));
  72. ?? ??? ?lb_welcome.setForeground(Color.BLUE);
  73. ?
  74. ?? ??? ?fundesk = new JDesktopPane();
  75. ?? ??? ?ImageIcon img = new ImageIcon(ClassLoader.getSystemResource("image/beijjing3.jpg"));
  76. ?? ??? ?lb_image = new JLabel(img);
  77. ?? ??? ?lb_image.setBounds(10, 10, img.getIconWidth(), img.getIconHeight());
  78. ?? ??? ?fundesk.add(lb_image, new Integer(Integer.MIN_VALUE));
  79. ?
  80. ?? ??? ?main_panel.add(lb_welcome, BorderLayout.NORTH);
  81. ?? ??? ?main_panel.add(fun_panel, BorderLayout.EAST);
  82. ?? ??? ?main_panel.add(fundesk, BorderLayout.CENTER);
  83. ?
  84. ?? ??? ?// 为了不让线程阻塞,来调用线程
  85. ?? ??? ?// 放入队列当中
  86. ?? ??? ?EventQueue.invokeLater(new Runnable() {
  87. ?
  88. ?? ??? ??? ?public void run() {
  89. ?? ??? ??? ??? ?new Thread(new thread()).start();
  90. ?? ??? ??? ?}
  91. ?? ??? ?});
  92. ?
  93. ?? ??? ?this.setTitle("管理员功能界面");
  94. ?? ??? ?this.getContentPane().add(main_panel);
  95. ?? ??? ?this.setSize(880, 600);
  96. ?? ??? ?this.setResizable(false);
  97. ?? ??? ?this.setVisible(true);
  98. ?? ??? ?this.setLocationRelativeTo(null);
  99. ?? ??? ?this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  100. ?? ?}
  101. ?
  102. ?? ?// 开启线程使得欢迎标签动起来
  103. ?? ?// 这是单线程
  104. ?? ?private class thread implements Runnable {
  105. ?
  106. ?? ??? ?@Override
  107. ?? ??? ?public void run() {
  108. ?? ??? ??? ?while (true) {// 死循环让其一直移动
  109. ?? ??? ??? ??? ?for (int i = 900; i > -700; i--) {
  110. ?? ??? ??? ??? ??? ?// for(int i=-100;i<900;i++){
  111. ?? ??? ??? ??? ??? ?try {
  112. ?? ??? ??? ??? ??? ??? ?Thread.sleep(10);// 让线程休眠100毫秒
  113. ?? ??? ??? ??? ??? ?} catch (InterruptedException e) {
  114. ?? ??? ??? ??? ??? ??? ?e.printStackTrace();
  115. ?? ??? ??? ??? ??? ?}
  116. ?? ??? ??? ??? ??? ?lb_welcome.setLocation(i, 5);
  117. ?? ??? ??? ??? ?}
  118. ?? ??? ??? ?}
  119. ?? ??? ?}
  120. ?
  121. ?? ?}
  122. ?
  123. ?? ?private void RegisterListener() {
  124. ?? ??? ?oper_User.addActionListener(new ActionListener() {
  125. ?
  126. ?? ??? ??? ?@Override
  127. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  128. ?? ??? ??? ??? ?operUserView ouv = new operUserView();
  129. ?? ??? ??? ??? ?fundesk.add(ouv);
  130. ?? ??? ??? ??? ?ouv.toFront();
  131. ?? ??? ??? ?}
  132. ?? ??? ?});
  133. ?
  134. ?? ??? ?oper_Cinema.addActionListener(new ActionListener() {
  135. ?
  136. ?? ??? ??? ?@Override
  137. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  138. ?? ??? ??? ??? ?operCinemaView ocv = new operCinemaView();
  139. ?? ??? ??? ??? ?fundesk.add(ocv);
  140. ?? ??? ??? ??? ?ocv.toFront();
  141. ?? ??? ??? ?}
  142. ?? ??? ?});
  143. ?
  144. ?? ??? ?oper_Hall.addActionListener(new ActionListener() {
  145. ?
  146. ?? ??? ??? ?@Override
  147. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  148. ?? ??? ??? ??? ?operHallView ohv = new operHallView();
  149. ?? ??? ??? ??? ?fundesk.add(ohv);
  150. ?? ??? ??? ??? ?ohv.toFront();
  151. ?? ??? ??? ?}
  152. ?? ??? ?});
  153. ?
  154. ?? ??? ?oper_Session.addActionListener(new ActionListener() {
  155. ?
  156. ?? ??? ??? ?@Override
  157. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  158. ?? ??? ??? ??? ?operSessionView osv = new operSessionView();
  159. ?? ??? ??? ??? ?fundesk.add(osv);
  160. ?? ??? ??? ??? ?osv.toFront();
  161. ?? ??? ??? ?}
  162. ?? ??? ?});
  163. ?
  164. ?? ??? ?oper_Movie.addActionListener(new ActionListener() {
  165. ?
  166. ?? ??? ??? ?@Override
  167. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  168. ?? ??? ??? ??? ?operMovieView omv = new operMovieView();
  169. ?? ??? ??? ??? ?fundesk.add(omv);
  170. ?? ??? ??? ??? ?omv.toFront();
  171. ?? ??? ??? ?}
  172. ?? ??? ?});
  173. ?? ??? ?back.addActionListener(new ActionListener() {
  174. ?
  175. ?? ??? ??? ?@Override
  176. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  177. ?? ??? ??? ??? ?new Login();
  178. ?? ??? ??? ??? ?AdminMainView.this.dispose();
  179. ?? ??? ??? ?}
  180. ?? ??? ?});
  181. ?? ?}
  182. }

MovieInfoView.java

  1. package view;
  2. ?
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.text.SimpleDateFormat;
  8. import java.util.List;
  9. ?
  10. import javax.swing.GroupLayout;
  11. import javax.swing.GroupLayout.Alignment;
  12. import javax.swing.ImageIcon;
  13. import javax.swing.JButton;
  14. import javax.swing.JFrame;
  15. import javax.swing.JLabel;
  16. import javax.swing.JPanel;
  17. import javax.swing.JScrollPane;
  18. import javax.swing.JTable;
  19. import javax.swing.JTextField;
  20. import javax.swing.LayoutStyle.ComponentPlacement;
  21. import javax.swing.border.EmptyBorder;
  22. import javax.swing.table.DefaultTableModel;
  23. ?
  24. import entity.Comment;
  25. import entity.Movie;
  26. import entity.User;
  27. import service.CommentService;
  28. import service.MovieService;
  29. import service.UserService;
  30. import serviceimpl.CommentServiceImpl;
  31. import serviceimpl.MovieServiceImpl;
  32. import serviceimpl.UserServiceImpl;
  33. ?
  34. public class MovieInfoView extends JFrame {
  35. ?
  36. ?? ?private JPanel contentPane;
  37. ?? ?private JTable table;
  38. ?? ?JScrollPane scrollPane = null;
  39. ?
  40. ?? ?Movie movie = null;
  41. ?? ?User user = null;
  42. ?? ?MovieService ms = null;
  43. ?? ?CommentService cs = null;
  44. ?? ?UserService us = null;
  45. ?
  46. ?? ?public MovieInfoView(Movie movie, User user) {
  47. ?? ??? ?this.movie = movie;
  48. ?? ??? ?this.user = user;
  49. ?? ??? ?ms = new MovieServiceImpl();
  50. ?? ??? ?cs = new CommentServiceImpl();
  51. ?? ??? ?us = new UserServiceImpl();
  52. ?? ??? ?setTitle("用户选票界面");
  53. ?? ??? ?setBounds(260, 130, 620, 600);
  54. ?? ??? ?this.setLocationRelativeTo(null);
  55. ?
  56. ?? ??? ?contentPane = new JPanel();
  57. ?? ??? ?contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  58. ?? ??? ?setContentPane(contentPane);
  59. ?
  60. ?? ??? ?JLabel lblNewLabel = new JLabel("New label");
  61. ?? ??? ?lblNewLabel.setIcon(new ImageIcon("image/" + movie.getImg()));
  62. ?
  63. ?? ??? ?JLabel label = new JLabel("正在热映···");
  64. ?
  65. ?? ??? ?JLabel lblNewLabel_1 = new JLabel("影片名:");
  66. ?? ??? ?lblNewLabel_1.setFont(new Font("楷体", Font.BOLD, 18));
  67. ?
  68. ?? ??? ?JLabel label_1 = new JLabel("类型:");
  69. ?
  70. ?? ??? ?JLabel label_2 = new JLabel("时长:");
  71. ?
  72. ?? ??? ?JLabel label_3 = new JLabel("电影详情:");
  73. ?
  74. ?? ??? ?JLabel label_4 = new JLabel(movie.getMname());
  75. ?? ??? ?label_4.setFont(new Font("楷体", Font.BOLD, 18));
  76. ?
  77. ?? ??? ?JButton btnNewButton = new JButton("购买");
  78. ?? ??? ?btnNewButton.setForeground(Color.BLUE);
  79. ?? ??? ?btnNewButton.addActionListener(new ActionListener() {
  80. ?
  81. ?? ??? ??? ?@Override
  82. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  83. ?? ??? ??? ??? ?new UserUi(user, 3);
  84. ?? ??? ??? ??? ?movie.getMovie_id();
  85. ?? ??? ??? ??? ?List<Movie> movieByName = ms.getMovieByName(movie.getMname());
  86. ?
  87. ?? ??? ??? ??? ?for (Movie movie2 : movieByName) {
  88. ?? ??? ??? ??? ??? ?System.out.println(movie2);
  89. ?? ??? ??? ??? ?}
  90. ?? ??? ??? ??? ?MovieInfoView.this.dispose();
  91. ?
  92. ?? ??? ??? ?}
  93. ?? ??? ?});
  94. ?
  95. ?? ??? ?JButton button = new JButton("取消");
  96. ?? ??? ?button.setForeground(Color.RED);
  97. ?? ??? ?button.addActionListener(new ActionListener() {
  98. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  99. ?? ??? ??? ??? ?MovieInfoView.this.dispose();
  100. ?? ??? ??? ?}
  101. ?? ??? ?});
  102. ?
  103. ?? ??? ?scrollPane = new JScrollPane();
  104. ?? ??? ?scrollPane.setEnabled(false);
  105. ?? ??? ?scrollPane.setVisible(false);
  106. ?
  107. ?? ??? ?JButton button_1 = new JButton("查看评论");
  108. ?? ??? ?button_1.addActionListener(new ActionListener() {
  109. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  110. ?? ??? ??? ??? ?scrollPane.setVisible(true);
  111. ?? ??? ??? ??? ?showComment();
  112. ?? ??? ??? ??? ?table.repaint();
  113. ?
  114. ?? ??? ??? ?}
  115. ?? ??? ?});
  116. ?
  117. ?? ??? ?button_1.setForeground(Color.MAGENTA);
  118. ?
  119. ?? ??? ?JLabel lblNewLabel_2 = new JLabel("欢迎来到电影详情界面");
  120. ?? ??? ?lblNewLabel_2.setFont(new Font("新宋体", Font.BOLD, 20));
  121. ?? ??? ?lblNewLabel_2.setForeground(Color.BLACK);
  122. ?
  123. ?? ??? ?JLabel label_5 = new JLabel(movie.getType());
  124. ?
  125. ?? ??? ?JLabel label_6 = new JLabel(movie.getDuration() + "分钟");
  126. ?
  127. ?? ??? ?JLabel label_7 = new JLabel(movie.getDetail());
  128. ?
  129. ?? ??? ?GroupLayout gl_contentPane = new GroupLayout(contentPane);
  130. ?? ??? ?gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING).addGroup(gl_contentPane
  131. ?? ??? ??? ??? ?.createSequentialGroup()
  132. ?? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
  133. ?? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addGap(218)
  134. ?? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
  135. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addComponent(label_3)
  136. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addPreferredGap(ComponentPlacement.RELATED).addComponent(label_7,
  137. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE))
  138. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addComponent(lblNewLabel_1)
  139. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addPreferredGap(ComponentPlacement.RELATED)
  140. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_4, GroupLayout.PREFERRED_SIZE, 137,
  141. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE))
  142. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup()
  143. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
  144. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_2)
  145. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup()
  146. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addPreferredGap(ComponentPlacement.RELATED)
  147. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_1)))
  148. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGap(4)
  149. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
  150. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_6, GroupLayout.PREFERRED_SIZE, 55,
  151. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE)
  152. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_5, GroupLayout.PREFERRED_SIZE, 82,
  153. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE)))
  154. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addComponent(btnNewButton)
  155. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGap(18)
  156. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(button, GroupLayout.PREFERRED_SIZE, 71,
  157. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE)
  158. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGap(18).addComponent(button_1))))
  159. ?? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addGap(36).addComponent(label))
  160. ?? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addGap(170).addComponent(lblNewLabel_2))
  161. ?? ??? ??? ??? ??? ??? ?.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
  162. ?? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addGap(84).addComponent(scrollPane,
  163. ?? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE, 464, GroupLayout.PREFERRED_SIZE)))
  164. ?? ??? ??? ??? ?.addContainerGap(46, Short.MAX_VALUE)));
  165. ?? ??? ?gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
  166. ?? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup()
  167. ?? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane
  168. ?? ??? ??? ??? ??? ??? ??? ??? ?.createParallelGroup(Alignment.LEADING)
  169. ?? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addGap(46).addComponent(label)
  170. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addPreferredGap(ComponentPlacement.UNRELATED)
  171. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(lblNewLabel, GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))
  172. ?? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createSequentialGroup().addContainerGap()
  173. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(lblNewLabel_2).addGap(58)
  174. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
  175. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(lblNewLabel_1).addComponent(label_4,
  176. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
  177. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addPreferredGap(ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
  178. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
  179. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_1).addComponent(label_5))
  180. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGap(18)
  181. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
  182. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_2).addComponent(label_6))
  183. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGap(18)
  184. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
  185. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(label_3).addComponent(label_7))
  186. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGap(125)
  187. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
  188. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(btnNewButton).addComponent(button)
  189. ?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?.addComponent(button_1))))
  190. ?? ??? ??? ??? ??? ??? ?.addGap(28)
  191. ?? ??? ??? ??? ??? ??? ?.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)));
  192. ?
  193. ?? ??? ?showComment();
  194. ?? ??? ?scrollPane.setViewportView(table);
  195. ?? ??? ?contentPane.setLayout(gl_contentPane);
  196. ?? ??? ?this.setVisible(true);
  197. ?? ?}
  198. ?
  199. ?? ?public void showComment() {
  200. ?? ??? ?List<Comment> commlist = cs.getAllCommentByMovieId(movie.getMovie_id());
  201. ?? ??? ?int recordrow = 0;
  202. ?
  203. ?? ??? ?if (commlist != null) {
  204. ?? ??? ??? ?recordrow = commlist.size();
  205. ?? ??? ?}
  206. ?? ??? ?String[][] rinfo = new String[recordrow][3];
  207. ?
  208. ?? ??? ?SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd hh:mm");
  209. ?? ??? ?for (int i = 0; i < recordrow; i++) {
  210. ?? ??? ??? ?for (int j = 0; j < 3; j++) {
  211. ?? ??? ??? ??? ?rinfo[i][j] = new String();
  212. ?
  213. ?? ??? ??? ??? ?rinfo[i][0] = us.queryUserById(commlist.get(i).getUser_id()).getUname();
  214. ?? ??? ??? ??? ?rinfo[i][1] = commlist.get(i).getContent();
  215. ?? ??? ??? ??? ?rinfo[i][2] = sdf.format(commlist.get(i).getDatetime());
  216. ?? ??? ??? ?}
  217. ?? ??? ?}
  218. ?
  219. ?? ??? ?String[] tbheadnames = { "用户名", "评论内容", "评论时间" };
  220. ?
  221. ?? ??? ?table = new JTable(rinfo, tbheadnames);
  222. ?? ??? ?table.setBorder(null);
  223. ?? ??? ?table.setRowHeight(20);
  224. ?? ??? ?table.setEnabled(false);
  225. ?? ??? ?table.getColumnModel().getColumn(0).setPreferredWidth(30);
  226. ?? ??? ?table.getTableHeader().setFont(new Font("楷体", 1, 20));
  227. ?? ??? ?table.getTableHeader().setBackground(Color.CYAN);
  228. ?? ??? ?table.getTableHeader().setReorderingAllowed(false); // 不可交换顺序
  229. ?? ??? ?table.getTableHeader().setResizingAllowed(true); // 不可拉动表格
  230. ?
  231. ?? ??? ?scrollPane.add(table);
  232. ?? ??? ?scrollPane.setBorder(null);
  233. ?
  234. ?? ??? ?table.repaint();
  235. ?
  236. ?? ?}
  237. }

operCinemaView.java

  1. package view;
  2. ?
  3. import java.awt.BorderLayout;
  4. import java.awt.GridLayout;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.awt.event.MouseAdapter;
  8. import java.awt.event.MouseEvent;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. ?
  12. import javax.swing.BorderFactory;
  13. import javax.swing.JButton;
  14. import javax.swing.JComboBox;
  15. import javax.swing.JInternalFrame;
  16. import javax.swing.JLabel;
  17. import javax.swing.JOptionPane;
  18. import javax.swing.JPanel;
  19. import javax.swing.JTable;
  20. import javax.swing.JTextField;
  21. import javax.swing.event.TableModelListener;
  22. import javax.swing.table.TableModel;
  23. ?
  24. import entity.Cinema;
  25. import service.CinemaService;
  26. import serviceimpl.CinemaServiceImpl;
  27. ?
  28. public class operCinemaView extends JInternalFrame {
  29. ?? ?private JPanel pl_main = null;
  30. ?? ?private JPanel pl_button = null;
  31. ?? ?private JPanel pl_text = null;
  32. ?? ?private JTable table = null;
  33. ?? ?private JButton btn_add = null;
  34. ?? ?private JButton btn_query = null;
  35. ?? ?private JButton btn_del = null;
  36. ?? ?private JComboBox<String> cb_query = null;
  37. ?? ?private JButton btn_back = null;
  38. ?? ?private JLabel lb_name = null;
  39. ?? ?private JLabel lb_address = null;
  40. ?? ?private JTextField tf_qname = null;// 查询时输入的名称
  41. ?? ?private JTextField tf_name = null;// 添加输入的名称
  42. ?? ?private JTextField tf_address = null;
  43. ?? ?private CinemaService cinemabiz = null;
  44. ?? ?private List<Cinema> cinemaList = null;
  45. ?? ?private CinemaInfoTableModel infoTableModel = null;
  46. //?? ?private List<Hall> hallList = null;
  47. //?? ?private List<Session> sessionList = null;
  48. //?? ?private HallBiz hallbiz = null;
  49. //?? ?private SessionBiz sessionbiz = null;
  50. ?
  51. ?? ?public operCinemaView() {
  52. ?? ??? ?cinemabiz = new CinemaServiceImpl();
  53. //?? ??? ?hallbiz = new HallBizImpl();
  54. //?? ??? ?sessionbiz = new SessionBizImpl();
  55. ?? ??? ?init();
  56. ?? ??? ?RegisterListener();
  57. ?? ?}
  58. ?
  59. ?? ?private void init() {
  60. ?? ??? ?pl_main = new JPanel(new BorderLayout());
  61. ?? ??? ?pl_button = new JPanel(new GridLayout(8, 1, 0, 40));
  62. ?? ??? ?pl_text = new JPanel(new GridLayout(1, 4));
  63. ?? ??? ?cinemaList = new ArrayList<Cinema>();
  64. ?? ??? ?table = new JTable();
  65. ?? ??? ?refreshTable(cinemaList);
  66. ?? ??? ?cb_query = new JComboBox<String>(new String[] { "查询所有影院", "按名字查找影院" });
  67. ?? ??? ?tf_qname = new JTextField(8);
  68. ?? ??? ?tf_qname.setEnabled(false);
  69. ?? ??? ?btn_query = new JButton("查询");
  70. ?? ??? ?btn_add = new JButton("增添影院");
  71. ?? ??? ?btn_del = new JButton("删除影院");
  72. ?? ??? ?btn_del.setEnabled(false);
  73. ?? ??? ?btn_back = new JButton("退出窗口");
  74. ?? ??? ?lb_name = new JLabel("影院名称: ");
  75. ?? ??? ?tf_name = new JTextField(8);
  76. ?? ??? ?lb_address = new JLabel("影院地址: ");
  77. ?? ??? ?tf_address = new JTextField(12);
  78. ?? ??? ?pl_main.add(table.getTableHeader(), BorderLayout.PAGE_START);
  79. ?? ??? ?pl_main.add(table);
  80. ?? ??? ?pl_main.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(null, null), "查询信息"));
  81. ?? ??? ?pl_button.add(new JLabel());
  82. ?? ??? ?pl_button.add(cb_query);
  83. ?? ??? ?pl_button.add(tf_qname);
  84. ?? ??? ?pl_button.add(btn_query);
  85. ?? ??? ?pl_button.add(btn_add);
  86. ?? ??? ?pl_button.add(btn_del);
  87. ?? ??? ?pl_button.add(new JLabel());
  88. ?? ??? ?pl_button.add(btn_back);
  89. ?
  90. ?? ??? ?pl_text.add(lb_name);
  91. ?? ??? ?pl_text.add(tf_name);
  92. ?? ??? ?pl_text.add(lb_address);
  93. ?? ??? ?pl_text.add(tf_address);
  94. ?? ??? ?this.add(pl_main, BorderLayout.CENTER);
  95. ?? ??? ?this.add(pl_button, BorderLayout.EAST);
  96. ?? ??? ?this.add(pl_text, BorderLayout.NORTH);
  97. ?? ??? ?this.setVisible(true);
  98. ?? ??? ?this.setTitle("影院操作界面");
  99. ?? ??? ?this.setSize(700, 530);
  100. ?? ??? ?this.setIconifiable(true);
  101. ?? ??? ?this.setClosable(true);
  102. ?? ??? ?this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  103. ?? ?}
  104. ?
  105. ?? ?private void RegisterListener() {
  106. ?
  107. ?? ??? ?table.addMouseListener(new MouseAdapter() {
  108. ?? ??? ??? ?@Override
  109. ?? ??? ??? ?public void mouseClicked(MouseEvent e) {
  110. ?? ??? ??? ??? ?if (table.getSelectedRow() != -1) {
  111. ?? ??? ??? ??? ??? ?btn_del.setEnabled(true);
  112. ?? ??? ??? ??? ?}
  113. ?? ??? ??? ??? ?int row = table.getSelectedRow();
  114. ?? ??? ??? ??? ?String name = table.getValueAt(row, 1).toString();
  115. ?? ??? ??? ??? ?String address = table.getValueAt(row, 2).toString();
  116. ?? ??? ??? ??? ?tf_name.setText(name);
  117. ?? ??? ??? ??? ?tf_address.setText(address);
  118. ?? ??? ??? ?}
  119. ?? ??? ?});
  120. ?? ??? ?cb_query.addActionListener(new ActionListener() {
  121. ?
  122. ?? ??? ??? ?@Override
  123. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  124. ?? ??? ??? ??? ?if (cb_query.getSelectedIndex() + 1 == 2) {
  125. ?? ??? ??? ??? ??? ?tf_qname.setEnabled(true);
  126. ?? ??? ??? ??? ?} else {
  127. ?? ??? ??? ??? ??? ?tf_qname.setEnabled(false);
  128. ?? ??? ??? ??? ?}
  129. ?? ??? ??? ?}
  130. ?? ??? ?});
  131. ?? ??? ?btn_query.addActionListener(new ActionListener() {
  132. ?
  133. ?? ??? ??? ?@Override
  134. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  135. ?? ??? ??? ??? ?if (cb_query.getSelectedIndex() + 1 == 1) {
  136. ?? ??? ??? ??? ??? ?cinemaList = cinemabiz.queryAllCinema();
  137. ?? ??? ??? ??? ??? ?refreshTable(cinemaList);
  138. ?? ??? ??? ??? ?} else {
  139. ?? ??? ??? ??? ??? ?String name = tf_qname.getText().trim();
  140. ?? ??? ??? ??? ??? ?cinemaList = cinemabiz.queryCinemaByName(name);
  141. ?? ??? ??? ??? ??? ?refreshTable(cinemaList);
  142. ?? ??? ??? ??? ?}
  143. ?? ??? ??? ?}
  144. ?? ??? ?});
  145. ?
  146. ?? ??? ?btn_add.addActionListener(new ActionListener() {
  147. ?
  148. ?? ??? ??? ?@Override
  149. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  150. ?? ??? ??? ??? ?String name = tf_name.getText().trim();
  151. ?? ??? ??? ??? ?String address = tf_address.getText().trim();
  152. ?? ??? ??? ??? ?if (name.equals("")) {
  153. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operCinemaView.this, "影院名称不能为空!");
  154. ?? ??? ??? ??? ?} else if (address.equals("")) {
  155. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operCinemaView.this, "影院地址不能为空!");
  156. ?? ??? ??? ??? ?} else {
  157. ?? ??? ??? ??? ??? ?int flag = JOptionPane.showConfirmDialog(operCinemaView.this, "确认是否添加?", "确认信息",
  158. ?? ??? ??? ??? ??? ??? ??? ?JOptionPane.YES_NO_OPTION);
  159. ?? ??? ??? ??? ??? ?if (flag == JOptionPane.YES_OPTION) {
  160. ?? ??? ??? ??? ??? ??? ?Cinema cinema = new Cinema(name, address);
  161. ?? ??? ??? ??? ??? ??? ?boolean res = cinemabiz.addCinema(cinema);
  162. ?? ??? ??? ??? ??? ??? ?if (res) {
  163. ?? ??? ??? ??? ??? ??? ??? ?cinemaList = cinemabiz.queryAllCinema();
  164. ?? ??? ??? ??? ??? ??? ??? ?refreshTable(cinemaList);
  165. ?? ??? ??? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operCinemaView.this, "添加成功!");
  166. ?? ??? ??? ??? ??? ??? ?} else {
  167. ?? ??? ??? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operCinemaView.this, "添加失败!");
  168. ?? ??? ??? ??? ??? ??? ?}
  169. ?? ??? ??? ??? ??? ?}
  170. ?? ??? ??? ??? ?}
  171. ?? ??? ??? ?}
  172. ?? ??? ?});
  173. ?
  174. ?? ??? ?btn_del.addActionListener(new ActionListener() {
  175. ?
  176. ?? ??? ??? ?@Override
  177. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  178. ?? ??? ??? ??? ?int row = table.getSelectedRow();
  179. ?? ??? ??? ??? ?int id = (Integer) table.getValueAt(row, 0);
  180. ?? ??? ??? ??? ?int flag = JOptionPane.showConfirmDialog(operCinemaView.this, "确认是否删除此影院?", "确认信息",
  181. ?? ??? ??? ??? ??? ??? ?JOptionPane.YES_NO_OPTION);
  182. ?? ??? ??? ??? ?if (flag == JOptionPane.YES_OPTION) {
  183. ?? ??? ??? ??? ??? ?boolean res = cinemabiz.deleteCinemaById(id);
  184. ?? ??? ??? ??? ??? ?/*
  185. ?? ??? ??? ??? ??? ? * if(res) { //更新数据 hallList = hallbiz.queryAllHall(); int hid = 0; for(int i =
  186. ?? ??? ??? ??? ??? ? * 0; i < hallList.size(); i++) { if(id == hallList.get(i).getCid()) { hid =
  187. ?? ??? ??? ??? ??? ? * hallList.get(i).getId(); hallbiz.delHall(hid); } } sessionList =
  188. ?? ??? ??? ??? ??? ? * sessionbiz.queryAllSession(); for(int i = 0; i < sessionList.size(); i++) {
  189. ?? ??? ??? ??? ??? ? * if(hid == sessionList.get(i).getHid()) {
  190. ?? ??? ??? ??? ??? ? * sessionbiz.delSession(sessionList.get(i).getId()); } } }
  191. ?? ??? ??? ??? ??? ? */
  192. ?? ??? ??? ??? ??? ?cinemaList = cinemabiz.queryAllCinema();
  193. ?? ??? ??? ??? ??? ?refreshTable(cinemaList);
  194. ?? ??? ??? ??? ?}
  195. ?? ??? ??? ?}
  196. ?? ??? ?});
  197. ?? ??? ?btn_back.addActionListener(new ActionListener() {
  198. ?
  199. ?? ??? ??? ?@Override
  200. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  201. ?? ??? ??? ??? ?operCinemaView.this.dispose();
  202. ?? ??? ??? ?}
  203. ?? ??? ?});
  204. ?? ?}
  205. ?
  206. ?? ?public class CinemaInfoTableModel implements TableModel {
  207. ?? ??? ?public List<Cinema> cinemaList = null;
  208. ?
  209. ?? ??? ?public CinemaInfoTableModel(List<Cinema> cinemaList) {
  210. ?? ??? ??? ?this.cinemaList = cinemaList;
  211. ?? ??? ?}
  212. ?
  213. ?? ??? ?@Override
  214. ?? ??? ?public int getRowCount() {
  215. ?? ??? ??? ?return cinemaList.size();
  216. ?? ??? ?}
  217. ?
  218. ?? ??? ?@Override
  219. ?? ??? ?public int getColumnCount() {
  220. ?? ??? ??? ?return 3;
  221. ?? ??? ?}
  222. ?
  223. ?? ??? ?@Override
  224. ?? ??? ?public String getColumnName(int columnIndex) {
  225. ?? ??? ??? ?if (columnIndex == 0) {
  226. ?? ??? ??? ??? ?return "影院ID";
  227. ?? ??? ??? ?} else if (columnIndex == 1) {
  228. ?? ??? ??? ??? ?return "影院名称";
  229. ?? ??? ??? ?} else if (columnIndex == 2) {
  230. ?? ??? ??? ??? ?return "影院地址";
  231. ?? ??? ??? ?} else {
  232. ?? ??? ??? ??? ?return "出错";
  233. ?? ??? ??? ?}
  234. ?? ??? ?}
  235. ?
  236. ?? ??? ?@Override
  237. ?? ??? ?public Class<?> getColumnClass(int columnIndex) {
  238. ?? ??? ??? ?return String.class;
  239. ?? ??? ?}
  240. ?
  241. ?? ??? ?@Override
  242. ?? ??? ?public boolean isCellEditable(int rowIndex, int columnIndex) {
  243. ?? ??? ??? ?return false;
  244. ?? ??? ?}
  245. ?
  246. ?? ??? ?@Override
  247. ?? ??? ?public Object getValueAt(int rowIndex, int columnIndex) {
  248. ?? ??? ??? ?Cinema cinema = cinemaList.get(rowIndex);
  249. ?? ??? ??? ?if (columnIndex == 0) {
  250. ?? ??? ??? ??? ?return cinema.getCinema_id();
  251. ?? ??? ??? ?} else if (columnIndex == 1) {
  252. ?? ??? ??? ??? ?return cinema.getCname();
  253. ?? ??? ??? ?} else if (columnIndex == 2) {
  254. ?? ??? ??? ??? ?return cinema.getAddress();
  255. ?? ??? ??? ?} else {
  256. ?? ??? ??? ??? ?return "出错";
  257. ?? ??? ??? ?}
  258. ?? ??? ?}
  259. ?
  260. ?? ??? ?@Override
  261. ?? ??? ?public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  262. ?? ??? ??? ?// TODO Auto-generated method stub
  263. ?
  264. ?? ??? ?}
  265. ?
  266. ?? ??? ?@Override
  267. ?? ??? ?public void addTableModelListener(TableModelListener l) {
  268. ?? ??? ??? ?// TODO Auto-generated method stub
  269. ?
  270. ?? ??? ?}
  271. ?
  272. ?? ??? ?@Override
  273. ?? ??? ?public void removeTableModelListener(TableModelListener l) {
  274. ?? ??? ??? ?// TODO Auto-generated method stub
  275. ?
  276. ?? ??? ?}
  277. ?? ?}
  278. ?
  279. ?? ?private void refreshTable(List<Cinema> cinemaList) {
  280. ?? ??? ?infoTableModel = new CinemaInfoTableModel(cinemaList);
  281. ?? ??? ?table.setModel(infoTableModel);
  282. ?? ??? ?table.setRowHeight(20);
  283. ?? ?}
  284. }

operHallView.java

  1. package view;
  2. ?
  3. import java.awt.BorderLayout;
  4. import java.awt.GridLayout;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.awt.event.MouseAdapter;
  8. import java.awt.event.MouseEvent;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. ?
  12. import javax.swing.BorderFactory;
  13. import javax.swing.JButton;
  14. import javax.swing.JInternalFrame;
  15. import javax.swing.JLabel;
  16. import javax.swing.JOptionPane;
  17. import javax.swing.JPanel;
  18. import javax.swing.JTable;
  19. import javax.swing.JTextField;
  20. import javax.swing.event.TableModelListener;
  21. import javax.swing.table.TableModel;
  22. ?
  23. import entity.Cinema;
  24. import entity.Hall;
  25. import entity.Session;
  26. import service.CinemaService;
  27. import service.HallService;
  28. import serviceimpl.CinemaServiceImpl;
  29. import serviceimpl.HallServiceImpl;
  30. import serviceimpl.SessionServiceImpl;
  31. import util.Check;
  32. ?
  33. public class operHallView extends JInternalFrame {
  34. ?? ?private JPanel pl_main = null;
  35. ?? ?private JPanel pl_button = null;
  36. ?? ?private JPanel pl_text = null;
  37. ?? ?private JTable table = null;
  38. ?? ?private JButton btn_add = null;
  39. ?? ?private JButton btn_del = null;
  40. ?? ?private JButton btn_query = null;
  41. ?? ?private JButton btn_back = null;
  42. ?? ?private JLabel lb_name = null;
  43. ?? ?private JLabel lb_cid = null;
  44. ?? ?private JLabel lb_capacity = null;
  45. ?? ?private JTextField tf_name = null;// 添加输入的名称
  46. ?? ?private JTextField tf_cid = null;// 添加时输入的所属影院id
  47. ?? ?private JTextField tf_capacity = null;// 添加输入的名称
  48. ?? ?private HallService hallbiz = null;
  49. ?? ?private CinemaService cinemabiz = null;
  50. ?? ?private SessionServiceImpl sessionbiz = null;
  51. ?? ?private List<Hall> hallList = null;
  52. ?? ?private HallInfoTableModel infoTableModel = null;
  53. ?
  54. ?? ?public operHallView() {
  55. ?? ??? ?hallbiz = new HallServiceImpl();
  56. ?? ??? ?cinemabiz = new CinemaServiceImpl();// 查询出所有的影院与cid进行匹配,显示影院名称
  57. ?? ??? ?sessionbiz = new SessionServiceImpl();
  58. ?? ??? ?init();
  59. ?? ??? ?RegisterListener();
  60. ?? ?}
  61. ?
  62. ?? ?private void init() {
  63. ?? ??? ?pl_main = new JPanel(new BorderLayout());
  64. ?? ??? ?pl_button = new JPanel(new GridLayout(6, 1, 0, 40));
  65. ?? ??? ?pl_text = new JPanel(new GridLayout(1, 6));
  66. ?? ??? ?hallList = new ArrayList<Hall>();
  67. ?? ??? ?table = new JTable();
  68. ?? ??? ?// 绑定JTabel,呈现数据
  69. ?? ??? ?refreshTable(hallList);
  70. ?? ??? ?btn_query = new JButton("查询所有场厅");
  71. ?? ??? ?btn_add = new JButton("增添场厅");
  72. ?? ??? ?btn_del = new JButton("删除场厅");
  73. ?? ??? ?btn_del.setEnabled(false);
  74. ?? ??? ?btn_back = new JButton("退出窗口");
  75. ?? ??? ?tf_name = new JTextField(8);
  76. ?? ??? ?tf_cid = new JTextField(8);
  77. ?? ??? ?tf_capacity = new JTextField(8);
  78. ?? ??? ?lb_name = new JLabel("场厅名称");
  79. ?? ??? ?lb_cid = new JLabel("所属影院id");
  80. ?? ??? ?lb_capacity = new JLabel("场厅容量");
  81. ?? ??? ?pl_main.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(null, null), "查询信息"));
  82. ?? ??? ?pl_main.add(table.getTableHeader(), BorderLayout.PAGE_START);
  83. ?? ??? ?pl_main.add(table);
  84. ?? ??? ?this.add(pl_main, BorderLayout.CENTER);
  85. ?
  86. ?? ??? ?pl_button.add(new JLabel());
  87. ?? ??? ?pl_button.add(btn_query);
  88. ?? ??? ?pl_button.add(btn_add);
  89. ?? ??? ?pl_button.add(btn_del);
  90. ?? ??? ?pl_button.add(new JLabel());
  91. ?? ??? ?pl_button.add(btn_back);
  92. ?? ??? ?this.add(pl_button, BorderLayout.EAST);
  93. ?
  94. ?? ??? ?pl_text.add(lb_name);
  95. ?? ??? ?pl_text.add(tf_name);
  96. ?? ??? ?pl_text.add(lb_cid);
  97. ?? ??? ?pl_text.add(tf_cid);
  98. ?? ??? ?pl_text.add(lb_capacity);
  99. ?? ??? ?pl_text.add(tf_capacity);
  100. ?? ??? ?this.add(pl_text, BorderLayout.NORTH);
  101. ?? ??? ?this.setVisible(true);
  102. ?? ??? ?this.setTitle("场厅操作界面");
  103. ?? ??? ?this.setSize(700, 530);
  104. ?? ??? ?this.setIconifiable(true);
  105. ?? ??? ?this.setClosable(true);
  106. ?? ??? ?this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  107. ?? ?}
  108. ?
  109. ?? ?private void RegisterListener() {
  110. ?? ??? ?table.addMouseListener(new MouseAdapter() {
  111. ?? ??? ??? ?@Override
  112. ?? ??? ??? ?public void mouseClicked(MouseEvent e) {
  113. ?? ??? ??? ??? ?// 加入选中一行,删除按钮变为可用
  114. ?? ??? ??? ??? ?if (table.getSelectedRow() != -1) {
  115. ?? ??? ??? ??? ??? ?btn_del.setEnabled(true);
  116. ?? ??? ??? ??? ?}
  117. ?? ??? ??? ??? ?int row = table.getSelectedRow();
  118. ?? ??? ??? ??? ?String name = table.getValueAt(row, 1).toString();
  119. ?? ??? ??? ??? ?String cid = table.getValueAt(row, 2).toString();
  120. ?? ??? ??? ??? ?String capacity = table.getValueAt(row, 3).toString();
  121. ?? ??? ??? ??? ?tf_name.setText(name);
  122. ?? ??? ??? ??? ?tf_cid.setText(cid);
  123. ?? ??? ??? ??? ?tf_capacity.setText(capacity);
  124. ?? ??? ??? ?}
  125. ?? ??? ?});
  126. ?
  127. ?? ??? ?btn_add.addActionListener(new ActionListener() {
  128. ?
  129. ?? ??? ??? ?@Override
  130. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  131. ?? ??? ??? ??? ?String name = tf_name.getText().trim();
  132. ?? ??? ??? ??? ?String cid = tf_cid.getText().trim();
  133. ?? ??? ??? ??? ?String capacity = tf_capacity.getText().trim();
  134. ?? ??? ??? ??? ?if (name.equals("")) {
  135. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "场厅名称不能为空!");
  136. ?? ??? ??? ??? ?} else if (cid.equals("")) {
  137. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "所属影院id不能为空!");
  138. ?? ??? ??? ??? ?} else if (capacity.equals("")) {
  139. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "场厅容量不能为空!");
  140. ?? ??? ??? ??? ?} else if (!Check.isNumber(cid)) {
  141. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "所属影院id只能为数字!");
  142. ?? ??? ??? ??? ?} else if (!Check.isNumber(capacity)) {
  143. ?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "场厅容量只能为数字!");
  144. ?? ??? ??? ??? ?} else {
  145. ?? ??? ??? ??? ??? ?int flag = JOptionPane.showConfirmDialog(operHallView.this, "是否添加此场厅?", "确认信息",
  146. ?? ??? ??? ??? ??? ??? ??? ?JOptionPane.YES_NO_OPTION);
  147. ?? ??? ??? ??? ??? ?if (flag == JOptionPane.YES_OPTION) {
  148. ?? ??? ??? ??? ??? ??? ?Hall hall = new Hall(name, new Integer(capacity), new Integer(cid));
  149. ?? ??? ??? ??? ??? ??? ?boolean res = hallbiz.addHall(hall);
  150. ?
  151. ?? ??? ??? ??? ??? ??? ?hallList = hallbiz.queryAllHall();
  152. ?? ??? ??? ??? ??? ??? ?refreshTable(hallList);
  153. ?? ??? ??? ??? ??? ??? ?if (res) {
  154. ?? ??? ??? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "添加成功!");
  155. ?? ??? ??? ??? ??? ??? ?} else {
  156. ?? ??? ??? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "添加失败!");
  157. ?? ??? ??? ??? ??? ??? ?}
  158. ?? ??? ??? ??? ??? ?}
  159. ?? ??? ??? ??? ?}
  160. ?? ??? ??? ?}
  161. ?? ??? ?});
  162. ?? ??? ?btn_query.addActionListener(new ActionListener() {
  163. ?
  164. ?? ??? ??? ?@Override
  165. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  166. ?? ??? ??? ??? ?// 清除数据,防止累加
  167. ?? ??? ??? ??? ?if (hallList != null) {
  168. ?? ??? ??? ??? ??? ?hallList.clear();
  169. ?? ??? ??? ??? ?}
  170. ?? ??? ??? ??? ?hallList = hallbiz.queryAllHall();
  171. ?? ??? ??? ??? ?refreshTable(hallList);
  172. ?? ??? ??? ?}
  173. ?? ??? ?});
  174. ?? ??? ?btn_del.addActionListener(new ActionListener() {
  175. ?
  176. ?? ??? ??? ?@Override
  177. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  178. ?? ??? ??? ??? ?int row = table.getSelectedRow();
  179. ?? ??? ??? ??? ?int id = (Integer) table.getValueAt(row, 0);
  180. ?? ??? ??? ??? ?int flag = JOptionPane.showConfirmDialog(operHallView.this, "确认是否删除此场厅?", "确认信息",
  181. ?? ??? ??? ??? ??? ??? ?JOptionPane.YES_NO_OPTION);
  182. ?? ??? ??? ??? ?if (flag == JOptionPane.YES_OPTION) {
  183. ?? ??? ??? ??? ??? ?boolean res = hallbiz.delHall(id);
  184. ?? ??? ??? ??? ??? ?if (res) {
  185. ?? ??? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "删除成功!");
  186. ?? ??? ??? ??? ??? ??? ?// 更新数据
  187. ?? ??? ??? ??? ??? ??? ?List<Session> sessionList = new ArrayList<Session>();
  188. ?? ??? ??? ??? ??? ??? ?sessionList = sessionbiz.queryAllSession();
  189. ?? ??? ??? ??? ??? ??? ?// 删除某场厅后,对应的场次也进行删除
  190. ?? ??? ??? ??? ??? ??? ?int sid = 0;
  191. ?? ??? ??? ??? ??? ??? ?for (int i = 0; i < sessionList.size(); i++) {
  192. ?? ??? ??? ??? ??? ??? ??? ?if (id == sessionList.get(i).getHall_id()) {
  193. ?? ??? ??? ??? ??? ??? ??? ??? ?sid = sessionList.get(i).getSession_id();
  194. ?? ??? ??? ??? ??? ??? ??? ??? ?sessionbiz.delSession(sid);
  195. ?? ??? ??? ??? ??? ??? ??? ?}
  196. ?? ??? ??? ??? ??? ??? ?}
  197. ?? ??? ??? ??? ??? ??? ?hallList = hallbiz.queryAllHall();
  198. ?? ??? ??? ??? ??? ??? ?refreshTable(hallList);// 更新显示数据
  199. ?? ??? ??? ??? ??? ?} else {
  200. ?? ??? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(operHallView.this, "删除失败!");
  201. ?? ??? ??? ??? ??? ?}
  202. ?? ??? ??? ??? ?}
  203. ?? ??? ??? ?}
  204. ?? ??? ?});
  205. ?? ??? ?btn_back.addActionListener(new ActionListener() {
  206. ?
  207. ?? ??? ??? ?@Override
  208. ?? ??? ??? ?public void actionPerformed(ActionEvent e) {
  209. ?? ??? ??? ??? ?operHallView.this.dispose();
  210. ?? ??? ??? ?}
  211. ?? ??? ?});
  212. ?? ?}
  213. ?
  214. ?? ?private class HallInfoTableModel implements TableModel {
  215. ?? ??? ?public List<Hall> hallList = null;
  216. ?
  217. ?? ??? ?public HallInfoTableModel(List<Hall> hallList) {
  218. ?? ??? ??? ?this.hallList = hallList;
  219. ?? ??? ?}
  220. ?
  221. ?? ??? ?// JTable显示的行数
  222. ?? ??? ?@Override
  223. ?? ??? ?public int getRowCount() {
  224. ?? ??? ??? ?return hallList.size();
  225. ?? ??? ?}
  226. ?
  227. ?? ??? ?// JTable显示的列数
  228. ?? ??? ?@Override
  229. ?? ??? ?public int getColumnCount() {
  230. ?? ??? ??? ?return 4;
  231. ?? ??? ?}
  232. ?
  233. ?? ??? ?// JTable显示各行的名称
  234. ?? ??? ?@Override
  235. ?? ??? ?public String getColumnName(int columnIndex) {
  236. ?? ??? ??? ?if (columnIndex == 0) {
  237. ?? ??? ??? ??? ?return "场厅ID";
  238. ?? ??? ??? ?} else if (columnIndex == 1) {
  239. ?? ??? ??? ??? ?return "场厅名称";
  240. ?? ??? ??? ?} else if (columnIndex == 2) {
  241. ?? ??? ??? ??? ?return "所属影院";
  242. ?? ??? ??? ?} else if (columnIndex == 3) {
  243. ?? ??? ??? ??? ?return "场厅容量";
  244. ?? ??? ??? ?} else {
  245. ?? ??? ??? ??? ?return "出错";
  246. ?? ??? ??? ?}
  247. ?? ??? ?}
  248. ?
  249. ?? ??? ?// JTable列的数据类型
  250. ?? ??? ?@Override
  251. ?? ??? ?public Class<?> getColumnClass(int columnIndex) {
  252. ?? ??? ??? ?return String.class;
  253. ?? ??? ?}
  254. ?
  255. ?? ??? ?// 单元格是否可编辑
  256. ?? ??? ?@Override
  257. ?? ??? ?public boolean isCellEditable(int rowIndex, int columnIndex) {
  258. ?? ??? ??? ?return false;
  259. ?? ??? ?}
  260. ?
  261. ?? ??? ?// 每行单元格显示的数据
  262. ?? ??? ?@Override
  263. ?? ??? ?public Object getValueAt(int rowIndex, int columnIndex) {
  264. ?? ??? ??? ?Hall hall = hallList.get(rowIndex);
  265. ?? ??? ??? ?Cinema cinema = null;
  266. ?? ??? ??? ?if (columnIndex == 0) {
  267. ?? ??? ??? ??? ?return hall.getHall_id();
  268. ?? ??? ??? ?} else if (columnIndex == 1) {
  269. ?? ??? ??? ??? ?return hall.getHname();
  270. ?? ??? ??? ?} else if (columnIndex == 2) {
  271. ?? ??? ??? ??? ?List<Cinema> cinemaList = cinemabiz.queryAllCinema();
  272. ?? ??? ??? ??? ?for (int i = 0; i < cinemaList.size(); i++) {
  273. ?? ??? ??? ??? ??? ?if (hall.getCinema_id() == cinemaList.get(i).getCinema_id()) {
  274. ?? ??? ??? ??? ??? ??? ?cinema = cinemaList.get(i);
  275. ?? ??? ??? ??? ??? ??? ?break;
  276. ?? ??? ??? ??? ??? ?}
  277. ?? ??? ??? ??? ?}
  278. ?? ??? ??? ??? ?return cinema.getCname();
  279. ?? ??? ??? ??? ?// return hall.getCid();
  280. ?? ??? ??? ?} else if (columnIndex == 3) {
  281. ?? ??? ??? ??? ?return hall.getCapacity();
  282. ?? ??? ??? ?} else {
  283. ?? ??? ??? ??? ?return "出错";
  284. ?? ??? ??? ?}
  285. ?? ??? ?}
  286. ?
  287. ?? ??? ?@Override
  288. ?? ??? ?public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  289. ?? ??? ??? ?// TODO Auto-generated method stub
  290. ?
  291. ?? ??? ?}
  292. ?
  293. ?? ??? ?@Override
  294. ?? ??? ?public void addTableModelListener(TableModelListener l) {
  295. ?? ??? ??? ?// TODO Auto-generated method stub
  296. ?
  297. ?? ??? ?}
  298. ?
  299. ?? ??? ?@Override
  300. ?? ??? ?public void removeTableModelListener(TableModelListener l) {
  301. ?? ??? ??? ?// TODO Auto-generated method stub
  302. ?
  303. ?? ??? ?}
  304. ?? ?}
  305. ?
  306. ?? ?private void refreshTable(List<Hall> hallList) {
  307. ?? ??? ?infoTableModel = new HallInfoTableModel(hallList);
  308. ?? ??? ?table.setModel(infoTableModel);
  309. ?? ??? ?table.setRowHeight(20);
  310. ?? ?}
  311. }

到此这篇关于Eclipse+Java+Swing+Mysql实现电影购票系统(详细代码)的文章就介绍到这了,更多相关Eclipse+Java+Swing+Mysql实现电影购票系统内容请搜索w3xue以前的文章或继续浏览下面的相关文章希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号