Bonjour,

Je souhaiterais modifier l'apparence de mon JTextField en passant par un setBorder.

Mon Border :
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
public class RectangleBordsArrondi implements Border {          
	private int radius;   
	//private Color couleurInterieur = Color.BLACK;
	private Color couleurBord = InitGene.RENSEIGNEB;
 
	public RectangleBordsArrondi(int radius) 
	{	
		this.radius = radius;
	}    
 
	public RectangleBordsArrondi() 
	{	
		this.radius = 15;         
	}  
 
	public RectangleBordsArrondi(Color c) 
	{	
		this.radius = 15;
		couleurBord=c;
	}  
 
	public RectangleBordsArrondi(Color c, int radius) 
	{	
		this.radius = radius;
		couleurBord=c;
	} 
	/*
	public RectangleBordsArrondi(Color ci, Color cb) 
	{	
		this.radius = 15;
		couleurBord=cb;
		couleurInterieur=ci;
	} 
	 */
 
	public Insets getBorderInsets(Component c) 
	{             
		return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);        
	}
 
	public boolean isBorderOpaque() 
	{             
		return true;   
	} 
 
	public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) 
	{   
		Graphics2D g2D = (Graphics2D)g;
 
		g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
		g2D.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
 
		/*
        //Intérieur composant
		g2D.setColor(GRIS);
        //g.setColor(couleurInterieur);
		g2D.fillRoundRect(x,y,width-1,height-1,radius,radius);
		*/
 
		//Bordure du composant
		g2D.setColor(couleurBord);
		g2D.setStroke(new BasicStroke(2));
		g2D.drawRoundRect(x,y,width-1,height-1,radius,radius);   
 
	}     
}
Mon JTexField :
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
public class JTextFieldBordsArrondi extends JTextField {
	/**
         * Pour personnaliser l'apparence de mon JTextField
         */
	private static final long serialVersionUID = 1L;
 
	public JTextFieldBordsArrondi(String texte){
		super(texte);
		setPreferredSize(new Dimension(40, 40));
		setBorder(new RectangleBordsArrondi(InitGene.DESACTIVE));
		setVisible(false);
		setOpaque (true);
 
		addFocusListener(new java.awt.event.FocusListener(){
			// Lorsque le focus est perdu
			public void focusLost(FocusEvent e) {
				setBorder(new RectangleBordsArrondi(InitGene.DESACTIVE));
				paintComponent(getGraphics());
			}
			// Lorsque le focus est récupéré
			public void focusGained(FocusEvent arg0) {
				setBorder(new RectangleBordsArrondi(InitGene.ACTIVE));
				paintComponent(getGraphics());
			}
		});
	}
}
Le contour sort bien comme il faut et se modifie bien, mais le text de mon JtextField n'apparait pas.
Ou est le problème ?