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

📄 netsenderframe.java

📁 用swt作的一个类似飞鸽一样的局域网通信工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData2.heightHint = 28;
		gridData2.grabExcessVerticalSpace = false;
		gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		cBanner = new CBanner(composite2, SWT.NONE);
		cBanner.setSimple(false);
		cBanner.setLayoutData(gridData2);
		cBanner.setBackground(SAPWindowFrame.BACKGROUNDCOLOR);
		createComposite3();
		cBanner.setLeft(composite3);
		createComposite5();
		cBanner.setRight(composite5);
	}

	/**
	 * This method initializes composite3	
	 *
	 */
	private void createComposite3() {
		GridData gridData6 = new org.eclipse.swt.layout.GridData();
		gridData6.grabExcessHorizontalSpace = true;
		gridData6.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
		gridData6.grabExcessVerticalSpace = false;
		gridData6.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		GridData gridData5 = new org.eclipse.swt.layout.GridData();
		gridData5.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData5.grabExcessHorizontalSpace = false;
		gridData5.grabExcessVerticalSpace = true;
		gridData5.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
		GridData gridData4 = new org.eclipse.swt.layout.GridData();
		gridData4.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData4.grabExcessHorizontalSpace = false;
		gridData4.grabExcessVerticalSpace = true;
		gridData4.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
		GridLayout gridLayout3 = new GridLayout();
		gridLayout3.numColumns = 4;
		gridLayout3.verticalSpacing = 0;
		gridLayout3.marginWidth = 0;
		gridLayout3.marginHeight = 0;
		gridLayout3.horizontalSpacing = 0;
		composite3 = new Composite(cBanner, SWT.NONE);
		composite3.setBackground(SAPWindowFrame.BACKGROUNDCOLOR);
		composite3.setLayout(gridLayout3);
		button = new Button(composite3, SWT.NONE);
		button.setText("&Action");
		button.setLayoutData(gridData4);
		button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
			public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
				int locateX = button.getLocation().x+((FillLayout)NetSenderFrame.this.getLayout()).marginWidth;
				int locateY = composite1.getLocation().y + parent.moveBarPanel.getSize().y + button.getSize().y+8;
				menu.setLocation(getShell().getLocation().x + locateX,	getShell().getLocation().y	+ locateY);
				menu.setVisible(true);
			}
		});
		cLabel = new CLabel(composite3, SWT.NONE);
		cLabel.setBackground(SAPWindowFrame.BACKGROUNDCOLOR);
		cLabel.setText("Host :");
		cLabel.setLayoutData(gridData5);
		cCombo = new CCombo(composite3, SWT.BORDER);
		cCombo.setText("");
		cCombo.setLayoutData(gridData6);
		cCombo.addModifyListener(new ModifyListener(){

			public void modifyText(ModifyEvent e) {
				if (NetSenderFrame.this.cCombo.equals("")) {
					Color color = new Color(Display.getCurrent(), 255,220,220);
					cCombo.setBackground(color);
					color.dispose();
				}else{
					Color color = new Color(Display.getCurrent(), 255,255,255);
					cCombo.setBackground(color);
					color.dispose();
				}
			}
			
		});
		button2 = new Button(composite3, SWT.NONE);
		button2.setText("");
		button2.setImage(new Image(Display.getCurrent(), getClass()
				.getResourceAsStream("/view/picture/refresh2.png")));
		button2.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
			public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
				
				new GetOnlineListThread("recreate");
				try {
					Thread.sleep(3000);
				} catch (InterruptedException e1) {
					e1.printStackTrace();
				}
				new GetOnlineListThread(NetSenderFrame.this);
			}
		});
	}

	/**
	 * This method initializes composite5	
	 *
	 */
	private void createComposite5() {
		
		GridLayout gridLayout5 = new GridLayout();
		
		gridLayout5.horizontalSpacing = 0;
		
		gridLayout5.marginWidth = 0;
		
		gridLayout5.verticalSpacing = 0;
		
		gridLayout5.marginHeight = 0;
		
		composite5 = new Composite(cBanner, SWT.NONE);
		
		composite5.setLayout(gridLayout5);
		
		composite5.setBackground(SAPWindowFrame.BACKGROUNDCOLOR);
		
		button1 = new Button(composite5, SWT.NONE);
		
		button1.setText("&Send");
		
		button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
			
			public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
				
				NetSenderDaemon nsd = null;
				
				String IPAddress = "";
				
				String hostName = "";
				
				if (cCombo.getText().equals("")) {
					Color color = new Color(Display.getCurrent(), 255,220,220);
					cCombo.setBackground(color);
					color.dispose();
					
				}else{
					IPAddress = (String)NetSenderFrame.splitToken(cCombo.getText()).get(0);
					
					try {
						Configuration rc = new Configuration(NetTransfer.SetupFile);
					    
					    hostName = rc.getValue("HostName");
						
					    if (hostName.equals("")) hostName = new String(InetAddress.getLocalHost().getHostName().getBytes());
					    
					} catch (UnknownHostException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					} 
					
					parent.getShell().setVisible(false);
					
					if (textArea.getText()==null || textArea.getText().equals("")) nsd = new NetSenderDaemon(IPAddress,hostName,main.NetReceiver.TCPport," ",selectedFiles);
				
					else nsd = new NetSenderDaemon(IPAddress,hostName,main.NetReceiver.TCPport,textArea.getText(),selectedFiles);
				
					if (nsd.isConnected()){
						
						nsd.start();
						
						thisDispose();
						
					}else{
				
						parent.getShell().setVisible(true);
					}
				}
			}
		});
	}
	/*
	 *从字符串中以"|"作为分割符获取cmdList列表。
	 */
	public static List splitToken(String fs) {
		
		StringTokenizer pt = new StringTokenizer(fs, " ");
		
		List l = new ArrayList();
		
		while (pt.hasMoreTokens()) {
		
			l.add(pt.nextToken());
		}
		
		return l;
	}
	
	public void setComboAddress(String address){
		cCombo.setText(address);
	}
	public void setMessage(String message){
		StringBuffer sb= new StringBuffer(">"+message);
		for (int i=0; i<sb.length();i++){
			if (sb.charAt(i)=='\n') {
				sb.replace(i, i+1, "\n>");
				i++;
			}
		}
		textArea.setText(String.valueOf(sb));
		textArea.setSelection(textArea.getCharCount(), textArea.getCharCount());
	}
	public void addComboAddress(String address){
		cCombo.add(address);
	}
	public void removeComboAllItems(){
		cCombo.removeAll();
	}
	public void sortComboList(){
		IPAndHostPackage IPHostPackage[];
		String[] item = cCombo.getItems();
		IPHostPackage = new IPAndHostPackage[item.length];
		for (int i = 0; i<item.length; i++){
			String ipAddress = (String) NetSenderFrame.splitToken(item[i]).get(0);
			String hostName = (String) NetSenderFrame.splitToken(item[i]).get(1);
			IPHostPackage[i] = new IPAndHostPackage(ipAddress,hostName);
		}
		item = new SortIPAddress(IPHostPackage).getSortedIPAddress();
		removeComboAllItems();
		cCombo.setItems(item);
	}
	protected void free(){
		this.button1 = null;
		this.button2 = null;
		this.cBanner = null;
		this.cLabel = null;
		this.cLabel1 = null;
		this.composite = null;
		this.composite1 = null;
		this.composite2 = null;
		this.composite3 = null;
		this.composite5 = null;
		this.nfsBackPanel = null;
		this.parent = null;
		this.sashForm = null;
		this.textArea = null;
		this.button = null;
		this.cCombo = null;
		this.addFileMI = null;
		this.addFolderMI = null;
		this.delAllMI = null;
		this.menu = null;
		this.fileLogo = null;
		this.folderLogo = null;
		this.trashLogo = null;
		this.selectedFiles = null;
		this.list_NSF_FileHI = null;
	}
	public void thisDispose(){
		if ((nfsBackPanel!=null)&&!nfsBackPanel.isDisposed()) nfsBackPanel.thisDispose();
		if ((sashForm!=null)&&!sashForm.isDisposed()) sashForm.dispose();
		if ((composite!=null)&&!composite.isDisposed()) composite.dispose();
		if ((composite1!=null)&&!composite1.isDisposed()) composite1.dispose();
		if ((textArea!=null)&&!textArea.isDisposed()) textArea.dispose();
		if ((composite2!=null)&&!composite2.isDisposed()) composite2.dispose();
		if ((cBanner!=null)&&!cBanner.isDisposed()) cBanner.dispose();
		if ((composite3!=null)&&!composite3.isDisposed()) composite3.dispose();
		if ((cLabel!=null)&&!cLabel.isDisposed()) cLabel.dispose();
		if ((cLabel1!=null)&&!cLabel1.isDisposed()) cLabel1.dispose();
		if ((composite5!=null)&&!composite5.isDisposed()) composite5.dispose();
		if ((button1!=null)&&!button1.isDisposed()) button1.dispose();
		if ((button2!=null)&&!button2.isDisposed()) button2.dispose();
		if ((button!=null)&&!button.isDisposed()) button.dispose();
		if ((cCombo!=null)&&!cCombo.isDisposed()) cCombo.dispose();
		if ((addFileMI!=null)&&!addFileMI.isDisposed()) addFileMI.dispose();
		if ((addFolderMI!=null)&&!addFolderMI.isDisposed()) addFolderMI.dispose();
		if ((delAllMI!=null)&&!delAllMI.isDisposed()) delAllMI.dispose();
		if ((menu!=null)&&!menu.isDisposed()) menu.dispose();
		if ((fileLogo!=null)&&!fileLogo.isDisposed()) fileLogo.dispose();
		if ((folderLogo!=null)&&!folderLogo.isDisposed()) folderLogo.dispose();
		if ((trashLogo!=null)&&!trashLogo.isDisposed()) trashLogo.dispose();
		this.dispose();
		if (parent!=null) this.parent.thisDispose();
		free();
	}
}  

⌨️ 快捷键说明

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