
import java.rmi.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class SClientsr extends JFrame
{
TextField t1=new TextField(20);
Label rs=new Label("0");
JButton b=new JButton("ANS :");
Panel f=new Panel(new GridLayout(2,2));
SInterface i;
public SClientsr()
{
super("Client Side");
setSize(250, 250);
setLocation(300, 300);
getContentPane().add(f,"NORTH");
f.add("Summation limit");
f.add(t1);
f.add(b);
f.add(rs);
f.pack();
}
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int n=Integer.parseInt(t1.getText());
try
{
int m=i.summation(n);
rs.setText(m);
}
catch (Exception epx){}
}
});
}
public class SClient
{
public static void main(String args[])
{
SClientsr sc=new SClientsr();
sc.setDefaultCloseOperation(EXIT_ON_CLOSE);
sc.setVisible(true);
}
}
I am getting the following errors:
C:\tjm>javac SClient.java
SClient.java:29: error: <identifier> expected
b.addActionListener(new ActionListener() {
^
SClient.java:29: error: illegal start of type
b.addActionListener(new ActionListener() {
^
SClient.java:29: error: ')' expected
b.addActionListener(new ActionListener() {
^
SClient.java:29: error: ';' expected
b.addActionListener(new ActionListener() {
^
SClient.java:29: error: illegal start of type
b.addActionListener(new ActionListener() {
^
SClient.java:29: error: <identifier> expected
b.addActionListener(new ActionListener() {
^
SClient.java:29: error: ';' expected
b.addActionListener(new ActionListener() {
^
SClient.java:39: error: class, interface, or enum expected
});
^
SClient.java:40: error: class, interface, or enum expected
}
^
9 errors
PLEASE HELP

import java.rmi.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
class SClientsr extends JFrame
{
JTextField t1=new JTextField(20);
JLabel rs=new JLabel("0");
JButton b=new JButton("ANS :");
JPanel f=new JPanel(new GridLayout(2,2));
SInterface i;
public SClientsr()
{
super("Client Side");
setSize(250, 250);
setLocation(300, 300);
getContentPane().add(f,"NORTH");
f.add(new JLabel("Summation limit"));
f.add(t1);
f.add(b);
f.add(rs);
add(f);
pack();
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int n=Integer.parseInt(t1.getText());
try
{
int m=i.summation(n);
rs.setText(Integer.toString(m));
}
catch (Exception epx){}
}
});
}
}
public class SClient
{
public static void main(String args[])
{
SClientsr sc=new SClientsr();
sc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sc.setVisible(true);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.