Bonjour,

Je souhaite convertir la valeur de "pos" de la méthode setComponentConstraints() avec la classe DecimalFormat, mais j'ai une erreur à la ligne 48 de Login.java, auriez vous une idée?
Code java : 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
 
private final DecimalFormat df=new DecimalFormat("##0.###");
....
TimingTarget target = new TimingTargetAdapter(){
            @Override
            public void timingEvent(float fraction){
                double fractionCover;
                if(isLogin) fractionCover = 1f - fraction;
                else fractionCover=fraction;
 
                fractionCover=Double.parseDouble(df.format(fractionCover));//Ligne 48 Login.java erreur ici
 
                mig.setComponentConstraints(container, "width "+coverSize+"%, pos "+fractionCover+"al 0 n 100%");
                bg.revalidate();
            }
            @Override
            public void end(){
                isLogin=!isLogin;
            }
        };
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "0,001"
at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.base/java.lang.Double.parseDouble(Double.java:651)
at interfaces.Login$1.timingEvent(Login.java:48)
at org.jdesktop.animation.timing.Animator.timingEvent(Animator.java:728)
at org.jdesktop.animation.timing.Animator.access$200(Animator.java:75)
at org.jdesktop.animation.timing.Animator$TimerTarget.actionPerformed(Animator.java:1041)
at java.desktop/javax.swing.Timer.fireActionPerformed(Timer.java:311)
at java.desktop/javax.swing.Timer$DoPostEvent.run(Timer.java:243)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)