can anyone tell me what's the error in this rmi calculator program....... especially the clint.java.........

here when i run the rmi calculator.........i gets an applet calculator.....but for all the mathematical addition,sub,div,mul......i'm getting the null value.......i also doubt at whether the try catch is placed wrongly............

Recommended Answers

All 7 Replies

anybody please help me................

commented: patience, young grasshopper -3

help me,,,
i'm getting a java.lang.NullPointerException

start with calculator view, replace all int to double, in all classes

I don't want to help you with that longer ..., nothing special but view to GUI is correct, not nice or ....

import java.awt.event.*;
import java.awt.*;
import java.math.RoundingMode;
import java.rmi.*;
import java.text.NumberFormat;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
//<applet code=Clint.class width=200 height=200></applet>
public class Clint extends JApplet implements ActionListener {

    private static final long serialVersionUID = 1L;
    private JButton b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ad, sb, ml, dv, eq, clr;
    private int x = 0;
    private double y = 0, z = 0, s = 0, ans;
    private double s1;
    private JFormattedTextField t1;
    private calintf ci;
    private JPanel inputPanel = new JPanel();
    private JPanel buttonPanel = new JPanel();

    @Override
    public void init() {
        inputPanel = new JPanel();
        inputPanel.setPreferredSize(new Dimension(400, 30));
        inputPanel.setLayout(new BorderLayout(5, 5));
        buttonPanel = new JPanel();
        buttonPanel.setPreferredSize(new Dimension(400, 400));
        buttonPanel.setLayout(new GridLayout(4, 4, 5, 5));
        s1 = 0;
        NumberFormat dblFormat = NumberFormat.getNumberInstance();
        dblFormat.setMinimumFractionDigits(0);
        dblFormat.setMaximumFractionDigits(9);
        dblFormat.setRoundingMode(RoundingMode.HALF_UP);

        t1 = new JFormattedTextField(dblFormat);
        t1.setValue(0);
        t1.addFocusListener(new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {
                t1.requestFocus();
                t1.setText(t1.getText());
                t1.selectAll();
            }

            @Override
            public void focusLost(FocusEvent e) {
            }
        });
        inputPanel.add(t1, BorderLayout.CENTER);
        clr = new JButton("Clr");
        clr.addActionListener(this);
        buttonPanel.add(clr);
        b1 = new JButton("1");
        b1.addActionListener(this);
        buttonPanel.add(b1);
        b2 = new JButton("2");
        buttonPanel.add(b2);
        b2.addActionListener(this);
        b3 = new JButton("3");
        buttonPanel.add(b3);
        b3.addActionListener(this);
        b4 = new JButton("4");
        buttonPanel.add(b4);
        b4.addActionListener(this);
        b5 = new JButton("5");
        buttonPanel.add(b5);
        b5.addActionListener(this);
        b6 = new JButton("6");
        buttonPanel.add(b6);
        b6.addActionListener(this);
        b7 = new JButton("7");
        buttonPanel.add(b7);
        b7.addActionListener(this);
        b8 = new JButton("8");
        buttonPanel.add(b8);
        b8.addActionListener(this);
        b9 = new JButton("9");
        buttonPanel.add(b9);
        b9.addActionListener(this);
        b0 = new JButton("0");
        buttonPanel.add(b0);
        b0.addActionListener(this);
        sb = new JButton("-");
        buttonPanel.add(sb);
        sb.addActionListener(this);
        ad = new JButton("+");
        buttonPanel.add(ad);
        ad.addActionListener(this);
        ml = new JButton("*");
        buttonPanel.add(ml);
        ml.addActionListener(this);
        dv = new JButton("/");
        buttonPanel.add(dv);
        dv.addActionListener(this);
        eq = new JButton("=");
        buttonPanel.add(eq);
        eq.addActionListener(this);
        setLayout(new BorderLayout(5, 5));
        setPreferredSize(new Dimension(600, 600));
        setLayout(new BorderLayout(5, 5));
        add(inputPanel, BorderLayout.NORTH);
        add(buttonPanel, BorderLayout.CENTER);
        setVisible(true);
    }

and debug that with System.out.println(tested value)

y = (((Number) t1.getValue()).doubleValue());

hey i want the attached rmi program to be corrected.............the above code is not in rmi format

are you done with:

1/ start with calculator view
2/ replace all int to double, in all classes
3/ get number value from JForrmatedTextField

I think that you're shot to the dark, haven't you, because a.m. changes could *** (upTo) half hour

now I'm outta from this thread,

We're not a code review service...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.