# data[].attributes.attachment_link.readable_text
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class Calc {

	protected Shell shell;
	private Text Nombor_1;
	private Text Nombor_2;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Calc window = new Calc();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("Kalkulator Ringkas");
		
		Nombor_1 = new Text(shell, SWT.BORDER);
		Nombor_1.setBounds(10, 44, 147, 21);
		
		Nombor_2 = new Text(shell, SWT.BORDER);
		Nombor_2.setBounds(10, 99, 147, 21);
		
		Label lblNo1 = new Label(shell, SWT.NONE);
		lblNo1.setBounds(10, 22, 55, 15);
		lblNo1.setText("Nombor 1");
		
		Label lblNo2 = new Label(shell, SWT.NONE);
		lblNo2.setBounds(10, 78, 55, 15);
		lblNo2.setText("Nombor 2");
		
		final Label lblJawapan = new Label(shell, SWT.NONE);
		lblJawapan.setFont(SWTResourceManager.getFont("Script", 24, SWT.BOLD));
		lblJawapan.setBounds(10, 211, 252, 40);
		lblJawapan.setText("Jawapannya ialah : ");
		
		Button butangTambah = new Button(shell, SWT.NONE);
		butangTambah.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				int number1, number2;
				try{
					number1 = Integer.parseInt(Nombor_1.getText());
				}
				catch (Exception exc)
				{
					MessageDialog.openError(shell, "Error", "bad first number");
					return;
				}
				
				try{
					number2 = Integer.parseInt(Nombor_2.getText());
				}
				catch (Exception exc)
				{
					MessageDialog.openError(shell, "Error", "bad second number");
					return;
				}
				int answer = number1 + number2;
				lblJawapan.setText("Jawapannya ialah :" + answer);
			}
		});
		butangTambah.setToolTipText("Tambah");
		butangTambah.setBounds(10, 154, 75, 25);
		butangTambah.setText("+");
		
		Button butangTolak = new Button(shell, SWT.NONE);
		butangTolak.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				int number1, number2;
				try{
					number1 = Integer.parseInt(Nombor_1.getText());
				}
				catch (Exception exc)
				{
					MessageDialog.openError(shell, "Error", "bad first number");
					return;
				}
				
				try{
					number2 = Integer.parseInt(Nombor_2.getText());
				}
				catch (Exception exc)
				{
					MessageDialog.openError(shell, "Error", "bad second number");
					return;
				}
				int answer = number1 - number2;
				lblJawapan.setText("Jawapannya ialah :" + answer);
			}
		});
		butangTolak.setToolTipText("Tolak");
		butangTolak.setBounds(105, 154, 75, 25);
		butangTolak.setText("-");
		

	}
}

# data[].attributes.body
Klik link ini untuk download kertas kerja