基于java+mysql的swing+java+mysql电影院购票电影票管理系统(管理员、用户)(java+swing+mysql+gui)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
后台管理员:管理电影、影院、场次等
前台用户:查看电影、购票、评论等
eclipse/myeclipse
idea
后台管理员:
前台用户:
技术框架
Java Swing MySQL
基于java+mysql的Swing+Java+MySQL电影院购票电影票管理系统(管理员、用户)(java+swing+mysql+gui)
}
// 加上影院地址
String[] tbheadnames = { "影票编号", "用户名", "影院名称", "影院地址","场厅名字", "电影名称", "开始时间", "价格", "座位号" };*/
ticktb = new JTable() {
public boolean isCellEditable( int row, int column) {
return false;
}
};
ticktb.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"影票编号", "用户名", "影院名称","影院地址","场厅名字","电影名称","开始时间","价格","座位号"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, false,false,false,false,false,false
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
fillticktable(ticketlist);
r.setHorizontalAlignment(JLabel.CENTER);
ticktb.setDefaultRenderer(Object.class, r);
ticktb.setRowHeight(90);
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);
jsearch_jbutton.setBounds(400,450,150,40);
jsearch_jbutton.setFont(font);
jsearch_jbutton.addActionListener(this);
jsearch_nametext.setBounds(50,450,300,40);
jsearch_nametext.setFont(font);
card2.add(jsearch_nametext);
card2.add(jsearch_jbutton);
moviecard1_btn=new JButton();
.addComponent(lblNewLabel_7)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(serNameText, GroupLayout.PREFERRED_SIZE, 243, GroupLayout.PREFERRED_SIZE)
.addGap(125)
.addComponent(serbtn))
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addGroup(groupLayout.createSequentialGroup()
.addGap(30)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(mIdText, GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lblNewLabel_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(movieNameText, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
.addGap(20)
.addComponent(lblNewLabel_8)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(95)
.addComponent(btnNewButton_1))
.addGroup(groupLayout.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(timeText, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE))))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblNewLabel_5)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(moviepicadreText))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblNewLabel_2)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(movielangText, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(lblNewLabel_3)
.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))
public class LoginUi implements ActionListener{
private JFrame jf = new JFrame(" 电影购票系统");
private Container con = jf.getContentPane();// 获得面板
private ImageIcon bg = new ImageIcon("images/bg.jpg");
private ImageIcon btnbg = new ImageIcon("images/btn.png");
private Toolkit toolkit = Toolkit.getDefaultToolkit();
private Dimension sc = toolkit.getScreenSize();// 获得屏幕尺寸
private JButton in = new JButton("",btnbg);
//"进入系统"用背景图
private JLabel bglabel = new JLabel();
public LoginUi() {
con.setLayout(null);
jf.setSize(1000, 600);
jf.setLocation((sc.width - 1000) / 2, (sc.height - 618) / 2);
jf.setResizable(false);// 窗口大小不可变
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setVisible(true);
bglabel.setIcon(bg);
bglabel.setBounds(0, 0, 1000, 600);
in.setBounds(425, 250, 150, 56);
con.add(bglabel);
con.add(in);
public class BuyTicketUi extends JFrame implements ActionListener {
private JPanel p1 = new JPanel();
private JPanel p2 = new JPanel();
private JPanel p3 = new JPanel();
private JButton btlist[];
private JButton reset = new JButton("重置");
private JButton jbuy = new JButton("购买");
private JButton returnuser = new JButton("返回主页");
private JButton returnlast = new JButton("返回上一层");
private TextField lblRe = new TextField(20);
private UserService userservice = new UserServiceImpl();
private SessionService sessionservice = new SessionServiceImpl();
private TicketService ticketService = new TicketServiceImpl();
private int num;
private User u;
private Session se;
private Movie mo;
private Hall ha;
private List<Ticket> list;
private List<Integer> seatlist = new ArrayList<Integer>();
private StringBuffer sb = new StringBuffer();
public BuyTicketUi(User u, Session se, Movie mo, Hall ha) {
this.u = u;
this.se = se;
this.mo = mo;
this.ha = ha;
list = ticketService.queryAllTicketsId(se.getsId());
jbuy.setFont(new Font("楷体", Font.BOLD, 20));
returnuser.setFont(new Font("楷体", Font.BOLD, 20));
returnlast.setFont(new Font("楷体", Font.BOLD, 20));
reset.setFont(new Font("楷体", Font.BOLD, 20));
lblRe.setFont(new Font("楷体", Font.BOLD, 20));
this.setSize(1000, 1000);
num = ha.getCapacity();
int rows = (num + 9) / 10;
btlist = new JButton[num];
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// TODO Auto-generated method stub
String sql="delete from session where sId="+sId;
return operUpdate(sql, null);
}
@Override
public boolean updateSession(Session session) {
// TODO Auto-generated method stub
String sql="update session set hId=?,cId=?,mId=?,beginTime=?,price=?,remain=? where sId=?";
List<Object> params1 = new ArrayList<Object>();
params1.add(session.gethId());
params1.add(session.getcId());
params1.add(session.getmId());
params1.add(session.getBeginTime());
params1.add(session.getPrice());
params1.add(session.getRemain());
params1.add(session.getsId());
return operUpdate(sql, params1);
}
@Override
public List<Session> queryAllSession() {
// TODO Auto-generated method stub
String sql="select * from session";
List<Session> list=null;
try {
list = operQuery(sql, null,Session.class);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
@Override
public Session querySessionById(int sId) {
// TODO Auto-generated method stub
String sql="select *from session where sId="+sId;
List<Session> list=null;
try {
list = operQuery(sql,null,Session.class);
if(list.size() == 0){
return null;
}else{
return list.get(0);
}
} catch (Exception e) {
// TODO Auto-generated catch block
protected void movietbmousePressed(MouseEvent me) {
// TODO Auto-generated method stub
row1=movietb.getSelectedRow();
if(row1!=-1) {
moviecard1_btn.setIcon(new ImageIcon(movielist.get(row1).getmPicaddress()));
moviename.setText("片名:" +movielist.get(row1).getmName()+" 评分:"+movielist.get(row1).getmGrade());
movielocality_language.setText("地区:" + movielist.get(row1).getMlocality() + " 语言:" + movielist.get(row1).getMlanguage());
movietype_grade.setText("类型:" + (movielist.get(row1).getmType()) + " " + "时长 :" + movielist.get(row1).getmDuration() + "分钟");
}
}
private void fillTable(List<Movie> movielist2) {
// TODO Auto-generated method stub
DefaultTableModel dtm=(DefaultTableModel) movietb.getModel();
dtm.setRowCount(0); // 设置成0行
int movieRow= movielist2.size();
for(int i=0;i<movieRow;i++) {
Vector v=new Vector();
v.add(movielist2.get(i).getmId());
v.add(movielist2.get(i).getmName());
v.add(movielist2.get(i).getMlanguage());
v.add(movielist2.get(i).getMlocality());
v.add(movielist2.get(i).getmDuration());
v.add(movielist2.get(i).getmType());
v.add(movielist2.get(i).getmGrade());
dtm.addRow(v);
}
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setHorizontalAlignment(JLabel.CENTER);
}
protected void ticktablemousePressed(MouseEvent me) {
// TODO Auto-generated method stub
Session csession;
row = ticktb.getSelectedRow();
if(row!=-1) {
csession=sessionservice.querySessionById(ticketlist.get(row).getsId());
ccomment=new Comment(user.getUid(),csession.getmId());
ccomment=commentservice.queryComment(ccomment);
if(ccomment!=null) {
jcommentcontent.setText(ccomment.getComment());
jcommentcontent.setLineWrap(true);
jcommentcontent.setEditable(false);
jIscomment.setText("您已评论");
}else {
jcommentcontent.setEditable(true);
jIscomment.setText("您还未评论");
serNameText.setColumns(10);
JButton serbtn = new JButton("搜索");
serbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
searchActionPerformed(e);
}
});
serbtn.setFont(new Font("楷体", Font.PLAIN, 20));
movieDeText = new JTextArea();
movieDeText.setFont(new Font("楷体", Font.PLAIN, 18));
movieDeText.setLineWrap(true);
JLabel lblNewLabel_8 = new JLabel("时长:");
lblNewLabel_8.setFont(new Font("楷体", Font.PLAIN, 20));
timeText = new JTextField();
timeText.setFont(new Font("楷体", Font.PLAIN, 20));
timeText.setColumns(10);
JLabel lblNewLabel_9 = new JLabel("评分:");
lblNewLabel_9.setFont(new Font("楷体", Font.PLAIN, 20));
scoreText = new JTextField();
scoreText.setFont(new Font("楷体", Font.PLAIN, 20));
scoreText.setColumns(10);
serTypecomboBox = new JComboBox();
serTypecomboBox.setFont(new Font("楷体", Font.PLAIN, 20));
serTypecomboBox.addItem("科幻");
serTypecomboBox.addItem("动作");
serTypecomboBox.addItem("爱情");
serTypecomboBox.addItem("剧情");
serTypecomboBox.addItem("动漫");
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(152)
.addComponent(lblNewLabel_6)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(serTypecomboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(176)
.addComponent(lblNewLabel_7)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(serNameText, GroupLayout.PREFERRED_SIZE, 243, GroupLayout.PREFERRED_SIZE)
.addGap(125)
.addComponent(serbtn))
.addGroup(groupLayout.createSequentialGroup()
if(cinemaservice.queryCinemaById(cId)!=null) {
halllist.get(halrow).sethName(hName);
if(hallservice.updateHall(halllist.get(halrow))) {
JOptionPane.showMessageDialog(null, "修改成功");
fillhalltableTable(halllist);
}
}else {
JOptionPane.showMessageDialog(null, "不存在此影院");
}
}
}catch (NumberFormatException e2) {
JOptionPane.showMessageDialog(null, "格式错误");
}
}
}
protected void addactionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(judge()) {
try {
int cId=Integer.parseInt(cIdtext.getText());
int capacity=Integer.parseInt(capacitytext.getText());
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, "输入格式错误");
}
}
}
protected void halltablemousePressed(MouseEvent me) {
// TODO Auto-generated method stub
sPane.setVisible(true);
card1.add(sPane);
tabbedPane.addTab("我的影票", card8);
jupdatere.setBounds(850, 80, 150, 50);
jupdatere.setFont(font);
card8.add(jupdatere);
jupdatere.addActionListener(this);
jreport.setBounds(1200, 80, 100, 50);
jreport.setFont(font);
jreport.addActionListener(this);
card8.add(jreport);
jIscomment.setText("您的评论");
jIscomment.setFont(font0);
jIscomment.setBounds(400, 50, 300, 200);
card8.add(jIscomment);
delTicket=new JButton("退订");
delTicket.setFont(font);
delTicket.setBounds(1400, 350, 100, 50);
delTicket.addActionListener(this);
card8.add(delTicket);
jcommentcontent.setBounds(300, 250, 1000, 150);
jcommentcontent.setFont(font0);
card8.add(jcommentcontent);
ticketlist=ticketservice.queryAllTicketuId(user.getUid());
/*int ticketRow = ticketlist.size();
Session session;
Hall hall;
Cinema cinema;
Movie tmovie;*/
/*String[][] ticinfo = new String[ticketRow][9];
for (int i = 0; i < ticketRow; i++) {
session=sessionservice.querySessionById(ticketlist.get(i).getsId());
hall=hallservice.queryHallById(session.gethId());
cinema=cinemaservice.queryCinemaById(session.getcId());
tmovie=mo.queryMovieById(session.getmId());
ticinfo[i][0]=String.valueOf(ticketlist.get(i).gettId() );
ticinfo[i][1]=user.getuName();
ticinfo[i][2]= cinema.getCname() ;
ticinfo[i][3]=cinema.getCaddress();
ticinfo[i][4]=hall.gethName();
ticinfo[i][5]=tmovie.getmName();
ticinfo[i][6]=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(session.getBeginTime());
ticinfo[i][7]=String.valueOf(session.getPrice());
ticinfo[i][8]=String.valueOf(ticketlist.get(i).getSeat());
}
// 加上影院地址
String[] tbheadnames = { "影票编号", "用户名", "影院名称", "影院地址","场厅名字", "电影名称", "开始时间", "价格", "座位号" };*/
ticktb = new JTable() {
public boolean isCellEditable( int row, int column) {
return false;
}
public class MovieUi {
private Movie movie;
private User u;
private JFrame jf = new JFrame("电影购票系统");
private Container con = jf.getContentPane();
private ImageIcon moviebg;
private Font font0 = new Font("楷体", 0, 40);
private Font font1 = new Font("楷体", 0, 28);
private Font font2 = new Font("楷体", 0, 25);
/* private JLabel maxLable=new JLabel(); */
private JLabel jPic = new JLabel();// 图片
private JLabel jmName = new JLabel();// 电影名字
private JLabel jmLoca = new JLabel();// 地区
private JLabel jmLanguage = new JLabel();// 语言
private JLabel jmDuration = new JLabel();// 时长
private JLabel jmType = new JLabel();// 类型
private JLabel jmGrade = new JLabel();// 评分
private JLabel jcomment=new JLabel();//评论列表
private JTextArea jcommentcontent=new JTextArea(30,30);//评论内容
private JButton jreport=new JButton("发表评论");//评论
private JTextArea jmDetail = new JTextArea(50, 50);
private JButton jreturn = new JButton("返回主页");
private JButton jBuy = new JButton("想看电影");
private JPanel p = new JPanel();
private UserService userservice=new UserServiceImpl();
private CommentService commentservice=new CommentServiceImpl();
private JLabel[] jothercomment;
private JLabel[] jcommentName;
private JLabel[] jcommentTime;
private JTextArea[] jothercommentcontent;
private List<Comment> comlist;
private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/* Container contentPane; */
}
public boolean judge() {
if("".equals(hallnametext.getText())) {
JOptionPane.showMessageDialog(null, "场厅名不能为空");
return false;
}
if("".equals(cIdtext.getText())) {
JOptionPane.showMessageDialog(null, "影院编号不能为空");
return false;
}
if("".equals(capacitytext.getText())) {
JOptionPane.showMessageDialog(null, "场厅容量不能为空");
return false;
}
return true;
}
}
public class CinemaManage extends JInternalFrame {
JOptionPane.showMessageDialog(null, "修改评论成功");
jcommentcontent.setEditable(false);
}else {
JOptionPane.showMessageDialog(null, "系统错误");
}
}
}
}
if(obj==delTicket) {
Ticket ticket;
if(row==-1) {
JOptionPane.showMessageDialog(null, "未选择影票");
}else {
ticket=ticketlist.get(row);
if(ticketservice.delTicket(ticket.gettId())) {
Session desession=sessionservice.querySessionById(ticket.getsId());
desession.setRemain(desession.getRemain()+1);
if(sessionservice.updateSession(desession)) {
JOptionPane.showMessageDialog(null, "退票成功");
this.user.setBalance(this.user.getBalance()+desession.getPrice());
uo.updateUser(this.user);
ticketlist.remove(row);
fillticktable(ticketlist);
}else {
JOptionPane.showMessageDialog(null, "退票失败");
}
}
else {
JOptionPane.showMessageDialog(null, "退票失败");
}
}
}
for(int i=0;i<size;i++) {
if(obj==card1_btn[i]) {
new MovieUi(list.get(i),this.user);
jf.dispose();
}
}
for(int i=0;i<size1;i++) {
if(obj==card1_btn1[i]) {
scoreLabel.setFont(new Font("楷体", Font.PLAIN, 20));
scoreText = new JTextField();
scoreText.setFont(new Font("楷体", Font.PLAIN, 20));
scoreText.setColumns(10);
detailtextArea = new JTextArea();
detailtextArea.setFont(new Font("楷体", Font.PLAIN, 20));
detailtextArea.setLineWrap(true);
JButton cancelButton = new JButton("取消");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelActionPerformed(e);
}
});
cancelButton.setFont(new Font("楷体", Font.PLAIN, 20));
JButton addButton = new JButton("添加");
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addactionPerformed(e);
}
});
addButton.setFont(new Font("楷体", Font.PLAIN, 20));
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap(222, Short.MAX_VALUE)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(picaddressLabel, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)
.addComponent(movieNameLabel))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addComponent(picaddressText)
.addComponent(movieNameText, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
.addGap(43)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addComponent(timeLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(movielanglabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(movielangText, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE)
private Toolkit toolkit = Toolkit.getDefaultToolkit();
private Dimension sc = toolkit.getScreenSize();// 获得屏幕尺寸
private JLabel name = new JLabel("用 户 名");
private JLabel pass = new JLabel("密 码");
private JLabel pass2 = new JLabel("确认密码");
private JTextField textName = new JTextField();
private JLabel title = new JLabel("用户注册");
private JPasswordField textPs = new JPasswordField();
private JPasswordField textPs2 = new JPasswordField();
// 密码框
private JButton button1 = new JButton("确定");
private JButton button2 = new JButton("返回");
// 按钮
private Font font = new Font("楷体", 1, 28);
private Font font1 = new Font("楷体", 0, 20);
private Font font2 = new Font("宋体", 0, 18);// 字体,样式(粗体,斜体),大小
private ImageIcon loginbg = new ImageIcon("images/loginbg.jpg");
public RegisterUi() {
con.setLayout(null);
jf.setSize(1000, 618);
jf.setLocation((sc.width - 1000) / 2, (sc.height - 618) / 2);
jf.setResizable(false);// 窗口大小不可变
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setVisible(true);
JLabel maxlabel = new JLabel(loginbg);
title.setBounds(215, 95, 170, 30);
title.setFont(font);
title.setForeground(Color.black);
name.setBounds(160, 163, 95, 30);
name.setFont(font1);
name.setForeground(Color.red);
pass.setBounds(160, 220, 95, 30);// 密码的位置大小
pass.setForeground(Color.red);
pass.setFont(font1);
pass2.setBounds(160, 280, 95, 30);
pass2.setForeground(Color.red);
pass2.setFont(font1);
textName.setBounds(245, 163, 140, 25);
movieTypeText.setFont(new Font("楷体", Font.PLAIN, 20));
movieTypeText.setColumns(10);
JLabel lblNewLabel_5 = new JLabel("海报地址:");
lblNewLabel_5.setFont(new Font("楷体", Font.PLAIN, 20));
moviepicadreText = new JTextField();
moviepicadreText.setFont(new Font("楷体", Font.PLAIN, 20));
moviepicadreText.setColumns(10);
txtrDetailtest = new JTextArea();
txtrDetailtest.setText("detailTest");
txtrDetailtest.setFont(new Font("楷体", Font.PLAIN, 18));
JButton btnNewButton = new JButton("修改");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updatemovieActionPerformed(e);
}
});
btnNewButton.setFont(new Font("楷体", Font.PLAIN, 20));
JButton btnNewButton_1 = new JButton("删除");
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);
JButton serbtn = new JButton("搜索");
serbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
searchActionPerformed(e);
}
});
serbtn.setFont(new Font("楷体", Font.PLAIN, 20));
movieDeText = new JTextArea();
movieDeText.setFont(new Font("楷体", Font.PLAIN, 18));
movieDeText.setLineWrap(true);
JLabel lblNewLabel_8 = new JLabel("时长:");
lblNewLabel_8.setFont(new Font("楷体", Font.PLAIN, 20));
bgim.setImage(bgim.getImage().getScaledInstance(bg.getSize().width,
bg.getSize().height, Image.SCALE_DEFAULT));
laycon.add(bg, new Integer(Integer.MIN_VALUE));
maxlabel.add(title);
maxlabel.add(name);
maxlabel.add(pass);
maxlabel.add(pass2);
maxlabel.add(textName);
maxlabel.add(textPs);
maxlabel.add(textPs2);
maxlabel.add(button1);
maxlabel.add(button2);
maxlabel.setBounds(0, 0, 999, 617);
con.add(maxlabel);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.button1) {
String pswd = new String(textPs.getPassword());
String pswd2 = new String(textPs2.getPassword());
String name = textName.getText();
if ("".equals(name) || "".equals(pswd) || "".equals(pswd2)) {
LoginUi.winMessage("账号、密码不能为空!");
cleanUserInfo();
} else {
if (pswd.equals(pswd2)) {
int rs = userService.register(new User(name, pswd,0));
if (rs == 3) {
LoginUi.winMessage("注册失败,该用户名已存在!");
cleanUserInfo();
} else if(rs == 1) {
new LoginUi();
this.jf.dispose();
LoginUi.winMessage("注册成功!");
} else {
LoginUi.winMessage("注册失败,原因。。。");
cleanUserInfo();
}
} else{
LoginUi.winMessage("两次输入的密码不一致!");
cleanUserInfo();
}
}
} else if (e.getSource() == this.button2) {
new Login();
this.jf.dispose();
}
}
public void cleanUserInfo() {
this.textName.setText("");
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jmIdText, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addGap(9)
.addComponent(jtimeText, GroupLayout.PREFERRED_SIZE, 219, GroupLayout.PREFERRED_SIZE)))
.addGap(18)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblNewLabel_5)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jremainText, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(lblNewLabel_3)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(jpriceText, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE))))
.addGroup(groupLayout.createSequentialGroup()
.addGap(135)
.addComponent(btnNewButton))
.addGroup(groupLayout.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblNewLabel)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(jcIdText, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
.addGap(52)
.addComponent(lblNewLabel_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(jhallText, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)))
.addGap(41))
.addGroup(groupLayout.createSequentialGroup()
.addGap(20)
.addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 481, GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(22)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_6)
.addComponent(lblNewLabel_7))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 348, GroupLayout.PREFERRED_SIZE)
.addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 348, GroupLayout.PREFERRED_SIZE))
.addGap(25)