Results 1 to 2 of 2
- 08-20-2013, 07:18 PM #1
Member
- Join Date
- Aug 2013
- Posts
- 1
- Rep Power
- 0
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);}
}
}
- 08-20-2013, 07:26 PM #2
Re: 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 http://www.java-forums.org/forum-gui...w-members.html 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'
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
Similar Threads
-
Help please, what's wrong with my code?
By jamgor in forum New To JavaReplies: 9Last Post: 06-12-2013, 04:35 AM -
what is wrong with my code :(
By lexyloraine in forum New To JavaReplies: 2Last Post: 03-23-2011, 05:37 AM -
What is wrong with my code????
By maneatingbaby in forum New To JavaReplies: 2Last Post: 12-31-2010, 07:06 PM -
What is wrong with my code?
By loosemember in forum New To JavaReplies: 1Last Post: 12-03-2010, 02:20 AM -
What is wrong with my code?!
By new2java2009 in forum New To JavaReplies: 2Last Post: 04-17-2010, 09:01 PM
Bookmarks