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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| public class mainFram2 extends JFrame
{
public mainFram2()
{
setSize(300, 400);
_contentPane = getContentPane();
// Timer pour retarder l'affichage
javax.swing.Timer timer = new javax.swing.Timer(500, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
createMenu();
}
});
timer.start();
timer.setRepeats(false);
// Fermeture par la croix
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
try
{
fermeture();
}
catch(Throwable err)
{
System.out.println("[Err] mainFram2::windowClosing(), " + err);
}
}
});
}
private void createMenu()
{
_image = createImage(80, 400);
_graphicV = _image.getGraphics();
_graphicV.setColor(new Color(227, 228, 197));
_graphicV.fillRect(0, 0, 80, 400);
_graphicV.setColor(new Color(225, 151, 86));
// Rond en haut
_graphicV.fillRoundRect (30, 20, 20, 20, 20, 20);
_contentPane.getGraphics().drawImage(_image, 0, 0, this);
}
private void fermeture()
{
System.exit(0);
}
public void paintComponent(Graphics g)
{
validate();
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
super.paint(g);
validate();
SwingUtilities.updateComponentTreeUI(_contentPane);
}
private Container _contentPane;
private Image _image = null;
private Graphics _graphicV = null;
} |
Partager