Button Selection Event : Button « SWT JFace Eclipse « Java






Button Selection Event


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Gui_4 {

  /**
   * user code fields V4ALL Entry Level
   */
  //user code begin FIELDS {1} Swing
  //user code end
  //user code begin FIELDS {1} SWT
  //user code end
  //user code begin FIELDS {1} HTML
  //user code end
  //user code begin FIELDS {1} Eclipse
  //user code end
  //user code begin FIELDS {1} C#
  //user code end
  /**
   * user code methods V4ALL Entry Level
   */
  //user code begin METHODS {1} Swing
  //user code end
  //user code begin METHODS {1} SWT
  //user code end
  //user code begin METHODS {1} HTML
  //user code end
  //user code begin METHODS {1} Eclipse
  //user code end
  //user code begin METHODS {1} C#
  //user code end

  public void processEvent() {
    // user code begin {1} Swing
    // user code end
    // user code begin {1} SWT
    ivjLabel100.setText("No worries.");
    // user code end
    // user code begin {1} HTML
    // user code end
    // user code begin {1} Eclipse
    // user code end
    // user code begin {1} C#
    // user code end
  }

  /**
   * Initializes connections
   * 
   * @exception java.lang.Exception
   *                The exception description.
   */
  /* WARNING: THIS METHOD WILL BE REGENERATED. */
  private void initConnections() throws java.lang.Exception {
    // user code begin {1} Swing
    // user code end
    // user code begin {1} SWT
    // user code end
    // user code begin {1} HTML
    // user code end
    // user code begin {1} Eclipse
    // user code end
    // user code begin {1} C#
    // user code end
    // user code begin {2} Swing
    // user code end
    // user code begin {2} SWT
    // user code end
    // user code begin {2} HTML
    // user code end
    // user code begin {2} Eclipse
    // user code end
    // user code begin {2} C#
    // user code end
  }

  /**
   * Return the Frame100 property value.
   * 
   * @return Shell
   */
  /* WARNING: THIS METHOD WILL BE REGENERATED. */
  public Shell getFrame100() {
    if (ivjFrame100 == null) {
      try {
        Display display = new Display();
        ivjFrame100 = new Shell(display);
        ivjFrame100.setBounds(47, 55, 365, 184);
        ivjFrame100.setForeground(new Color(null, 0, 0, 0));
        int height = java.awt.Toolkit.getDefaultToolkit()
            .getScreenSize().height;
        int width = java.awt.Toolkit.getDefaultToolkit()
            .getScreenSize().width;
        ivjFrame100.setLocation(width / 2 - 365 / 2,
            height / 2 - 184 / 2);
        // user code begin {1} Swing
        // user code end
        // user code begin {1} SWT
        // user code end
        // user code begin {1} HTML
        // user code end
        // user code begin {1} Eclipse
        // user code end
        // user code begin {1} C#
        // user code end
      } catch (java.lang.Throwable ivjExc) {
        // user code begin {1} Swing
        // user code end
        // user code begin {1} SWT
        // user code end
        // user code begin {1} HTML
        // user code end
        // user code begin {1} Eclipse
        // user code end
        // user code begin {1} C#
        // user code end
        handleException(ivjExc);
      }
    }
    return ivjFrame100;
  }

  /**
   * V4ALL Entry Level Return the Button100 property value.
   * 
   * @return Buttonl
   */
  /* WARNING: THIS METHOD WILL BE REGENERATED. */
  private Button getButton100() {
    if (ivjButton100 == null) {
      try {
        ivjButton100 = new Button(getFrame100(), SWT.NULL);
        ivjButton100.setText("Click Me");
        ivjButton100.setBounds(80, 76, 85, 25);
        ivjButton100.setForeground(new Color(null, 0, 0, 0));
        ivjButton100.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            processEvent();
            // user code begin {3} SWT
            // user code end
          };
        });
        // user code begin {1} Swing
        // user code end
        // user code begin {1} SWT
        // user code end
        // user code begin {1} HTML
        // user code end
        // user code begin {1} Eclipse
        // user code end
        // user code begin {1} C#
        // user code end
      } catch (java.lang.Throwable ivjExc) {
        // user code begin {2} Swing
        // user code end
        // user code begin {2} SWT
        // user code end
        // user code begin {2} HTML
        // user code end
        // user code begin {2} Eclipse
        // user code end
        // user code begin {2} C#
        // user code end
        handleException(ivjExc);
      }
    }
    return ivjButton100;
  }

  /**
   * V4ALL Entry Level Return the Label100 property value.
   * 
   * @return org.eclipse.swt.widgets.Labell
   */
  /* WARNING: THIS METHOD WILL BE REGENERATED. */
  private org.eclipse.swt.widgets.Label getLabel100() {
    if (ivjLabel100 == null) {
      try {
        ivjLabel100 = new org.eclipse.swt.widgets.Label(getFrame100(),
            SWT.NULL);
        ivjLabel100.setText(" ");
        ivjLabel100.setBounds(218, 76, 82, 23);
        ivjLabel100.setForeground(new Color(null, 0, 0, 0));
        // user code begin {1} Swing
        // user code end
        // user code begin {1} SWT
        // user code end
        // user code begin {1} HTML
        // user code end
        // user code begin {1} Eclipse
        // user code end
        // user code begin {1} C#
        // user code end
      } catch (java.lang.Throwable ivjExc) {
        // user code begin {2} Swing
        // user code end
        // user code begin {2} SWT
        // user code end
        // user code begin {2} HTML
        // user code end
        // user code begin {2} Eclipse
        // user code end
        // user code begin {2} C#
        // user code end
        handleException(ivjExc);
      }
    }
    return ivjLabel100;
  }

  /**
   * Initialize the class.
   */
  /* WARNING: THIS METHOD WILL BE REGENERATED. */
  private void initialize() {
    try {
      // user code begin {1} Swing
      // user code end
      // user code begin {1} SWT
      // user code end
      // user code begin {1} HTML
      // user code end
      // user code begin {1} Eclipse
      // user code end
      // user code begin {1} C#
      // user code end
      initConnections();
      // user code begin {2} Swing
      // user code end
      // user code begin {2} SWT
      // user code end
      // user code begin {2} HTML
      // user code end
      // user code begin {2} Eclipse
      // user code end
      // user code begin {2} C#
      // user code end
    } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
    }
  }

  /**
   * V4ALL Entry Level Called whenever the part throws an exception.
   * 
   * @param exception
   *            java.lang.Throwable
   */
  private void handleException(java.lang.Throwable exception) {
    /* Uncomment the following lines to print uncaught exceptions to stdout */
    // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
    // exception.printStackTrace(System.out);
  }

  private Shell ivjFrame100 = null;

  private Button ivjButton100 = null;

  private org.eclipse.swt.widgets.Label ivjLabel100 = null;

  /**
   * Gui_4 constructor comment.
   * 
   * @param title
   *            java.lang.String
   */
  public Gui_4(String title) {
    getFrame100().setText(title);
  }

  /**
   * main entrypoint - starts the part when it is run as an application
   * 
   * @param args
   *            java.lang.String[]
   */
  public static void main(java.lang.String[] args) {
    try {
      Gui_4 aGui_4;
      aGui_4 = new Gui_4("Frame");
      aGui_4.getFrame100();
      aGui_4.getButton100();
      aGui_4.getLabel100();
      aGui_4.getFrame100().open();
      while (!aGui_4.getFrame100().isDisposed()) {
        if (!aGui_4.getFrame100().getDisplay().readAndDispatch())
          aGui_4.getFrame100().getDisplay().sleep();
      }
      aGui_4.getFrame100().dispose();
    } catch (Throwable exception) {
      System.err
          .println("Exception occurred in main() of javax.swing.JFrame");
      exception.printStackTrace(System.out);
    }
  }

}

           
       








Related examples in the same category

1.SWT ButtonSWT Button
2.SWT Button Example DemoSWT Button Example Demo
3.SWT Button ActionSWT Button Action
4.Icon SelectorIcon Selector
5.Default ButtonDefault Button
6.Button StylesButton Styles
7.Image Button
8.Widget StylesWidget Styles
9.Demonstrates ButtonsDemonstrates Buttons
10.Button ExampleButton Example
11.Arrow Button ExampleArrow Button Example
12.Make a toggle button have radio behaviorMake a toggle button have radio behavior
13.Set the default buttonSet the default button