Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new in java so friends help me. i'm unable to get what i want.

Java
ButtonFrame()
{
  jp=new JPanel();
  btn1=new JButton("Green button");
  btn2=new JButton("Yellow button");
  add(jp);
  setTitle("change background color");
  setSize(400,300);
}
public void actionPerformed(ActionEvent e)
{
  if(e.getSource()==btn1)
   setBackground(new Color(Color.GREEN));
  //same for others
}
Posted
Updated 20-May-14 10:03am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900