private void createUI()

in examples-trunk/applet/src/main/java/org/superbiz/applet/CalculatorApplet.java [55:100]


    private void createUI() {
        field1 = new JTextField();
        field2 = new JTextField();
        label1 = new JLabel("Enter first number");
        label2 = new JLabel("Enter second number");
        label3 = new JLabel("RESULT=");
        button = new JButton("Add");

        setLayout(new GridLayout(3, 2));
        add(label1);
        add(field1);
        add(label2);
        add(field2);
        add(button);
        add(label3);
        Properties props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY,
                  "org.apache.openejb.client.RemoteInitialContextFactory");
        props.put(Context.PROVIDER_URL, "http://127.0.0.1:8080/applet/ejb");
        try {
            ctx = new InitialContext(props);
        } catch (NamingException e) {
            throw new RuntimeException(e);
        }
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                try {
                    final Object ref = ctx.lookup("CalculatorImplRemote");
                    Calculator calc = (Calculator) PortableRemoteObject.narrow(
                                                                                  ref, Calculator.class);
                    String text1 = field1.getText();
                    String text2 = field2.getText();
                    int num1 = Integer.parseInt(text1);
                    int num2 = Integer.parseInt(text2);
                    double result = calc.add(num1, num2);
                    label3.setText("RESULT=" + result);
                } catch (NamingException ex) {
                    throw new RuntimeException(ex);
                }

            }
        });

    }