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



Home Answers Viewqa Java-Beginners Swing error in code

Have Programming Question? Ask it here!
 
 
 


rhea
Swing error in code
1 Answer(s)      2 years and 7 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
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 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
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
Need source code - Swing AWT
Need source code  Hai, In java swing, How can upload and retrieve the images from the mysql database?   Hi Friend, To upload and insert image in database, try the following code: import java.sql.*; import
Causing Deadlocks in Swing Code
Causing Deadlocks in Swing At First Consider the Deadlocks A deadlock... that resources. It is a common problem in multithreading. Consider the Sample code... and by adding  the new DesktopPain to the Content Pain it starts the Swing Thread
Java Code Color Function Error
Java Code Color Function Error  Java Code Color Function Error
Need source code - Swing AWT
Need source code  Hai, I need a source code for developing the project, title is "Face Recognition" and the backend as My-sql.... Thanks & Regards
game programming code - Swing AWT
game programming code  write a snake program using swings with step by step explanation?. please send me this source code to my mail id with step by step explanation
Need source code - Swing AWT
Need source code  Hai, I need a idea and code for developing the project "Face Recognition" with the backend as My-sql.... Thanks & Regards
AWT code for popUpmenu - Swing AWT
AWT code for popUpmenu  Respected Sir/Madam, I am writing a program in JAVA/AWT.My requirement is, a Form consists of a "TextBox" and a "Button... the code. ThanQ.   import java.awt.BorderLayout; import
Need source code - Swing AWT
Need source code  Hai friends, How can I, view all the datas from the mysql database table in the jframe........  Hi Friend, Try the following code: import java.awt.*; import java.sql.*; import
Error in laodin and saving the image . - Swing AWT
Error in laodin and saving the image .  I am a student who had to submit their projects......so i am working on the Photo Editor Project. But i am facing problem while laoding and saving the image with help of JFileChooser class
Compilation error. Hibernate code - Hibernate
Compilation error. Hibernate code   Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory...) how to rectify that error in hibernate  Hi Friend, You have
Java error code
Java error code       Java Error code are the set of error that occurs during the compile-time and Run-time. From java error we have given  you a sample of code
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
jsp code error - Java Beginners
jsp code error  Hi, I have a problem with following code... part. Is it possible to display a message box or alert box in jsp code??. plz help...; Hi friend , Try this code: /*out.println("Login Failed
error in java code - Java Beginners
error in java code  Hi Can u say how to communication between systems in a network.   Hi friend, A method for controlling an operation of a server system by a client system interconnected with the server
jsp code error - JSP-Servlet
jsp code error  I have a jsp page named "tMastDepartment".which has some table row containing text box like 'project code','Departmentcode','employee... there is the problem which i am facing.what will be the exact code
jsp code error - JSP-Servlet
jsp code error  hello, is anyone here who can solve my problem. what happen experts where r u? r u not able to do
jsp code error - JSP-Servlet
jsp code error  hello, is anyone here who can solve my problem. what happen experts where r u? or u r not able to do
Java code error - Java Beginners
Java code error  Hi, I am using a MooreQuery to look for neighbors in a grid: MooreQuery query = new MooreQuery(grid, this,(int) (2*myHomeRangeRadius), (int) (2*myHomeRangeRadius)); if(query != null){ for (Object
exception handling code for file not found error..
exception handling code for file not found error..  How to do exception handling for file not found error
Advertisements
 

 

 

DMCA.com