Home » » Background Colour Changer in Java Program

Background Colour Changer in Java Program

Background Colour Changer in Java Program

Background Colour Changer in Java Program

Background Colour Changer in Java Program

import java.awt*;
import java.awt.event.*;
import javax.Swing.*;
public class MainClass extends JPanel implements ActionListener
{
TextField text=new TextField(20);
private int numClicks=0;
public Static void main(String args[])
{
JFrame frame=new JFrame();
frame.getContentPane().add(new MainClass());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Button Test");
frame.setSize(200,200);
frame.setVisible(true);
}
public MainClass()
{
JButton btn1=new JButton("Button1");
btn1.addActionListener(this);
add(btn);
}
public void actionPerformed(ActionEvent e)
{
setBackground(color.red);
}
}


0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g