Bonjour,

J'ai vu pas mal de choses sur mon problème, venant généralement de l'utilisation d'AWT avec du SWING dans une même frame.
Là je pense utiliser que du SWING et mon jLabel reste malgré tout derrière mon cercle alors j'en appelle à votre aide
Je veux donc que mon jLabel1 se superpose sur mon horloge pour que je puisse afficher les heures tout autour.
Voici le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package tp2;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
import java.awt.Font;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.JLabel;
import javax.swing.*;
import javax.swing.border.TitledBorder;
 
 
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Frame1 extends JFrame {
    JPanel contentPane;
    JPanel jPanel1 = new JPanel();
     Heure heureCourante = new Heure (120);
    XYLayout xYLayout1 = new XYLayout();
    JTextField jTextField1 = new JTextField(heureCourante.toString());
    public Frame1() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
 
    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        int haut =jPanel1.getHeight(); ;
        int large =jPanel1.getWidth(); ;
 
        contentPane = (JPanel) getContentPane();
        setSize(new Dimension(402, 311));
        setTitle("Frame Title");
        jPanel1.setLayout(xYLayout1);
        jTextField1.addActionListener(new Frame1_jTextField1_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
        jLabel1.setForeground(Color.darkGray);
        jLabel1.setBorder(null);
        jLabel1.setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
        jLabel1.setDoubleBuffered(true);
        jLabel1.setDisplayedMnemonic('0');
        jLabel1.setLabelFor(null);
        jLabel1.setLabelFor(contentPane);
        jLabel1.setText("12");
        contentPane.setBackground(SystemColor.control);
        contentPane.setToolTipText("");
        contentPane.setLayout(borderLayout1);
        jPanel1.setActionMap(null);
        contentPane.add(jPanel2, java.awt.BorderLayout.CENTER);
        jPanel2.add(jLabel1);
        contentPane.add(jPanel1, java.awt.BorderLayout.NORTH);
        jPanel1.add(jTextField1, new XYConstraints(18, 0, -1, -1));
        timer.start(); // pour démarrer le décompte du temps
 
    }
 
    private void affichehorloge() {
        Graphics g = jPanel1.getGraphics();
        Graphics h = jPanel1.getGraphics();
        Graphics k = jPanel1.getGraphics();
        h.setColor(Color.black);
        g.setColor(Color.white);
        k.setColor(Color.darkGray);
        int haut = jPanel1.getHeight();
        int large = jPanel1.getWidth();
        int taille = Math.min(large,haut);
        jLabel1.setLocation(large/2,-40);
        h.drawOval((large/2)-(taille/2)-1,(haut/2)-(taille/2)+3,(taille+1),(taille-5));
        g.fillOval((large/2)-(taille/2),(haut/2)-(taille/2)+4,taille,taille-6) ;
        k.fillOval((large/2)-(12/2),(haut/2)-(12/2),12,12);
 
    }
 
    ActionListener action = new ActionListener() {
public void actionPerformed(ActionEvent event) {
    heureCourante.augmente(1);
    jTextField1.setText(heureCourante.toString());
 
    //c'est la pour affichehorloge()
    affichehorloge();
}
};
 
    Timer timer = new Timer(1000, action);// 1000 millisecondes
    JLabel jLabel1 = new JLabel();
    PaneLayout paneLayout1 = new PaneLayout();
    BorderLayout borderLayout1 = new BorderLayout();
    TitledBorder titledBorder1 = new TitledBorder("");
    JPanel jPanel2 = new JPanel();
}
 
 
class Frame1_jTextField1_actionAdapter implements ActionListener {
    private Frame1 adaptee;
    Frame1_jTextField1_actionAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
    }
 
    public void actionPerformed(ActionEvent e) {
    }
 
 
}