Home Answers Viewqa Java-Beginners Swing error in code

 
 


rhea
Swing error in code
1 Answer(s)      a year and 3 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

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 Pages:
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
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
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
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
Swing paint - Swing AWT
the Swing Applet, use html file with the following code: Java Applet Demo...Swing paint  hi, i want to print something on window using swing... on window... while compiling error is coming in super... so pls let me knw whats
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
Swing - Swing AWT
Swing  hi sir i have a code like this: import... initialize the String variable Str therefore you got that error. For more.../java/swing/get_jtextfield_value_from_anothe.shtml Thanks
swing login code
swing login code  code for the 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
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 - 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
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string... inside the method 'accept()'. Here is your modified code: import java.util.
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner.... Try the code below : package roseindia.net; import java.util.Scanner; public
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
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
swing - Java Beginners
swing  i tried many programs in swing to set a background image but everytime it shows somerun time error...plz anyone help me by sending a program for setting background image using swing....  Hi Friend, Try
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
swing chatt program
swing chatt program  how to invoke the code from JTextArea to Socket   package magesh; import java.net.Socket; import...(Exception ex){ System.out.println("Error : "+ex.getMessage
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.
Validation in swing - Java Beginners
Validation in swing  I want to validate my swing program. If I didnt... the fields.  Hi Friend, Try the following code: import java.awt.... the field","Error",JOptionPane.ERROR_MESSAGE); } else
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
Help Required - Swing AWT
. Try again.","Error Message", JOptionPane.ERROR_MESSAGE... the password by searching this example's\n" + "source code.../java/swing/ Thanks. Amardeep
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   
java - Swing AWT
java  hello..sir.....plzzzzzzz help me to display selected image on JPanel.  Hi Friend, Try the following code: import java.awt.... ie) { System.out.println("Error:"+ie.getMessage()); } } public
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
awt swings - Swing AWT
).its urgent sir.it is a part of my project..if code is available......  Hi friend, This code will be captured your image. Please implement this code. import javax.swing.*; import javax.imageio.*; import
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
LINKBUTTON - Swing AWT
, Try the following code: import java.awt.*; import java.net.*; import... these errors........ the error is D:\>javac LinkButton.java
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
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
NotePad - Swing AWT
NotePad  //CODE FOR NOTEPAD /* * To change this template, choose Tools | Templates * and open the template in the editor. */ //Author... (Exception ex) { System.out.println("Error:"+ex.getMessage
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

Ask Questions?

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.