Advertisement
Guest User

Harness

a guest
Mar 3rd, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.52 KB | None | 0 0
  1. import org.eclipse.swt.events.SelectionAdapter;
  2. import org.eclipse.swt.events.SelectionEvent;
  3. import org.eclipse.swt.widgets.Display;
  4. import org.eclipse.swt.widgets.Shell;
  5. import org.eclipse.swt.widgets.Composite;
  6. import org.eclipse.swt.SWT;
  7. import org.eclipse.swt.widgets.Text;
  8. import org.eclipse.swt.widgets.Spinner;
  9. import org.eclipse.swt.widgets.Label;
  10. import org.eclipse.swt.widgets.Button;
  11.  
  12.  
  13. public class Harness {
  14.  
  15.     protected static Shell shell;
  16.     public static Text harnessModel, harnessMake, lastCheckedBy, onLoanTo, isOnLoan, timesUsed;
  17.     public static Button saveCheck, saveMake, saveModel, saveLoan;
  18.     private static String make = "";
  19.     public static String check = "";
  20.     public static String loan = "";
  21.     public static String model = "";
  22.    
  23.     /**
  24.      * Launch the application.
  25.      * @param args
  26.      */
  27.     public static void main(String[] args) {
  28.         try {
  29.             Display display = Display.getDefault();
  30.             shell = new Shell();
  31.             shell.setSize(450, 300);
  32.             shell.setText("Harness Record System");
  33.             shell.open();
  34.             shell.layout();
  35.            
  36.             Composite composite = new Composite(shell, SWT.NONE);
  37.             composite.setBounds(29, 36, 91, 28);
  38.            
  39.             harnessMake = new Text(composite, SWT.BORDER);
  40.             harnessMake.setBounds(0, 0, 91, 28);
  41.             harnessMake.setText(getMake());
  42.            
  43.             harnessModel = new Text(shell, SWT.BORDER);
  44.             harnessModel.setBounds(29, 109, 91, 28);
  45.             harnessModel.setText(model);
  46.            
  47.             lastCheckedBy = new Text(shell, SWT.BORDER);
  48.             lastCheckedBy.setBounds(240, 36, 184, 28);
  49.             lastCheckedBy.setText(check);
  50.            
  51.             onLoanTo = new Text(shell, SWT.BORDER);
  52.             onLoanTo.setBounds(240, 177, 184, 28);
  53.             onLoanTo.setText(loan);
  54.            
  55.             Label lblModelNo = new Label(shell, SWT.NONE);
  56.             lblModelNo.setBounds(29, 88, 64, 15);
  57.             lblModelNo.setText("Model No.");
  58.            
  59.             Label lblMake = new Label(shell, SWT.NONE);
  60.             lblMake.setBounds(29, 15, 55, 15);
  61.             lblMake.setText("Make");
  62.            
  63.             Label lblLastCheckedBy = new Label(shell, SWT.NONE);
  64.             lblLastCheckedBy.setBounds(240, 15, 184, 15);
  65.             lblLastCheckedBy.setText("Last Checked by:");
  66.            
  67.             isOnLoan = new Text(shell, SWT.BORDER);
  68.             isOnLoan.setBounds(240, 109, 91, 28);
  69.            
  70.             Label lblOnLoanTo = new Label(shell, SWT.NONE);
  71.             lblOnLoanTo.setBounds(240, 156, 103, 15);
  72.             lblOnLoanTo.setText("On Loan to:");
  73.            
  74.             Label lblCurrentlyOnLoan = new Label(shell, SWT.NONE);
  75.             lblCurrentlyOnLoan.setBounds(240, 88, 130, 15);
  76.             lblCurrentlyOnLoan.setText("Currently on Loan:");
  77.            
  78.             Label lblNoOfTimes = new Label(shell, SWT.NONE);
  79.             lblNoOfTimes.setBounds(29, 177, 130, 15);
  80.             lblNoOfTimes.setText("No. Of Times Loaned");
  81.            
  82.             timesUsed = new Text(shell, SWT.BORDER);
  83.             timesUsed.setBounds(29, 192, 41, 28);
  84.            
  85.             Button btnNewButton = new Button(shell, SWT.NONE);
  86.             btnNewButton.setBounds(29, 227, 165, 25);
  87.             btnNewButton.setText("Close Window");
  88.            
  89.             saveCheck = new Button(shell, SWT.NONE);
  90.             saveCheck.setBounds(360, 70, 64, 15);
  91.             saveCheck.setText("save");
  92.                        
  93.             saveMake = new Button(shell, SWT.NONE);
  94.             saveMake.setText("save");
  95.             saveMake.setBounds(56, 67, 64, 15);
  96.            
  97.             saveModel = new Button(shell, SWT.NONE);
  98.             saveModel.setText("save");
  99.             saveModel.setBounds(56, 143, 64, 15);
  100.            
  101.             saveLoan = new Button(shell, SWT.NONE);
  102.             saveLoan.setText("save");
  103.             saveLoan.setBounds(360, 211, 64, 15);
  104.            
  105.             saveMake.addSelectionListener(new SelectionAdapter() {
  106.                 public void  widgetSelected(SelectionEvent a){
  107.                     setMake(harnessMake.getText());
  108.                     System.out.println(getMake());
  109.                 }
  110.             });
  111.             saveModel.addSelectionListener(new SelectionAdapter() {
  112.                 public void  widgetSelected(SelectionEvent b){
  113.                     model = harnessModel.getText();
  114.                     System.out.println(model);
  115.                 }
  116.             });
  117.             saveLoan.addSelectionListener(new SelectionAdapter() {
  118.                 public void  widgetSelected(SelectionEvent c){
  119.                     loan = onLoanTo.getText();
  120.                     System.out.println(loan);
  121.                 }
  122.             });
  123.             saveCheck.addSelectionListener(new SelectionAdapter() {
  124.                 public void  widgetSelected(SelectionEvent d){
  125.                     check = lastCheckedBy.getText();
  126.                     System.out.println(check);
  127.                 }
  128.             });
  129.             btnNewButton.addSelectionListener(new SelectionAdapter() {
  130.                 public void  widgetSelected(SelectionEvent e){
  131.                     shell.close();
  132.                 }
  133.             });
  134.             while (!shell.isDisposed()) {
  135.                 if (!display.readAndDispatch()) {
  136.                     display.sleep();
  137.                 }
  138.             }
  139.         } catch (Exception e) {
  140.             e.printStackTrace();
  141.         }
  142.     }
  143.  
  144.     public static String getMake() {
  145.         return make;
  146.     }
  147.  
  148.     public static void setMake(String make) {
  149.         Harness.make = make;
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement