08/07/20 17:02:53
>>570
final JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setSize(300,300);
f.addMouseListener(new MouseAdapter(){
Color color[] = new Color[]{
Color.RED,
Color.GREEN,
Color.BLUE
};
public void mouseClicked(MouseEvent e){
f.getContentPane().setBackground(color[(int)(Math.random()*color.length)]);
}
});
f.setVisible(true);