Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] hyperlink using SWT

 

Here I am attaching an example file....now I want to make "Register" as hyperlink text (Register)...I think with this example it could be more clear.

Could anyone help out ...Its quite urgent, I m really stuck up with this.

 

 

 

 

-----Original Message-----
From: platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] On Behalf Of Raju Jacob, Choorappadil
Sent:
Friday, September 09, 2005 3:20 PM
To: Eclipse Platform SWT component developers list.
Subject: RE: [platform-swt-dev] hyperlink using SWT

 

you may try this..

 


From: platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] On Behalf Of Vineet Puri
Sent:
Friday, September 09, 2005 5:13 PM
To: 'Eclipse Platform SWT component developers list.'
Subject: RE: [platform-swt-dev] hyperlink using SWT

 

I don't have to use it in the table, its just a simple text "setText"...and I've to give it a hyperlink ..for e.g Register... could u please help out

 

Thanks & Regards,

Vineet Puri

 

-----Original Message-----
From: platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] On Behalf Of mengqp
Sent:
Friday, September 09, 2005 1:36 PM
To: Eclipse Platform SWT component developers list.
Subject: Re: [platform-swt-dev] hyperlink using SWT

 

Try to run NewComposite2, and click "creat..." button , then a new line will be added to table  . click those column .

----- Original Message -----

From: Vineet Puri

Sent: Friday, September 09, 2005 3:43 PM

Subject: [platform-swt-dev] hyperlink using SWT

 

Could anyone please help me out in how to provide a hyperlink text using SWT. I got an example but its using html in SWT, and not working with other tools of SWT. Please could anyone help me out with an example including "heperlink text, menubar, text box "..etc.

 

Thanks & Regards,

Vineet Puri

 


_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


This email message and any files transmitted with it contain confidential information intended only for the person(s) to whom this email message is addressed. If you have received this email message in error, please notify the sender immediately by telephone or email and destroy the original message without making a copy. Thank you.

package testing;



import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import javax.swing.event.HyperlinkEvent;
import org.eclipse.swt.widgets.Text;

import com.spogger.AboutDialog;
import com.spogger.FAQDialog;
import com.spogger.StoringUserName;
import com.spogger.UploaderScreen;

import java.io.File;
import java.util.StringTokenizer;

import javax.swing.JEditorPane;

public class Login 
{
	Display display;
	Shell shell;
	Font font;
    Text _txtUserName;
	Text _txtPassword;	
	String Passwordfordb4o;
    String UserNamefordb4o ;
    String user_name = "";
    String _password = "";
    StoringUserName s = new StoringUserName();
    
