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

📄 j_fusionsample1.java

📁 该文档是 用的摩托罗拉的Rfid API开发包做的测试程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			
			try {
				item.setText (1, profiles.get(i).getName());
				item.setText (2, profiles.get(i).getId());    //profile ID
			} catch (WlanException e) {
				e.printStackTrace();
			}  //profile name
		}
		
	}

	
	/**
	 * Create About box
	 *
	 */
	void createAbout(){
	
		ResourceBundle res = ResourceBundle.getBundle("J_FusionSample1Res", new Locale("en","US"));
		tblAbout = new Table (shell, SWT.H_SCROLL|SWT.V_SCROLL|SWT.FULL_SELECTION);	
		tblAbout.setHeaderVisible (true);
		String[] titles = {res.getString("LST_ABOUT_TITLE_ITEM")};
		for (int i=0; i<titles.length; i++) {
			TableColumn column = new TableColumn (tblAbout, SWT.NONE);
			column.setText (titles [i]);
		}	

			
		TableItem item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_BACK"));

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, "");

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_SAMPLE_NAME") + 
			" " + res.getString("LST_ABOUT_DESCRIPTION_SAMPLE_VERSION"));
		
		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, "");

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_COPYRIGHT"));

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_COMPANY"));

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, "");

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_DESC_LINE1"));

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_DESC_LINE2"));

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_DESC_LINE3"));

		item = new TableItem (tblAbout, SWT.NONE);
		item.setText (0, res.getString("LST_ABOUT_DESCRIPTION_DESC_LINE4"));

		tblAbout.setSize (tblAbout.computeSize (width,height));
		
		tblAbout.getColumn(0).setWidth(width);//get total with of the screen
		
		tblAbout.setLayoutData(gridData8);
		
		tblAbout.addSelectionListener(this);
		tblAbout.addKeyListener(this);
		tblAbout.addMouseListener(this);
		tblAbout.setVisible(false);
		
		
	}
	
	/**
	 * callback function for signal quality change
	 */	
	public void signalQualityChanged(SignalQualityEvent evt) {

		//get new signal quality
		newQuality = evt.getSignalQuality();
		
		//get new signal strength
		newStrength = evt.getSignalStrength();

		try {
			updateMainList();   //update main panel with new information
		} catch (Exception e) {
			
			e.printStackTrace();
		}
	}

	public void widgetSelected(SelectionEvent arg0) {

	}
	
	/**
	 * Event handler for all the tables in this sample
	 */
	public void widgetDefaultSelected(SelectionEvent arg0) {
		
		Table t = (Table)arg0.getSource();

		if(t.equals(tblMain)){
			switch(t.getSelectionIndex()){
				case 0://0-[Exit]
				deleteSampleProfiles();//delete created sample profiles when exit
				adapter.removeSignalQualityListener(this);
				tblMain.removeSelectionListener(this);
				tblVersions.removeSelectionListener(this);
				tblProfiles.removeSelectionListener(this);
				tblAbout.removeSelectionListener(this);
				tblMain.removeKeyListener(this);
				tblMain.removeMouseListener(this);
				tblVersions.removeKeyListener(this);
				tblVersions.removeMouseListener(this);
				tblProfiles.removeKeyListener(this);
				tblProfiles.removeMouseListener(this);
				tblAbout.removeKeyListener(this);
				tblAbout.removeMouseListener(this);
						
				try {
					wlan.dispose();
				} catch (WlanException e) {
					e.printStackTrace();
				}

				System.exit(0);
				break;
				
				case 3://Profiles...
				updateProfileList();//update the profile list before display
				tblMain.setVisible(false);
				tblProfiles.setVisible(true);
				tblProfiles.setSelection(0);
				tblProfiles.setFocus();
				currentTable = 2;
				break;
				
				case 4://Versions...
				tblMain.setVisible(false);
				tblVersions.setVisible(true);
				tblVersions.setSelection(0);
				tblVersions.setFocus();
				currentTable = 1;
				break;
				
				case 5://About...
				tblMain.setVisible(false);
				tblAbout.setVisible(true);
				tblAbout.setSelection(0);
				tblAbout.setFocus();
				currentTable = 3;
				break;
			}
			
		}else if(t.equals(tblVersions)){
			switch(t.getSelectionIndex()){
				case 0://0-[Back]
				tblVersions.setVisible(false);
				tblMain.setVisible(true);
				tblMain.setFocus();
				currentTable = 0;
				break;
				
			}
			
		}else if(t.equals(tblProfiles)){
			if(t.getSelectionIndex()==0){//0-[Back]				
				tblProfiles.setVisible(false);
				tblMain.setVisible(true);									
				tblMain.setFocus();
				currentTable = 0;
			}else{
				try {
					//search for profile
					for(int i=0; i<profiles.getLength();i++){
					
						if(profiles.get(i).getId().equals(tblProfiles.getItem(t.getSelectionIndex()).getText(2))){
							profile = profiles.get(i);
							break;
						}
					}
					Win32.setWaitCursor(true);

					tblProfiles.setSelection(switchNo);
								
					//connect to the selected profile with persistance=true
					profile.connect(true);

	   			} catch (WlanException e) {
			
		   			e.printStackTrace();
	   			}
				//And go back to the main list...
				tblProfiles.setVisible(false);
				tblMain.setVisible(true);									
				tblMain.setFocus();
				currentTable = 0;
				
				try {
					
					updateMainList();//update main panel when return
				} catch (Exception e1) {
					e1.printStackTrace();
				}
					
				Win32.setWaitCursor(false);
				
			}
			
		}else if(t.equals(tblAbout)){
			if(t.getSelectionIndex()==0){//0-[Back]				
				tblAbout.setVisible(false);
				tblMain.setVisible(true);									
				tblMain.setFocus();
				currentTable = 0;
			}
		}
		
		digitsCount = 0;
		switchNo = 0;
		lastKeyTime = 0;
		
		
	}
	
	public void keyPressed(KeyEvent ke){

		long currKeyTime = System.currentTimeMillis();
		if(currentTable == 0){
			if((ke.character >= '0') && (ke.character <= '9')){
				if(digitsCount==0){
					lastKeyTime = currKeyTime;
					switchNo = ((int)(ke.character)) - 48;
					digitsCount++;
					if(tblMain.getItemCount()>10)
						return;
				}
				else if(digitsCount == 1){
					if((currKeyTime - lastKeyTime)<1000){
						digitsCount++; 
						switchNo = (switchNo * 10) + (((int)(ke.character)) - 48);
					}
					else{
						digitsCount = 1;
						switchNo = ((int)(ke.character)) - 48;
						lastKeyTime = currKeyTime;
						return;
					};
				}
				else {
					;
				};
			}

			else{ 
				digitsCount = 0;
				switchNo = 0;
				lastKeyTime = 0;
				return;
			}
			switch(switchNo){
				case 0://0-[Exit]
				deleteSampleProfiles();//delete created sample profiles when exit
				adapter.removeSignalQualityListener(this);
				tblMain.removeSelectionListener(this);
				tblVersions.removeSelectionListener(this);
				tblProfiles.removeSelectionListener(this);
				tblAbout.removeSelectionListener(this);
				tblMain.removeKeyListener(this);
				tblMain.removeMouseListener(this);
				tblVersions.removeKeyListener(this);
				tblVersions.removeMouseListener(this);
				tblProfiles.removeKeyListener(this);
				tblProfiles.removeMouseListener(this);
				tblAbout.removeKeyListener(this);
				tblAbout.removeMouseListener(this);
				
				try {
					wlan.dispose();
				} catch (WlanException e) {
					e.printStackTrace();
				}
				System.exit(0);
				break;
				
				case 3://Profiles...
				updateProfileList();//update the profile list before display
				tblMain.setVisible(false);
				tblProfiles.setVisible(true);
				tblProfiles.setSelection(0);
				tblProfiles.setFocus();
				currentTable = 2;
				break;
				
				case 4://Versions...
				tblMain.setVisible(false);
				tblVersions.setVisible(true);
				tblVersions.setSelection(0);
				tblVersions.setFocus();
				currentTable = 1;
				break;
				
				case 5://About...
				tblMain.setVisible(false);
				tblAbout.setVisible(true);
				tblAbout.setSelection(0);
				tblAbout.setFocus();
				currentTable = 3;
				break;
			}
			
			digitsCount = 0;
			switchNo = 0;
			lastKeyTime = 0;
			return;
			
		}else if(currentTable == 1){
			if((ke.character >= '0') && (ke.character <= '9')){
				if(digitsCount==0){
					lastKeyTime = currKeyTime;
					switchNo = (((int)(ke.character)) - 48);
					digitsCount++;
					if(tblVersions.getItemCount()>10)
						return;
				}
				else if(digitsCount == 1){
					if((currKeyTime - lastKeyTime)<1000){
						digitsCount++; 
						switchNo = (switchNo * 10) + (((int)(ke.character)) - 48);
					}
					else{
						digitsCount = 1;
						switchNo = ((int)(ke.character)) - 48;
						lastKeyTime = currKeyTime;
						return;
					};
				}
				else {
				};
			}

			else{ 
				digitsCount = 0;
				switchNo = 0;
				lastKeyTime = 0;
				return;
			}
			switch(switchNo){
				case 0://0-[Back]
				tblVersions.setVisible(false);
				tblMain.setVisible(true);
				tblMain.setFocus();
				currentTable = 0;
				break;
				
			}
			digitsCount = 0;
			switchNo = 0;
			lastKeyTime = 0;
			return;
			
		}else if(currentTable == 2){
			if((ke.character >= '0') && (ke.character <= '9')){
				if(digitsCount==0){
					lastKeyTime = currKeyTime;
					switchNo = (((int)(ke.character)) - 48);
					digitsCount++;
					if(tblProfiles.getItemCount()>10)
						return;
				}
				else if(digitsCount == 1){
					if((currKeyTime - lastKeyTime)<1000){
						digitsCount++; 
						switchNo = (switchNo * 10) + (((int)(ke.character)) - 48);
					}
					else{
						digitsCount = 1;
						switchNo = ((int)(ke.character)) - 48;
						lastKeyTime = currKeyTime;
						return;
					};
				}
				else {
				};
			}

			else{ 
				digitsCount = 0;
				switchNo = 0;
				lastKeyTime = 0;
				return;
			}

⌨️ 快捷键说明

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