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 4 of 4

Thread: what wrong with this??

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    7
    My Mood
    Relaxed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy what wrong with this??

    import java.applet.Applet.*;
    import java.awt.*;
    import java.awt.event.*;
     
    public class assign extends Applet implements ActionListener{
    	TextField txt1;
     
    Buttons cmd1,cmd2,cmd3,cmd4,cmd5,cmd6,cmd7;
    public void init(){
    	txt1= new TextField(20);
    	add(txt1);
    	cmd1= new Button();
    	add(cmd1);
    	cmd1.addActionListener(this);
    	cmd1.setBackground(Color.blue);
    	cmd2= new Button();
    	add(cmd2);
    	cmd2.addActionListener(this);
    	cmd2.setBackground(Color.green);
    	cmd3= new Button();
    	add(cmd3);
    	cmd3.addActionListener(this);
    	cmd3.setBackground(Color.cyan);
    	cmd4= new Button();
    	add(cmd4);
    	cmd4.addActionListener(this);
    	cmd4.setBackground(Color.pink);
    	cmd5= new Button();
    	add(cmd5);
    	cmd5.addActionListener(this);
    	cmd5.setBackground(Color.black);
    	cmd6= new Button();
    	add(cmd6);
    	cmd6.addActionListener(this);
    	cmd6.setBackground(Color.Brown);
    	cmd7= new Button();
    	add(cmd7);
    	cmd7.addActionListener(this);
    }
    	public void actionPerformed (ActionEvent objEvent)
    	{
    	 if (objEvent.getSource () == cmd1)
    		txt1.setText ("BLUE");
    	 if (objEvent.getSource () == cmd2)
    		txt1.setText ("GREEN");
    	 if (objEvent.getSource () == cmd3)
    		txt1.setText ("PINK");
    	 if (objEvent.getSource () == cmd4)
    		txt1.setText ("CYAN");
    	 if (objEvent.getSource () == cmd5)
    		txt1.setText ("BLACK");
    	 if (objEvent.getSource () == cmd6)
    		txt1.setText ("BROWN");
    	 if (objEvent.getSource () == cmd7)
    		txt1.setText (" ");
    }
    }

    can u please help me. .i hav 4 errors in that code.
    Last edited by helloworld922; January 14th, 2012 at 09:02 PM.


  2. #2
    Member
    Join Date
    Dec 2011
    Location
    United States
    Posts
    94
    My Mood
    Amused
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default Re: what wrong with this??

    It will be easier to get help if your code was highlighted with tags. So, next time, use [highlight = java] code here [/java] to highlight your code and you will easily locate help.

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Location
    Nigeria
    Posts
    12
    My Mood
    Cheerful
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: what wrong with this??

    sephskie, you can still edit your code and add the highlighting tags...makes it easier for forum users to help you.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: what wrong with this??

    .i hav 4 errors in that code.
    It also helps if you copy and paste here the full text of the error messages. You'll get answers faster the more information you provide.

Similar Threads

  1. Idk what is wrong
    By Devourz in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 28th, 2011, 05:05 AM
  2. [SOLVED] Help me to fix the bug?
    By arvindbis in forum JDBC & Databases
    Replies: 4
    Last Post: October 14th, 2011, 04:13 AM
  3. [SOLVED] I don't know what's wrong
    By Shivam24 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 25th, 2011, 08:54 AM
  4. WHAT IS WRONG HERE PLEASE?
    By mjava in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 27th, 2010, 08:29 PM
  5. Something is wrong? Please help.
    By DestinyChick1225 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 29th, 2010, 07:47 AM