code_work_posOrder_1.3

PosOrderMainWin.java

 

//list
        final List list = new List(c2, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL|SWT.SIMPLE);//
        list.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
            @Override
            //取得当前选取的项目
            public void widgetSelected(SelectionEvent e) {
//             String select[] = list.getSelection();
//             for(int i=0; i < select.length; i ++)
//             {
//            	 System.out.println(select[i]);
//             }
//           list Data
             
//             new CustomDialog(Display.getCurrent().getActiveShell(), 
//            		 ManName, ClassName, OrderName, account, SimplePrice, allPrice
//            		 ).open();      
             
           new CustomDialog(Display.getCurrent().getActiveShell(), list.getSelection()[0]).open();  
              
            }
           });
        
	        //list Data
	        String ManName = "Bill"; 
	        String ClassName = "套餐"; 
	        String OrderName = "西红柿"; 
	        int account = 2; 
	        double SimplePrice = 12.0;
	        double allPrice = SimplePrice * account;
	        
//           list.setItems(new String[] {"one", "two", "three"});//初始发list
           list.add(ManName+ " 订了 " + OrderName + "(" + ClassName + ") " + account + "件, 单价:" + SimplePrice +", 总价:" + allPrice);
//           list.add("five", 2);//在list的第二个位置加值
//           list.add("ddddd");
//           list.setBounds(100, 50, 50, 50);


 

 

 

 CustomDialog.java

 

public class CustomDialog extends Dialog {

	protected Object result;     
    protected Shell shell;     
    String ManName;   
    String ClassName;   
    String OrderName;   
    int account;   
    double SimplePrice;  
    double allPrice;  
    String context;
    
    public CustomDialog(Shell parent, String ManName, String ClassName, String OrderName, int account, double SimplePrice, double allPrice) {     
        super(parent, SWT.NONE);   
        this.ManName = ManName;   
        this.ClassName = ClassName;   
        this.OrderName = OrderName;   
        this.account = account;   
        this.SimplePrice = SimplePrice;  
        this.allPrice = allPrice;  
        this.context = ManName+ " 订了 " + OrderName + "(" + ClassName + ") " + account + "件, 单价:" + SimplePrice +", 总价:" + allPrice;
    }     
    
    public CustomDialog(Shell parent, String context) {     
        super(parent, SWT.NONE);   
        this.context = context;
    }   
    
    public Object open() {     
        createContents();     
        shell.open();     
        shell.layout();     
        Display display = getParent().getDisplay();     
        while (!shell.isDisposed()) {     
            if (!display.readAndDispatch())     
                display.sleep();     
        }     
        return result;     
    }     
    
    protected void createContents() {     
        shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);     
        shell.setSize(300, 100);     
        shell.setText("Order Details Dialog");    
        shell.setLocation(400, 400);  
    
//        final Button button = new Button(shell, SWT.NONE);     
        final Text txt = new Text(shell, SWT.NONE);  
        txt.setText(context);  
        txt.setSize(300, 20);     
//        txt.setBounds(127, 74, 44, 23);      
//        button.setBounds(127, 74, 44, 23);      
    }     


}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

折腾数据折腾代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值