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 }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)