Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.eclipse.swt.events.SelectionAdapter;
- import org.eclipse.swt.events.SelectionEvent;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Shell;
- import org.eclipse.swt.widgets.Composite;
- import org.eclipse.swt.SWT;
- import org.eclipse.swt.widgets.Text;
- import org.eclipse.swt.widgets.Spinner;
- import org.eclipse.swt.widgets.Label;
- import org.eclipse.swt.widgets.Button;
- public class Harness {
- protected static Shell shell;
- public static Text harnessModel, harnessMake, lastCheckedBy, onLoanTo, isOnLoan, timesUsed;
- public static Button saveCheck, saveMake, saveModel, saveLoan;
- private static String make = "";
- public static String check = "";
- public static String loan = "";
- public static String model = "";
- /**
- * Launch the application.
- * @param args
- */
- public static void main(String[] args) {
- try {
- Display display = Display.getDefault();
- shell = new Shell();
- shell.setSize(450, 300);
- shell.setText("Harness Record System");
- shell.open();
- shell.layout();
- Composite composite = new Composite(shell, SWT.NONE);
- composite.setBounds(29, 36, 91, 28);
- harnessMake = new Text(composite, SWT.BORDER);
- harnessMake.setBounds(0, 0, 91, 28);
- harnessMake.setText(getMake());
- harnessModel = new Text(shell, SWT.BORDER);
- harnessModel.setBounds(29, 109, 91, 28);
- harnessModel.setText(model);
- lastCheckedBy = new Text(shell, SWT.BORDER);
- lastCheckedBy.setBounds(240, 36, 184, 28);
- lastCheckedBy.setText(check);
- onLoanTo = new Text(shell, SWT.BORDER);
- onLoanTo.setBounds(240, 177, 184, 28);
- onLoanTo.setText(loan);
- Label lblModelNo = new Label(shell, SWT.NONE);
- lblModelNo.setBounds(29, 88, 64, 15);
- lblModelNo.setText("Model No.");
- Label lblMake = new Label(shell, SWT.NONE);
- lblMake.setBounds(29, 15, 55, 15);
- lblMake.setText("Make");
- Label lblLastCheckedBy = new Label(shell, SWT.NONE);
- lblLastCheckedBy.setBounds(240, 15, 184, 15);
- lblLastCheckedBy.setText("Last Checked by:");
- isOnLoan = new Text(shell, SWT.BORDER);
- isOnLoan.setBounds(240, 109, 91, 28);
- Label lblOnLoanTo = new Label(shell, SWT.NONE);
- lblOnLoanTo.setBounds(240, 156, 103, 15);
- lblOnLoanTo.setText("On Loan to:");
- Label lblCurrentlyOnLoan = new Label(shell, SWT.NONE);
- lblCurrentlyOnLoan.setBounds(240, 88, 130, 15);
- lblCurrentlyOnLoan.setText("Currently on Loan:");
- Label lblNoOfTimes = new Label(shell, SWT.NONE);
- lblNoOfTimes.setBounds(29, 177, 130, 15);
- lblNoOfTimes.setText("No. Of Times Loaned");
- timesUsed = new Text(shell, SWT.BORDER);
- timesUsed.setBounds(29, 192, 41, 28);
- Button btnNewButton = new Button(shell, SWT.NONE);
- btnNewButton.setBounds(29, 227, 165, 25);
- btnNewButton.setText("Close Window");
- saveCheck = new Button(shell, SWT.NONE);
- saveCheck.setBounds(360, 70, 64, 15);
- saveCheck.setText("save");
- saveMake = new Button(shell, SWT.NONE);
- saveMake.setText("save");
- saveMake.setBounds(56, 67, 64, 15);
- saveModel = new Button(shell, SWT.NONE);
- saveModel.setText("save");
- saveModel.setBounds(56, 143, 64, 15);
- saveLoan = new Button(shell, SWT.NONE);
- saveLoan.setText("save");
- saveLoan.setBounds(360, 211, 64, 15);
- saveMake.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent a){
- setMake(harnessMake.getText());
- System.out.println(getMake());
- }
- });
- saveModel.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent b){
- model = harnessModel.getText();
- System.out.println(model);
- }
- });
- saveLoan.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent c){
- loan = onLoanTo.getText();
- System.out.println(loan);
- }
- });
- saveCheck.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent d){
- check = lastCheckedBy.getText();
- System.out.println(check);
- }
- });
- btnNewButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e){
- shell.close();
- }
- });
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static String getMake() {
- return make;
- }
- public static void setMake(String make) {
- Harness.make = make;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement