⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifinstore.java

📁 JAVA编写的单击的PIZZA店销售系统
💻 JAVA
字号:
package GUI;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.*;
import PizzaProduct.Pizza;
public class IfInStore extends Dialog {

	protected Object result;
	protected Pizza[] pizzas;
	protected Shell shell;
	protected int eatinstore;
	
	Label label;
	/**
	 * Create the dialog
	 * @param parent
	 * @param style
	 */
	public IfInStore(Shell parent, int style) {
		super(parent, style);
	}

	/**
	 * Create the dialog
	 * @param parent
	 */
	public IfInStore(Shell parent,Pizza[] pizzas) {
		this(parent, SWT.NONE);
		this.pizzas=pizzas;
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		return result;
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		shell.setSize(399, 221);
		shell.setText("请选择");

		final Button button = new Button(shell, SWT.RADIO);
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				eatinstore=0;
			}
		});
		button.setText("在店内食用");
		button.setBounds(69, 72, 93, 16);

		final Button button_1 = new Button(shell, SWT.RADIO);
		button_1.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				eatinstore=1;
			}
		});
		button_1.setText("外送");
		button_1.setBounds(225, 72, 93, 16);
		/**
		 * after user click the button.
		 * we must get the information that if customer eat in the store
		 * so, wo need to check it.
		 * and then, we go on to the next(display the order detail).
		 */
		final Button button_2 = new Button(shell, SWT.NONE);
		button_2.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				if(button.getSelection()||button_1.getSelection()){
					if(eatinstore == 0){		
						final Shell fornext;
						fornext=shell.getShell();
						final PizzaOrderResult por = new PizzaOrderResult(fornext,pizzas,true);
						por.open();
						shell.close();
					}
					else if(eatinstore == 1){
						final Shell fornext;
						fornext=shell.getShell();
						final CustomerAdd customeraddress = new CustomerAdd(fornext,pizzas);
						customeraddress.open();
						shell.close();
					}
				}
				else{
					MessageDialog.openWarning(shell, "警告","请选择用餐地点");
				}
				
			}
		});
		button_2.setText("确定");
		button_2.setBounds(114, 126, 48, 22);

		final Button button_3 = new Button(shell, SWT.NONE);
		button_3.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				shell.close();				
			}
		});
		button_3.setText("返回");
		button_3.setBounds(203, 126, 48, 22);

	
		//
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -