📄 booking_fr.java
字号:
package newBookingSystem;
import java.util.Calendar;
import java.util.*;
import javax.swing.event.*;
import javax.swing.text.*;
import java.awt.datatransfer.*;
import java.io.*;
import java.awt.dnd.*;
import java.text.SimpleDateFormat;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Color;
import javax.swing.BorderFactory;
import java.awt.SystemColor;
import javax.swing.Box;
import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.util.Observer;
import java.util.Observable;
import java.awt.Font;
import com.sunking.swing.JCalendarPanel;
import com.sunking.swing.JDatePicker;
import java.text.*;
import com.sunking.swing.JStatusBar;
import java.util.Vector;
public class booking_fr extends JFrame implements Observer{
int everEnterFlag ;
//////////////////////标记是否当前为拖拽状态////////////////////
int dragFlag;
BookingSystem bookingSystem;
/////////////////////////////保存Table的Text信息///////////////
String tempTabelText;
////////////////////////////标示右键是否点击在桌子上//////////////
int tip;
//////////////////////////保存用户点击的桌号//////////////////////
int tempTno;
///////////////////////保存桌子的JLabel对象/////////////////////
/////////////////////临时保存被拖拽桌子的Text信息///////////////////
String tempDragFromText;
/////////////////////临时保存拖拽到桌子的Text信息//////////////////
String tempDragToText;
Vector vector = new Vector(16);
JPanel contentPane;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuFile = new JMenu();
JMenuItem jMenuFileExit = new JMenuItem();
XYLayout xYLayout1 = new XYLayout();
PopupMenu popupMenu1 = new PopupMenu();
MenuItem menuItem1 = new MenuItem("新增预约");
MenuItem menuItem2 = new MenuItem("预约到达");
MenuItem menuItem3 = new MenuItem("取消预约");
MenuItem menuItem4 = new MenuItem("餐桌调换");
MenuItem menuItem5 = new MenuItem("未约用餐");
////////////////////////////////四人桌子声明Label/////////////////////////
//////////////////////////////////////////////////////////////////////
JLabel table1 = new JLabel();
JLabel table2 = new JLabel();
JLabel table3 = new JLabel();
JLabel table4 = new JLabel();
JLabel table5 = new JLabel();
JLabel table6 = new JLabel();
JLabel table7 = new JLabel();
JLabel table8 = new JLabel();
/////////////////////////////////////六人桌子声明Label///////////////////////////
//////////////////////////////////////////////////////////////////////////
JLabel table9 = new JLabel();
JLabel table10 = new JLabel();
JLabel table11 = new JLabel();
JLabel table12 = new JLabel();
JLabel table13 = new JLabel();
JLabel table14 = new JLabel();
JLabel table15 = new JLabel();
JLabel table16 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
JButton jButton7 = new JButton();
///////////////////////////日期控件声明//////////////////////////////////
/////////////////////////////////////////////////////////////////////////
JDatePicker date1 = new JDatePicker();
JButton jButton8 = new JButton();
//////////////////////观察者构造函数将自身加入到观察者集合///////////////////
///////////////////////////////////////////////////////////////////////////
public booking_fr(BookingSystem bs) {
try {
bs.addObserver(this);
bookingSystem = bs;
// displayBooking(this.getCalendarDate());
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
bookingSystem.Display(this.getCalendarDate());
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(xYLayout1);
setSize(new Dimension(645, 437));
setTitle("Frame Title");
this.addMouseListener(new booking_fr_this_mouseAdapter(this));
jMenuFile.setText("File");
jMenuFileExit.addActionListener(new
booking_fr_jMenuFileExit_ActionAdapter(this));
table6.setBackground(Color.white);
table6.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table6.setBorder(BorderFactory.createLineBorder(Color.black));
table6.setOpaque(true);
table6.setPreferredSize(new Dimension(200, 100));
table6.setHorizontalAlignment(SwingConstants.CENTER);
table6.setHorizontalTextPosition(SwingConstants.CENTER);
table6.setText("(6)四人桌");
table6.addMouseMotionListener(new booking_fr_table6_mouseMotionAdapter(this));
table6.addMouseListener(new booking_fr_table5_mouseAdapter(this));
contentPane.setBackground(new Color(166, 202, 240));
contentPane.setBorder(BorderFactory.createLineBorder(Color.black));
contentPane.addInputMethodListener(new
booking_fr_contentPane_inputMethodAdapter(this));
contentPane.addMouseListener(new booking_fr_contentPane_mouseAdapter(this));
contentPane.addMouseMotionListener(new
booking_fr_contentPane_mouseMotionAdapter(this));
table3.setBackground(Color.white);
//table3.setBackground(Color.blue) ;
table3.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table3.setBorder(BorderFactory.createLineBorder(Color.black));
//Color color = new Color() ;
table3.setOpaque(true);
table3.setPreferredSize(new Dimension(200, 100));
table3.setToolTipText("");
table3.setHorizontalAlignment(SwingConstants.CENTER);
table3.setHorizontalTextPosition(SwingConstants.CENTER);
table3.setText("(3)四人桌");
table3.addMouseMotionListener(new booking_fr_table3_mouseMotionAdapter(this));
table3.addMouseListener(new booking_fr_table3_mouseAdapter(this));
table2.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table2.setBorder(BorderFactory.createLineBorder(Color.black));
table2.setOpaque(true);
table2.setPreferredSize(new Dimension(200, 100));
table2.setHorizontalAlignment(SwingConstants.CENTER);
table2.setHorizontalTextPosition(SwingConstants.CENTER);
table2.setText("(2)四人桌");
table2.addMouseMotionListener(new booking_fr_table2_mouseMotionAdapter(this));
table2.addMouseListener(new booking_fr_table2_mouseAdapter(this));
table5.setBackground(Color.white);
table5.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table5.setBorder(BorderFactory.createLineBorder(Color.black));
table5.setOpaque(true);
table5.setPreferredSize(new Dimension(200, 100));
table5.setHorizontalAlignment(SwingConstants.CENTER);
table5.setHorizontalTextPosition(SwingConstants.CENTER);
table5.setText("(5)四人桌");
table5.addMouseMotionListener(new booking_fr_table5_mouseMotionAdapter(this));
table5.addMouseListener(new booking_fr_table4_mouseAdapter(this));
table4.setBackground(Color.white);
table4.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table4.setBorder(BorderFactory.createLineBorder(Color.black));
table4.setOpaque(true);
table4.setPreferredSize(new Dimension(200, 100));
table4.setHorizontalAlignment(SwingConstants.CENTER);
table4.setHorizontalTextPosition(SwingConstants.CENTER);
table4.setText("(4)四人桌");
table4.addMouseMotionListener(new booking_fr_table4_mouseMotionAdapter(this));
table4.addMouseListener(new booking_fr_table6_mouseAdapter(this));
table9.setBackground(Color.white);
table9.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table9.setBorder(BorderFactory.createLineBorder(Color.black));
table9.setOpaque(true);
table9.setPreferredSize(new Dimension(200, 100));
table9.setHorizontalAlignment(SwingConstants.CENTER);
table9.setHorizontalTextPosition(SwingConstants.CENTER);
table9.setText("(9)六人桌");
table9.addMouseListener(new booking_fr_table9_mouseAdapter(this));
table9.addKeyListener(new booking_fr_table9_keyAdapter(this));
table9.addMouseMotionListener(new booking_fr_table9_mouseMotionAdapter(this));
table8.setBackground(Color.white);
table8.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table8.setBorder(BorderFactory.createLineBorder(Color.black));
table8.setOpaque(true);
table8.setPreferredSize(new Dimension(200, 100));
table8.setHorizontalAlignment(SwingConstants.CENTER);
table8.setHorizontalTextPosition(SwingConstants.CENTER);
table8.setText("(8)四人桌");
table8.addMouseMotionListener(new booking_fr_table8_mouseMotionAdapter(this));
table8.addMouseListener(new booking_fr_table8_mouseAdapter(this));
table7.setBackground(Color.white);
table7.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table7.setBorder(BorderFactory.createLineBorder(Color.black));
table7.setOpaque(true);
table7.setPreferredSize(new Dimension(200, 100));
table7.setHorizontalAlignment(SwingConstants.CENTER);
table7.setHorizontalTextPosition(SwingConstants.CENTER);
table7.setText("(7)四人桌");
table7.addMouseMotionListener(new booking_fr_table7_mouseMotionAdapter(this));
table7.addMouseListener(new booking_fr_table9_mouseAdapter(this));
table1.setBackground(Color.white);
table1.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table1.setBorder(BorderFactory.createLineBorder(Color.black));
table1.setOpaque(true);
table1.setPreferredSize(new Dimension(200, 100));
table1.setToolTipText("四人桌额定人数为四人 ");
table1.setHorizontalAlignment(SwingConstants.CENTER);
table1.setText("(1)四人桌");
table1.addMouseMotionListener(new booking_fr_table1_mouseMotionAdapter(this));
table1.addMouseListener(new booking_fr_jLabel9_mouseAdapter(this));
table10.setBackground(Color.white);
table10.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table10.setForeground(Color.black);
table10.setBorder(BorderFactory.createLineBorder(Color.black));
table10.setOpaque(true);
table10.setPreferredSize(new Dimension(200, 100));
table10.setHorizontalAlignment(SwingConstants.CENTER);
table10.setHorizontalTextPosition(SwingConstants.CENTER);
table10.setText("(10)六人桌");
table10.addMouseListener(new booking_fr_table10_mouseAdapter(this));
table10.addMouseMotionListener(new
booking_fr_table10_mouseMotionAdapter(this));
table11.setBackground(Color.white);
table11.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table11.setBorder(BorderFactory.createLineBorder(Color.black));
table11.setOpaque(true);
table11.setPreferredSize(new Dimension(200, 100));
table11.setHorizontalAlignment(SwingConstants.CENTER);
table11.setHorizontalTextPosition(SwingConstants.CENTER);
table11.setText("(11)六人桌");
table11.addMouseListener(new booking_fr_table11_mouseAdapter(this));
table11.addMouseMotionListener(new
booking_fr_table11_mouseMotionAdapter(this));
table12.setBackground(Color.white);
table12.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table12.setBorder(BorderFactory.createLineBorder(Color.black));
table12.setOpaque(true);
table12.setPreferredSize(new Dimension(200, 100));
table12.setHorizontalAlignment(SwingConstants.CENTER);
table12.setHorizontalTextPosition(SwingConstants.CENTER);
table12.setText("(12)六人桌");
table12.addMouseListener(new booking_fr_table12_mouseAdapter(this));
table12.addMouseMotionListener(new
booking_fr_table12_mouseMotionAdapter(this));
table13.setBackground(Color.white);
table13.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table13.setBorder(BorderFactory.createLineBorder(Color.black));
table13.setOpaque(true);
table13.setPreferredSize(new Dimension(200, 100));
table13.setHorizontalAlignment(SwingConstants.CENTER);
table13.setHorizontalTextPosition(SwingConstants.CENTER);
table13.setText("(13)六人桌");
table13.addMouseListener(new booking_fr_table13_mouseAdapter(this));
table13.addMouseMotionListener(new
booking_fr_table13_mouseMotionAdapter(this));
table14.setBackground(Color.white);
table14.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table14.setBorder(BorderFactory.createLineBorder(Color.black));
table14.setOpaque(true);
table14.setPreferredSize(new Dimension(200, 100));
table14.setHorizontalAlignment(SwingConstants.CENTER);
table14.setHorizontalTextPosition(SwingConstants.CENTER);
table14.setText("(14)六人桌");
table14.addMouseListener(new booking_fr_table14_mouseAdapter(this));
table14.addMouseMotionListener(new
booking_fr_table14_mouseMotionAdapter(this));
table15.setBackground(Color.white);
table15.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table15.setBorder(BorderFactory.createLineBorder(Color.black));
table15.setOpaque(true);
table15.setPreferredSize(new Dimension(200, 100));
table15.setHorizontalAlignment(SwingConstants.CENTER);
table15.setHorizontalTextPosition(SwingConstants.CENTER);
table15.setText("(15)六人桌");
table15.addMouseListener(new booking_fr_table15_mouseAdapter(this));
table15.addMouseMotionListener(new
booking_fr_table15_mouseMotionAdapter(this));
table16.setBackground(Color.white);
table16.setFont(new java.awt.Font("隶书", Font.PLAIN, 20));
table16.setBorder(BorderFactory.createLineBorder(Color.black));
table16.setOpaque(true);
table16.setPreferredSize(new Dimension(200, 100));
table16.setHorizontalAlignment(SwingConstants.CENTER);
table16.setHorizontalTextPosition(SwingConstants.CENTER);
table16.setText("(16)六人桌");
table16.addMouseListener(new booking_fr_table16_mouseAdapter(this));
table16.addMouseMotionListener(new
booking_fr_table16_mouseMotionAdapter(this));
jButton1.setEnabled(false);
jButton1.setText("jButton1");
jButton2.setEnabled(false);
jButton2.setText("jButton1");
jButton3.setEnabled(false);
jButton3.setText("jButton1");
jButton4.setBackground(Color.white);
jButton4.setEnabled(false);
jButton4.setText("jButton4");
jButton5.setEnabled(false);
jButton5.setText("jButton5");
jButton6.setEnabled(false);
jButton6.setText("jButton6");
jButton7.setEnabled(false);
jButton7.setText("jButton7");
date1.setBackground(Color.green);
date1.setBorder(BorderFactory.createLineBorder(Color.black));
date1.addPopupMenuListener(new booking_fr_date1_popupMenuAdapter(this));
date1.addMouseListener(new booking_fr_date1_mouseAdapter(this));
popupMenu1.addActionListener(new booking_fr_popupMenu1_actionAdapter(this));
jButton8.setFont(new java.awt.Font("隶书", Font.BOLD, 14));
jButton8.setBorder(BorderFactory.createLineBorder(Color.black));
jButton8.setText("显示");
jButton8.addActionListener(new booking_fr_jButton8_actionAdapter(this));
popupMenu1.add(menuItem1);
popupMenu1.add(menuItem2);
popupMenu1.add(menuItem3);
popupMenu1.add(menuItem4);
popupMenu1.add(menuItem5);
////////////////////将桌子JLabel对象添加保存/////////////////////////////////////
vector.add(table1);
vector.add(table2);
vector.add(table3);
vector.add(table4);
vector.add(table5);
vector.add(table6);
vector.add(table7);
vector.add(table8);
vector.add(table9);
vector.add(table10);
vector.add(table11);
vector.add(table12);
vector.add(table13);
vector.add(table14);
vector.add(table15);
vector.add(table16);
//在this中加入popupMenu1
add(popupMenu1);
menuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
menuItem1_actionPerformed(e);
}
});
menuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
menuItem2_actionPerformed(e);
}
});
menuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
menuItem3_actionPerformed(e);
}
});
menuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
menuItem4_actionPerformed(e);
}
});
menuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
menuItem5_actionPerformed(e);
}
});
jMenuBar1.add(jMenuFile);
jMenuFile.add(jMenuFileExit);
contentPane.add(jButton6, new XYConstraints(482, 30, 2, 363));
contentPane.add(jButton1, new XYConstraints( -2, 108, 644, 1));
contentPane.add(jButton2, new XYConstraints( -6, 203, 650, 1));
contentPane.add(jButton3, new XYConstraints( -2, 303, 645, 2));
contentPane.add(jButton4, new XYConstraints(165, 30, 2, 361));
contentPane.add(table2, new XYConstraints(194, 39, 105, 55));
contentPane.add(table10, new XYConstraints(194, 220, 105, 55));
contentPane.add(table1, new XYConstraints(45, 39, 105, 55));
contentPane.add(table3, new XYConstraints(357, 39, 105, 55));
contentPane.add(table4, new XYConstraints(498, 38, 105, 55));
contentPane.add(table8, new XYConstraints(500, 122, 105, 55));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -