Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Swing error in code
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


rhea
Swing error in code
1 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


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


Advertisement
View Answers

February 13, 2012 at 10:44 AM


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);
        }
    }


Related Tutorials/Questions & Answers:
Swing error in code
Swing error in code  import java.rmi.*; import java.awt.*; import... the following errors: C:\tjm>javac SClient.java SClient.java:29: error: <...() { ^ SClient.java:29: error: illegal start of type b.addActionListener(new
swing login code
swing login code  code for the login form
Advertisements
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form
Code error
Code error  package trail; import...) read.close(); } } } While using this it shows error as: run... seconds) Hw can i correct this code????????   Basically, the Exception
Java swing code
Java swing code  can any one send me the java swing code for the following: "A confirmation message after the successful registration of login form...(null,"Error!"); text1.setText(""); text2.setText
code - Swing AWT
code  i want example problem for menubar in swings  Hi Friend, Please visit the following links: http://www.roseindia.net/java/example/java/swing/SwingMenu.shtml http://www.roseindia.net/java/example/java/swing
Java Swing code for zoom in and out
Java Swing code for zoom in and out  hi.......... I require a code in java swing for image zoom in and zoom out can u tell me how it can be done or what is the code plz help
provide code - Swing AWT
provide code  Dear frnds please provide code for two player CHESS GAME.....using swings,awt concepts   Hi friend, import java.awt..../java/swing/ Thanks
java compilation error - Swing AWT
java compilation error   NestedPopupMenu n = new NestedPopupMenu(); getting error as "local variable n is never read  Hi dharani, This is running code. I hope that this code will help you. import java.util.
Java Compiler error - Swing AWT
Java Compiler error  Hi, I try to add quartz Lib in my HelloQuartz application. When I run HelloSchedule, I get this error: "Exception in thread...; Hello The above code is ok; But You have to add quartz.jar
source code - Swing AWT
source code  source code for a program to shutdown, restart, log off the pc after clicking jbutton on jpanel or a jframe by user. thanks in advance
java code - Swing AWT
to open the lock  Hi Friend, Try the following code: class
java code - Swing AWT
java code  Hello .anyone can plz tell me code for this .First create a button wen it is clicked its enters into another window asking for Name .After...   Hi Friend, Try the following code: import java.io.*; import
java code - Swing AWT
java code  i want to open a new dialog box after clicking "upload" button, it should have a text field, browse button to browse the file from directory  Hi Friend, Try the following code: 1)OpenDialog.java import
Java Code - Swing AWT
Java Code  How to Display a Save Dialog Box using JFileChooser and Save the loaded Image from Panel in any Location.  Hi Friend, Try the following code: import java.io.*; import java.awt.*; import java.util.
Java logical error - Swing AWT
uploaded my code at: http://www.mediafire.com/file/41d7a852eupfi9t/LoginPage.zip Thank you.  Hi Friend, Try the following code: import
Upload Code error on deploying
Upload Code error on deploying  on deploying the above code as it is said it is giving error that " No getter method for property thefile of bean org.apache.struts.taglib.html.BEAN " Error 500--Internal Server Error
error in code - JDBC
error in code  hi friends i had one problem when i am running the application of jdbc code it is getting that Exception in thread "main" java.lang.NoSuchMethodError: main plz send me the solution for that error   
put image on form creating in swing-swing code - Swing AWT
put image on form creating in swing-swing code  i want to display image on swing panel and get the image co ordinate by mouse clicking.and also zoom the image at particular area of image. please give solution on my email id
Error in Code - Development process
Error in Code  Hi; This is my code to get all d records from View_Service table but am getting error. I just copied this from net.I am doing mini project plz send me code to get records. What action should i mention
code error - JSP-Servlet
code error  hii this program is not working becoz when the mouse... is error in this progrm. ss function describe() { window.status... complaint   Hi friend, Do some changes in your code to solve
Error in a code. - Java Beginners
Error in a code.  This is the question I posted yesterday: "I'm.... I'm confused about where and what i should put into the overall code. Also I can't quite figure out how to write the code for the GUI. Could anyone please help
Java swing code - Java Beginners
Java swing code  How to set a font for a particular cell in JTable... in Swing. We have a huge amount of good examples on JTable here. http://www.roseindia.net/java/example/java/swing I hope this would be helpful to you
Code Error - WebSevices
Code Error  How to insert checkbox values to mysql using php  Hi friend, Code to help in solving the problem : Insert CheckBox Thanks
Java swing code - Java Beginners
Java swing code  How to validate input data entered into the swing applications in java?   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.
Snippet Code Error
Snippet Code Error  The following is a snippet of code from a Java application which uses Connector/J to query a MySQL database. Identify possible problems and possible solutions. Connection cn= DriverManager.getConnection
 

 

 

DMCA.com