📄 manadiglog.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.redingsoft.setroomframe;import com.redingsoft.warnmsg.WarnMsg;import com.redingsoft.locationutil.*;import com.redingsoft.sql.SetSQL;import com.redingsoft.sunsdk.swing.*;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Font;import java.awt.Toolkit;import java.awt.event.*;import javax.swing.*;import java.util.regex.Matcher;import java.util.regex.Pattern;import javax.swing.table.TableModel;/** * * @author Administrator */public class ManaDiglog extends JDialog implements FocusListener,ActionListener{ //声明标签类用来显示提示用输入的消息 private JLabel jl1,jl2,jl3,jl4,jl5,jl6,jl8,jl9, jl71,jl72,jl73,jl74,jl75,jl76; //声明文本框类 用作房间信息输入框 public JTextField tf1,tf2,tf3,tf4,tf5,tf7; private JTextArea ta; //声明数据表 JTable tb; //声明表数据模式. TableModel dataModel; //声明2个数组用于初始化表格 String colname[]={"房间编号","房间类型","房间床位","房间价格","房间押金", "房间备注"}; String rows[][]=new String[5][7]; //声明按钮类 private JButton bt1,bt2,bt3,bt4; //声明面版 private JPanel mainPane,upPane,bottPane,centerPane , pc1,pc2,pc3,pc4,pc5,pc6; // private JPanel imagePane; //声明一个滚动 JScrollPane sp,sp2; //标记添加的次数 int count=0; private String[] sqls;// String[] sqls; //用于存放数据库语句 //构造函数manarmframe public ManaDiglog(){ mainPane=new JPanel(new BorderLayout()); upPane=new JPanel(new FlowLayout(FlowLayout.CENTER,25,8)); centerPane=new JPanel(new BorderLayout()); bottPane=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); pc1=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2)); pc2=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2)); pc3=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2)); pc4=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2)); pc5=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2)); pc6=new JPanel(new FlowLayout(FlowLayout.LEFT,2,2)); //设置上面版的初始大小 upPane.setPreferredSize(new Dimension(200,110)) ; //表格标题 jl8=new JLabel(); jl8.setText("房间信息"); jl8.setHorizontalAlignment(SwingConstants.CENTER); jl8.setForeground(new Color(0,0,255)); jl8.setFont(new Font("宋体",Font.BOLD,25)); centerPane.add(BorderLayout.PAGE_START,jl8); sp=initTabel(); centerPane.add(sp); //设置中间面板大小 centerPane.setSize(200, 500); //实例化标签 jl1=new JLabel("类型编号"); jl2=new JLabel("房间类型"); jl3=new JLabel("房间床位"); jl4=new JLabel("房间价格"); jl5=new JLabel("房间押金"); jl6=new JLabel("房间备注"); jl8=new JLabel("提示信息:"); jl9=new JLabel(" "); //信息显示区 jl71=new JLabel("*"); //设置必填项的标记 jl72=new JLabel("*"); jl73=new JLabel("*"); jl74=new JLabel("*"); jl75=new JLabel("*"); jl76=new JLabel("*"); jl8.setFont(new Font("宋体",Font.ITALIC,15)); //设置提示信息样式 jl8.setForeground(new Color(0,0,255)); jl9.setFont(new Font("宋体",Font.ITALIC,15)); //设置显示信息区域的样式 jl9.setForeground(new Color(255,0,0)); //////////////////////////////////// jl71.setForeground(new Color(255,0,0)); //设置标题颜色 jl72.setForeground(new Color(255,0,0)); jl73.setForeground(new Color(255,0,0)); jl74.setForeground(new Color(255,0,0)); jl75.setForeground(new Color(255,0,0)); jl76.setForeground(new Color(255,0,0)); jl71.setFont(new Font("宋体",Font.BOLD,15)); //设置样式 jl72.setFont(new Font("宋体",Font.BOLD,15)); jl73.setFont(new Font("宋体",Font.BOLD,15)); jl74.setFont(new Font("宋体",Font.BOLD,15)); jl75.setFont(new Font("宋体",Font.BOLD,15)); jl76.setFont(new Font("宋体",Font.BOLD,15)); //实例化按钮 bt1=new OJButton("com/redingsoft/pic/save.gif","保存","添加的房间信息保存到数据库",true); bt2=new OJButton("com/redingsoft/pic/cancel.gif","删除","删除你输入的房间信息",true); bt3=new OJButton("com/redingsoft/pic/recall.gif","取消","取消你的操作",true); bt4=new OJButton("com/redingsoft/pic/add.gif","添加","添加房间",true); //实例化化文本框 tf1=new JTextField(15); tf2=new JTextField(15); tf3=new JTextField(15); tf4=new JTextField(15); tf5=new JTextField(15); //s实例化文本域 ta=new JTextArea(1,15); //设置自动换行 ta.setLineWrap(true); ta.setPreferredSize(new Dimension(2,15)); sp2=new JScrollPane(ta); // ta.setMaximumSize(new Dimension(2,15)); //设置备注区域大小 //将标签和文本框添加到面板中 pc1.add(jl1); //房间编号 pc1.add(tf1); pc1.add(jl71); //添加必填项标记 pc2.add(jl2); //房间类型 pc2.add(tf2); pc2.add(jl72); pc3.add(jl3); //房间床位 pc3.add(tf3); pc3.add(jl73); pc4.add(jl4); //房间价格 pc4.add(tf4); pc4.add(jl74); pc5.add(jl5); //房间押金 pc5.add(tf5); pc5.add(jl75); pc6.add(jl6); //房捡备注 pc6.add(sp2); //将信息面板添加到upPane中 upPane.add(pc1); upPane.add(pc2); upPane.add(pc3); upPane.add(pc4); upPane.add(pc5); upPane.add(pc6); //添加按钮到bottPane bottPane.add(jl8); //提示信息 //设置信息显示区的初始大小 bottPane.add(jl9); bottPane.add(bt4); //添加 bottPane.add(bt1); //保存 bottPane.add(bt2); //删除 bottPane.add(bt3); //取消 new BorderWithTitle("房间信息添加",upPane); upPane.setBorder(BorderFactory.createLineBorder(new Color(255,0,0), 1)); //将2个面板添加到主面板中 mainPane.add(upPane,BorderLayout.NORTH); mainPane.add(centerPane,BorderLayout.CENTER); mainPane.add(bottPane,BorderLayout.SOUTH); //绘制主面板的边框 //加组件到主面板 this.add(mainPane); //添加事件侦听 addListener(); this.addWindowListener(new WindowAdapter(){ @Overridepublic void windowClosing(WindowEvent e){ quit(); } }); this.setBounds(0, 0, 600, 500); this.setResizable(false);// this.pack(); this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setTitle("添加房间"); //使窗体居中显示 LocationUtil.setLocation(this); /********************************************************* *函数名:quit() * 参数:void * 返回值:void * 功能:窗口被关闭时给出提示 * ********************************************************/ } private void quit() { int flag=0; String msg="你现在要关闭该操作吗?"; flag=JOptionPane.showConfirmDialog(null, msg, "消息提示", JOptionPane.YES_NO_OPTION); if(flag==JOptionPane.YES_OPTION){ //关闭系统 this.dispose(); // this.setDefaultCloseOperation(EXIT_ON_CLOSE); } }//添加侦听事件 /********************************************** * 函数名:addListener() * 返回值:void
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -