Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: what's problem with this code?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what's problem with this code?

    package javaapplication76;

    import java.awt.*;
    import java.applet.*;
    import javax.swing.*;
    /**
    *
    * @author Ashik
    */
    public class ApplerTesting extends Applet{

    TextField textfield1,textfield2;

    public void inti(){

    textfield1=new TextField();
    textfield2=new TextField();
    add(textfield1);
    add(textfield2);
    textfield1.setText("0");
    textfield2.setText("0");

    }

    public void paint(Graphics graphics){

    int textfield1Numer, textfield2Numer,Answer;
    String textfield1String,textfield2String,AnswerString;
    graphics.drawString("please enter two number in the txtfield", 100, 200);

    try{
    textfield1String=textfield1.getText();
    textfield1Numer=Integer.valueOf(textfield1String);
    textfield2String=textfield2.getText();
    textfield2Numer=Integer.valueOf(textfield2String);
    Answer=textfield1Numer+textfield2Numer;
    AnswerString=String.valueOf(Answer);
    graphics.drawString("The summation is"+AnswerString, 100, 500);

    }
    catch(ArithmeticException arithmeticException){

    JOptionPane.showMessageDialog(null,arithmeticExcep tion);

    }

    }



    public Boolean action (Event event, Object object)
    {
    repaint();
    return true;

    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: what's problem with this code?

    You tell us. What does your code do? Does it throw an Exception? If so, post it here. Does it exhibit a weird behavior? If so, explain it in detail. Does it gain sentience and start plotting to overthrow humanity? If so, unplug your computer.

    Also, please use the highlight tags to preserve formatting when posting code. Unformatted code makes our eyes bleed.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. PROBLEM WITH MY CODE!!!!
    By vaughn00AoG in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 26th, 2012, 10:28 AM
  2. problem in my code java code graph editeur
    By kisokiso in forum Java Theory & Questions
    Replies: 5
    Last Post: January 6th, 2012, 08:36 AM
  3. I have a problem with my code I think
    By byrne in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 12th, 2011, 04:18 AM
  4. Problem with code
    By lichad3 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 22nd, 2011, 06:40 PM
  5. problem in my code
    By wannabe in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 24th, 2010, 07:53 AM