	public Login(){	
		checkForYapFile();
		createFrame();
		createMenubar();
		createComponents();		
		defineShellConstants();
	}
	private void defineShellConstants(){
		
		shell.setSize(450,275); 
		shell.setLocation(250,250); 
		shell.open ();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) 
				display.sleep();
		}
		display.dispose();
	}	
	private void createFrame(){
		display = new Display();
		shell = new Shell(display);
		font = new Font (display, "", 9, SWT.BOLD);
		shell.setText("Test Screen");
	}
	private void createMenubar(){
		Menu _menubar = new Menu(shell,SWT.BAR);
		shell.setMenuBar(_menubar);  
		MenuItem _menuItemFile = new MenuItem(_menubar,SWT.CASCADE);
		_menuItemFile.setText("&File");
		//_menuItemFile.setAccelerator(SWT.CTRL+'F');
		Menu fileMenu = new Menu(shell,SWT.DROP_DOWN);
		_menuItemFile.setMenu(fileMenu);
		MenuItem _menuItemQuit = new MenuItem(fileMenu,SWT.PUSH);
		_menuItemQuit.setText("&Quit\tCTRL+Q");  
		_menuItemQuit.setAccelerator(SWT.CTRL+'Q');
		_menuItemQuit.addSelectionListener(new SelectionAdapter(){
			public void widgetSelected(SelectionEvent e){
				MessageBox messageBox = new MessageBox(shell,SWT.ICON_QUESTION | 
						SWT.YES | SWT.NO);
				messageBox.setMessage("Do you really want to Quit?");
				int response = messageBox.open();
				if(response==SWT.YES)
				shell.close();  
			}
		}); 
		
		MenuItem _menuItemHelp = new MenuItem(_menubar,SWT.CASCADE);
		_menuItemHelp.setText("&Help");  
		Menu helpMenu = new Menu(shell,SWT.DROP_DOWN);
		_menuItemHelp.setMenu(helpMenu);
		MenuItem _menuItemFAQ = new MenuItem(helpMenu,SWT.PUSH);
		_menuItemFAQ.setText("&FAQ"); 
		_menuItemFAQ.addSelectionListener(new SelectionAdapter(){
			public void widgetSelected(SelectionEvent e){
				System.out.println("FAQ menu item clicked");
				FAQDialog f = new FAQDialog(shell);
			}
		}); 
		MenuItem _menuItemAbout = new MenuItem(helpMenu,SWT.PUSH);
		_menuItemAbout.setText("&About"); 
		_menuItemAbout.addSelectionListener(new SelectionAdapter(){
			public void widgetSelected(SelectionEvent e){
				System.out.println("About menu item clicked");
				AboutDialog ad = new AboutDialog(shell);
			
			}
		}); 
	}
	private void createComponents(){
		Label _lblUserName = new Label(shell,SWT.NULL);
		_lblUserName.setText("UserName");
		_lblUserName.setSize(70,20);
		_lblUserName.setLocation(10,10);
		_lblUserName.setFont(font);
		
		_txtUserName = new Text(shell,SWT.SINGLE|SWT.BORDER);
		_txtUserName.setBounds(80,10,200,20);
		_txtUserName.setTextLimit(30);
		_txtUserName.setEditable(true);
		_txtUserName.setText(user_name);
		
		Label _lblPassword = new Label(shell,SWT.NULL);//,SWT.BORDER);
		_lblPassword.setText("Password");
		_lblPassword.setSize(70,20);
		_lblPassword.setLocation(10,50);
		_lblPassword.setFont(font);  
		
		_txtPassword = new Text(shell,SWT.PASSWORD|SWT.BORDER);
		_txtPassword.setBounds(80,50,200,20);
		_txtPassword.setTextLimit(30);
		_txtPassword.setEditable(true);
		_txtPassword.setText(_password);
		
		final Label _lblRegister =  new Label(shell,SWT.NULL);
		_lblRegister.setText("Register");
		_lblRegister.setSize(100,50);
		_lblRegister.setLocation(320,50); 
		_lblRegister.setFocus();
		
				
		final Button _cbRememberUserNameAndPwd = new Button(shell,SWT.CHECK);
		_cbRememberUserNameAndPwd.setText("Remember my username and password");
		_cbRememberUserNameAndPwd.setSize(220,50);
		_cbRememberUserNameAndPwd.setLocation(30,80);
		_cbRememberUserNameAndPwd.addSelectionListener(new SelectionAdapter(){			
			public void widgetSelected(SelectionEvent e){
				System.out.println("Submit button Clicked");
				UserNamefordb4o  = _txtUserName.getText();				
				System.out.println("UserName is "+UserNamefordb4o);
				Passwordfordb4o = _txtPassword.getText();
				System.out.println("Password is "+Passwordfordb4o);	
				s.createData(UserNamefordb4o,Passwordfordb4o);
				System.out.println("Remember Username and Pwd Check box clicked");
				
			}
		}); 
		
				
		Button _btnSubmit = new Button(shell,SWT.PUSH);
		_btnSubmit.setText("Submit");
		_btnSubmit.setSize(80,40);
		_btnSubmit.setLocation(320,165);  
		_btnSubmit.addSelectionListener(new SelectionAdapter(){
			public void widgetSelected(SelectionEvent e){
				String Txtusername = _txtUserName.getText();
				String Txtpassword = _txtPassword.getText();
				System.out.println("Txtusername "+Txtusername);
				System.out.println("Txtpassword "+Txtpassword);
				if((Txtusername=="")||(Txtpassword=="")){	
				MessageBox messageBox = new MessageBox(shell,SWT.ICON_ERROR );
				messageBox.setMessage("Please Enter Some Data");
				messageBox.open();
				}
				else{
				display.dispose();
				UploaderScreen uploader = new UploaderScreen();	
				}
			}
		}); 
	}
	protected void checkForYapFile(){ //this will be the 1st method in the constructor
		File file= new File("c:/NameAndPwd.yap");
		if(file.exists()){	
			String strName = s.retrieveData();
			System.out.println("strName "+strName);
			StringTokenizer st = new StringTokenizer(strName,":");
        	while(st.hasMoreTokens()){
        		 user_name = st.nextElement().toString();
        		 System.out.println("user_name " + user_name);          		 
        		 _password = st.nextElement().toString();
        		 System.out.println("_password " + _password);  
        	}
			System.out.println("Yap File Exists");
		}else{
			System.out.println("Yap File does not Exist");
		}
		
	}
		public static void main(String args[]){

			Login login = new Login();
	
	}
		public void hyperlinkUpdate(HyperlinkEvent e){ 
	        if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){ 
	            try{ 
	                ((JEditorPane)e.getSource()).setPage(e.getURL()); 
	            } catch(Exception ex){ 
	                ex.printStackTrace(); 
	            } 
	        } 
	    } 

}




Back to the top