implements HelpListener : HelpListener « org.eclipse.swt.events « Java by API






implements HelpListener


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.HelpEvent;
import org.eclipse.swt.events.HelpListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class MainClass {

  public static void main(String[] a) {
    Display display = new Display();

    // Create the main window
    Shell shell = new Shell(display);

    Text fahrenheit = new Text(shell, SWT.BORDER);
    fahrenheit.setData("Type a temperature in Fahrenheit");
    fahrenheit.setBounds(20,20,100,20);
    
    fahrenheit.addHelpListener(new HelpListener(){
      public void helpRequested(HelpEvent event) {
        System.out.println((String) event.widget.getData());
      }
     
    });
    
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}

           
       








Related examples in the same category