Results 1 to 2 of 2
  1. #1
    Sayuri is offline Member
    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Default What's wrong with my code ? Help me please T_T

    Design an applet based on the form which will display the proper color, font and text based on the checked items after clicking the OK button. Note: Combination of Red & Yellow is Orange. The text must not be editable. If you run my program using applet , the output is wrong . HELP ME PLS .

    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;

    public class Mixing extends Applet implements ItemListener, ActionListener
    {
    Label l1 = new Label("Mixing Your Color and Fonts",Label.CENTER);
    Checkbox red = new Checkbox("Red");
    Checkbox yel = new Checkbox("Yellow");
    Checkbox bold = new Checkbox("Bold");
    Checkbox ita = new Checkbox("Italic");
    TextField tf = new TextField(" ",20);
    Button ok = new Button("OK");
    Font f = new Font("Seriff",Font.PLAIN,16);
    int b=0 ; int i=0;
    int r=1 ; int y=0;




    public void init()
    {
    add(l1); add(red); add(yel);
    add(bold); add(ita);

    red.addItemListener(this);
    yel.addItemListener(this);
    bold.addItemListener(this);
    ita.addItemListener(this);
    add(tf);
    ok.addActionListener(this);
    add(ok);
    }

    public void actionPerformed(ActionEvent x)
    {
    if(x.getSource()==ok)
    {
    tf.setFont(f);
    bold.setState(false);
    ita.setState(false);
    red.setState(false);
    yel.setState(false);

    f = new Font("Seriff",b+i,16);


    }

    }
    public void itemStateChanged(ItemEvent e)
    {


    if(bold.getState())
    b = Font.BOLD;
    if(ita.getState())
    i = Font.ITALIC;
    if(red.getState())
    { tf.setForeground(Color.red);}

    if(yel.getState())
    { tf.setForeground(Color.yellow);}



    }

    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: What's wrong with my code ? Help me please T_T

    Quote Originally Posted by Sayuri View Post
    What's wrong with my code ? Help me please T_T
    Please go through the Forum Rules, particularly the third paragraph. Then go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    To change the subject line, click 'Edit Post' then 'Go Advanced'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Help please, what's wrong with my code?
    By jamgor in forum New To Java
    Replies: 9
    Last Post: 06-12-2013, 03:35 AM
  2. what is wrong with my code :(
    By lexyloraine in forum New To Java
    Replies: 2
    Last Post: 03-23-2011, 04:37 AM
  3. What is wrong with my code????
    By maneatingbaby in forum New To Java
    Replies: 2
    Last Post: 12-31-2010, 06:06 PM
  4. What is wrong with my code?
    By loosemember in forum New To Java
    Replies: 1
    Last Post: 12-03-2010, 01:20 AM
  5. What is wrong with my code?!
    By new2java2009 in forum New To Java
    Replies: 2
    Last Post: 04-17-2010, 08:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •