1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| package guide_touristique;
import java.*;
import java.awt.Image;
import java.awt.MediaTracker;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
public class guide_touristique extends JFrame
{
public guide_touristique()
{
super();
build(); //On initialise notre fenêtre
}
private void build()
{
setTitle("Votre guide touristique"); //On donne un titre à l'application
setSize(600, 600); //On donne une taille à notre fenêtre
setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
setResizable(false); //On interdit la redimensionnement de la fenêtre
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //On dit à l'application de se fermer lors du clic sur la croix
}
public class TestJFrame extends JFrame
{
private Image fond;
public TestJFrame()
{super();
fond = java.awt.Toolkit.getDefaultToolkit().getImage("./tourisme-tunisie.jpg");
try {
MediaTracker mt = new MediaTracker(this);
mt.addImage(fond, 0);
mt.waitForAll();
}
catch (Exception e)
{e.printStackTrace();}
/*etContentPane(new ContentPane(fond));*/
getContentPane().add(new JLabel("Bonjour"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 400);
setLocationRelativeTo(null);
setVisible(true);
}
}
} |
Partager