Results 1 to 2 of 2
Thread: its not changing bgcolor
- 02-21-2009, 10:39 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 6
- Rep Power
- 0
its not changing bgcolor
hi new to java, i try making my own applet but it doesn't change color, no error though when compiling...
what is wrong? :confused:import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class ColorChange extends Applet implements ActionListener
{
Button a,b,c;
Color bgcolor;
public void init()
{
Button a = new Button("Blue");
Button b = new Button("Red");
Button c = new Button("Green");
add(a);
add(b);
add(c);
a.addActionListener(this);
b.addActionListener(this);
c.addActionListener(this);
bgcolor=Color.white;
}
public void paint(Graphics g){
setBackground(bgcolor);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==a){
bgcolor=Color.blue;
}else if(e.getSource()==b){
bgcolor=Color.red;
}else if(e.getSource()==c){
bgcolor=Color.green;
}
repaint();
}
}
-
Similar Threads
-
Change bgcolor newbea question
By casid in forum New To JavaReplies: 10Last Post: 12-03-2008, 11:11 PM -
Changing the Jframe
By Nemo1959 in forum New To JavaReplies: 13Last Post: 09-19-2008, 03:58 PM -
Changing Active Window
By jmHoekst in forum New To JavaReplies: 1Last Post: 06-14-2008, 12:21 AM -
Dynamically changing the display
By abhiN in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 01-22-2008, 11:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks