Package com.gwesm.ui.temp

Source Code of com.gwesm.ui.temp.Search

package com.gwesm.ui.temp;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class Search {
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display, SWT.CLOSE | SWT.TITLE);
    shell.setText("Guild Wars : ESM");

    shell.addListener(SWT.Traverse, new Listener() {
      public void handleEvent(Event event) {
        switch (event.detail) {
        case SWT.TRAVERSE_ESCAPE:
          shell.close();
          event.detail = SWT.TRAVERSE_NONE;
          event.doit = false;
          break;
        }
      }
    });

    FormLayout shellFormLayout = new FormLayout();
    shellFormLayout.marginHeight = shellFormLayout.marginWidth = 5;
    shell.setLayout(shellFormLayout);

    Label campaignLabel = new Label(shell, SWT.NONE);
    campaignLabel.setText("Select campaign : ");

    Label zoneLabel = new Label(shell, SWT.NONE);
    zoneLabel.setText("Select zone : ");

    Combo drpDwnCombo1 = new Combo(shell, SWT.DROP_DOWN | SWT.BORDER
        | SWT.READ_ONLY);
    drpDwnCombo1.add("campaign...");
    drpDwnCombo1.add("campaign 1");
    drpDwnCombo1.add("campaign 2");
    drpDwnCombo1.add("campaign 3");
    drpDwnCombo1.setText("campaign ...");

    Combo drpDwnCombo2 = new Combo(shell, SWT.DROP_DOWN | SWT.BORDER
        | SWT.READ_ONLY);
    drpDwnCombo2.add("zone...");
    drpDwnCombo2.add("zone 1");
    drpDwnCombo2.add("zone 2");
    drpDwnCombo2.add("zone 3");
    drpDwnCombo2.setText("zone ...");

    FormData campaignLabelFormData = new FormData();
    campaignLabelFormData.top = new FormAttachment(0, 5);
    campaignLabel.setLayoutData(campaignLabelFormData);

    FormData zoneLabelFormData = new FormData();
    zoneLabelFormData.top = new FormAttachment(campaignLabel, 10);
    zoneLabel.setLayoutData(zoneLabelFormData);

    FormData drpDwnCombo1FormData = new FormData(125, 0);
    drpDwnCombo1FormData.top = new FormAttachment(campaignLabel, 5,
        SWT.CENTER);
    drpDwnCombo1FormData.left = new FormAttachment(campaignLabel, 0);
    drpDwnCombo1FormData.right = new FormAttachment(100, 0);
    drpDwnCombo1.setLayoutData(drpDwnCombo1FormData);

    FormData drpDwnCombo2FormData = new FormData(125, 0);
    drpDwnCombo2FormData.top = new FormAttachment(zoneLabel, 5, SWT.CENTER);
    drpDwnCombo2FormData.left = new FormAttachment(zoneLabel, 0);
    drpDwnCombo2FormData.right = new FormAttachment(100, 0);
    drpDwnCombo2.setLayoutData(drpDwnCombo2FormData);

    Button searchButton = new Button(shell, SWT.PUSH);
    searchButton.setText("Search");

    Button cancelButton = new Button(shell, SWT.PUSH);
    cancelButton.setText("Cancel");

    FormData searchButtonFormData = new FormData();
    searchButtonFormData.top = new FormAttachment(drpDwnCombo2, 20,
        SWT.BOTTOM);
    searchButtonFormData.left = new FormAttachment(shell, 75);
    searchButtonFormData.right = new FormAttachment(100, -75);
    searchButton.setLayoutData(searchButtonFormData);

    FormData cancelButtonFormData = new FormData();
    cancelButtonFormData.top = new FormAttachment(searchButton, 5,
        SWT.BOTTOM);
    cancelButtonFormData.left = new FormAttachment(shell, 75);
    cancelButtonFormData.right = new FormAttachment(100, -75);
    cancelButton.setLayoutData(cancelButtonFormData);

    cancelButton.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        shell.close();
      }
    });

    shell.pack();
    shell.open();

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

Related Classes of com.gwesm.ui.temp.Search

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.