import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class AlberoNatale{
private JFrame albero;
private PannelloAlbero a;
private JButton accende;
private JButton spegne;
public AlberoNatale(){
albero=new JFrame("Albero del santo Natale 2008");
albero.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
albero.setSize(500,500);
a=new PannelloAlbero();
accende=new JButton("accendi lampadine");
spegne=new JButton("spegne le lampadine");
albero.add(a,BorderLayout.CENTER);
albero.add(accende,BorderLayout.SOUTH);
albero.setVisible(true);
}
public class PannelloAlbero extends JPanel{
public void paintComponent(Graphics g){
Graphics g2d=(Graphics2D) g;
Image alberoImmagine=new ImageIcon("albNat.jpg").getImage();
g.drawImage(alberoImmagine,0,0,albero.getWidth(),albero.getHeight(),null);
}
}
public static void main(String[] args){
AlberoNatale albero=new AlberoNatale();
}
}
_____________________________________________________________________________________

