IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Agents de placement/Fenêtres Java Discussion :

bug affichage de Jframe


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Membre du Club
    Homme Profil pro
    Artisant
    Inscrit en
    Avril 2018
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Artisant
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2018
    Messages : 169
    Points : 60
    Points
    60
    Par défaut bug affichage de Jframe
    Bonsoir,

    Je me retrouve avec un bug mineur mais je ne trouve pas d'ou ca viens...

    Alors pour faire simple :

    J'ai une jframe principale qui fais 700 par 400, dans celle ci j'ai dessiner des composant moi meme (bouton,text...) avec une classe qui extends jcomponent. jusque la rien d'anormale.

    Quatre de mes bouton dessiné ouvre respectivement 4 autre Jframe qui contienne des Jcombobox, bouton....

    J'ai dans c'est jframe des fond de couleur avec une légère transparence.

    le soucis que je rencontre est lorsque j'ouvre mes jframe a l'aide des bouton de la jframe principale, celle si affiche en plus du background de couleur les autre jframe....

    Pour faire simple : Jframe principale = jframe 1 (au centre de l'ecran)

    J'affiche mes 4 jframe a l'ecran

    bouton 1 = Jframe 2 (en haut a gauche)
    bouton 2 = Jframe 3 (en haut a droite)
    bouton 3 = jframe 4 (en bas a gauche)
    bouton 4 = jframe 5 (en bas a droite)

    J'ouvre la Jframe 2, tout es ok.
    j'ouvre la jframe 3, ont apercoit en fond la jframe 2 a l'interieur)
    j'ouvre la jframe 4, ont apercoit en fond la jframe 3 et 2 a l'interieur et du coup dans ma jframe 3, la 4 apparait en fond..)
    j'ouvre la jframe 5, ont apercoit en fond la jframe 3,2 et 1 a l'interieur et du coup dans ma jframe 4, la 5 apparait en fond et idel pour la 3..)

    seul la jframe 2 n'a aucun soucis. pourtant le l'est créer toute de la même manière....

    Ouverture a l'aide de mon bouton :
    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
     
     
     if (Paramettre.contains(event.getX(), event.getY())) {
     
     
     
                        SwingUtilities.invokeLater(() -> {
                            try {
                                new Frameparameter();
     
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        });
     
     
                    }
    et une des Jframe
    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
     {
     
            this.setTitle("Parametres des touches Clavier");
            this.setSize(500,400);
            this.setAlwaysOnTop(true);
            this.setResizable(true);
            this.setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
            this.setLocationRelativeTo(null);
            this.setVisible(true);
     
     
            this.setContentPane(pan1);
     
            pan1.setBackground(Color.ORANGE);
            pan1.setLayout(null);
     
    ....}
    et ma Jframe principale:
    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
      public Main() throws IOException {
     
            this.setSize(700,400);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setAlwaysOnTop(true);
            this.setResizable(false);
     
            this.setUndecorated(true);
            this.setBackground(new Color(0, 0, 0, 0));
     
            this.getContentPane().setLayout(null);
            this.setVisible(true);
     
            this.getContentPane().add(action);
            this.getContentPane().add(moving);
    ....
    Une idée?

    Cordialement


    Fred

  2. #2
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    Et tu m'aurai pas oublie de mettre un appel a super.paintComponent() dans une ou plusieurs de tes surcharges de paintCompoment() (resp avec paint()) ? En gros dans le code que tu nous as mis il manque la partie rendu qui semble fortement être la source de l'erreur.
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  3. #3
    Membre du Club
    Homme Profil pro
    Artisant
    Inscrit en
    Avril 2018
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Artisant
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2018
    Messages : 169
    Points : 60
    Points
    60
    Par défaut
    Bonsoir,

    Voci le code de ma class Action (jFrame principale) qui affiche mes bouton
    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
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    public class Action  extends  JComponent {
     
     
     
        private final RoundRectangle2D quit = new RoundRectangle2D.Float(26, 22, 54, 15, 10, 10);
        private final RoundRectangle2D slot1 = new RoundRectangle2D.Float(31, 96, 311, 39, 10, 10);
        private final RoundRectangle2D slot2 = new RoundRectangle2D.Float(31, 145, 311, 39, 10, 10);
        private final RoundRectangle2D viseur = new RoundRectangle2D.Float(31, 193, 311, 39, 10, 10);
        private final RoundRectangle2D armes = new RoundRectangle2D.Float(31, 241, 311, 39, 10, 10);
        private final RoundRectangle2D Moving = new RoundRectangle2D.Float(195, 22, 98, 15, 10, 10);
        private final RoundRectangle2D Overlay = new RoundRectangle2D.Float(88, 22, 99, 15, 10, 10);
        private final RoundRectangle2D Paramettre = new RoundRectangle2D.Float(302, 22, 99, 15, 10, 10);
        private final RoundRectangle2D SelectGameWeapons = new RoundRectangle2D.Float(409, 22, 99, 15, 10, 10);
        private final RoundRectangle2D ConfigArmes1 = new RoundRectangle2D.Float(409, 100, 99, 15, 10, 10);
        private final RoundRectangle2D ConfigArmes2 = new RoundRectangle2D.Float(409, 150, 99, 15, 10, 10);
        private boolean mouseDown = false;
     
        private Optional<Point2D> lastCoord = empty();
        private Optional<Point2D> lastCoord1 = empty();
        private Optional<Point2D> lastCoord2 = empty();
        private Optional<Point2D> lastCoord3 = empty();
        private Optional<Point2D> lastCoord4 = empty();
        private Optional<Point2D> lastCoord5 = empty();
        private Optional<Point2D> lastCoord6 = empty();
        private Optional<Point2D> lastCoord7 = empty();
        private Optional<Point2D> lastCoord8 = empty();
        private Optional<Point2D> lastCoord9 = empty();
        private Optional<Point2D> lastCoord10 = empty();
        private Optional<Point2D> lastCoord11 = empty();
     
        private String path1 = "src/images/STANDING.png";
        private BufferedImage Standing2 = ImageIO.read(new File(path1));
        private String path2 = "src/images/CROUCH.png";
        private BufferedImage Crouch2 = ImageIO.read(new File(path2));
        private String path3 = "src/images/PRONE.png";
        private BufferedImage Prone2 = ImageIO.read(new File(path3));
     
     
     
        private Font myFont = new Font("Serif", Font.BOLD, 30);
        private Font myFont1 = new Font("Arial arrondi MT Bold", Font.BOLD, 10);
        private Font myFont2 = new Font("Arial arrondi MT Bold", Font.BOLD + Font.ITALIC, 8);
     
        private Color COLOR1 = new Color(0.85F, 0.90F, 0.90F, 0.4F);
        private Color COLOR2 =  new Color(0.0F, 0.0F, 0.0F, 0.5F);
     
        private Color COLOR5 = new Color(225, 96, 0);
        private Color VIOLET = new Color(254, 40, 211);
        private Color BLEU = new Color(1, 1, 254);
        private Color NOIR = new Color(0, 0, 0);
        private Color GRIS = new Color(128, 128, 128);
        private Color BLANC = new Color(255, 255, 255);
        private Color VERT = new Color(0, 255, 0);
        private Color ROUGE = new Color(255, 0, 0);
        private Color JAUNE = new Color(255, 255, 0);
     
     
     
            Action() throws IOException {
     
            MouseInputListener mouseInputListener2 = new MouseInputAdapter() {
     
     
                @Override
                public void mouseClicked(MouseEvent event) {
     
                    if (slot1.contains(event.getX(), event.getY())) {
                        ConfigManager1.getInstance1().cycleConfigs();
                        Weapons_Config.NomArme.setText(ConfigManager1.getInstance1().getCurrentConfig().name);
                        Weapons_Config.Cadencedetir.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().rateoffire));
                        Weapons_Config.Nombredeballes.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().bullets));
                        Weapons_Config.ReculVertical.setText(Arrays.toString(ConfigManager1.getInstance1().getCurrentConfig().weaponssetbackTablevertical).replace("[", "").replace("]", "").replace("\"", ""));
                        Weapons_Config.ReculHorizontal.setText(Arrays.toString(ConfigManager1.getInstance1().getCurrentConfig().weaponssetbackTablehorizontal).replace("[", "").replace("]", "").replace("\"", ""));
                        Weapons_Config.NomViseur1.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex1name));
                        Weapons_Config.TauxdereculX1.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex1));
                        Weapons_Config.NomViseur2.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex2name));
                        Weapons_Config.TauxdereculX2.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex2));
                        Weapons_Config.NomViseur3.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex3name));
                        Weapons_Config.TauxdereculX3.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex3));
                        Weapons_Config.NomViseur4.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex4name));
                        Weapons_Config.TauxdereculX4.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Scopex4));
                        Weapons_Config.Standing.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Standing));
                        Weapons_Config.Crouch.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Crouch));
                        Weapons_Config.Prone.setText(String.valueOf(ConfigManager1.getInstance1().getCurrentConfig().Prone));
                        System.out.println("Arme1");
                    }
                    if (slot2.contains(event.getX(), event.getY())) {
                        ConfigManager2.getInstance2().cycleConfigs();
                        Weapons_Config2.NomArme.setText(ConfigManager2.getInstance2().getCurrentConfig().name);
                        Weapons_Config2.Cadencedetir.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().rateoffire));
                        Weapons_Config2.Nombredeballes.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().bullets));
                        Weapons_Config2.ReculVertical.setText(Arrays.toString(ConfigManager2.getInstance2().getCurrentConfig().weaponssetbackTablevertical).replace("[", "").replace("]", "").replace("\"", ""));
                        Weapons_Config2.ReculHorizontal.setText(Arrays.toString(ConfigManager2.getInstance2().getCurrentConfig().weaponssetbackTablehorizontal).replace("[", "").replace("]", "").replace("\"", ""));
                        Weapons_Config2.NomViseur1.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex1name));
                        Weapons_Config2.TauxdereculX1.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex1));
                        Weapons_Config2.NomViseur2.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex2name));
                        Weapons_Config2.TauxdereculX2.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex2));
                        Weapons_Config2.NomViseur3.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex3name));
                        Weapons_Config2.TauxdereculX3.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex3));
                        Weapons_Config2.NomViseur4.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex4name));
                        Weapons_Config2.TauxdereculX4.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Scopex4));
                        Weapons_Config2.Standing.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Standing));
                        Weapons_Config2.Crouch.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Crouch));
                        Weapons_Config2.Prone.setText(String.valueOf(ConfigManager2.getInstance2().getCurrentConfig().Prone));
     
                        System.out.println("Arme2");
                    }
                    if (viseur.contains(event.getX(), event.getY())) {
                        Main.choixviseur = Main.choixviseur.next();
                        System.out.println("Viseur");
                    }
                    if (Moving.contains(event.getX(), event.getY())) {
                        Main.Moving = !Main.Moving;
                        System.out.println("Moving");
                    }
                    if (ConfigArmes1.contains(event.getX(), event.getY())) {
     
     
     
                        SwingUtilities.invokeLater(() -> {
                            try {
     
                                new Weapons_Config();
     
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        });
     
     
                        //new Weapons_Config();
    // ic ont lance la nouvelle fenetre
                    }
                    if (ConfigArmes2.contains(event.getX(), event.getY())) {
     
     
                        SwingUtilities.invokeLater(() -> {
                            try {
                                new Weapons_Config2();
     
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        });
    // ic ont lance la nouvelle fenetre
                    }
     
                    if (SelectGameWeapons.contains(event.getX(), event.getY())) {
     
                        SwingUtilities.invokeLater(() -> {
                            try {
                                new Gameselection();
     
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        });
     
                    }
                    if (Paramettre.contains(event.getX(), event.getY())) {
     
                        SwingUtilities.invokeLater(() -> {
                            try {
                                new Frameparameter();
     
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        });
     
     
                    }
     
                    if (armes.contains(event.getX(), event.getY())) {
                        Main.change = !Main.change;
     
                        if (!Main.change) {
                            if (!Main.rightClick) {
                                System.out.println("Armes1enjeux");
                                switch (Main.switcharmes) {
                                    case ARMES1:
                                        Main.memoireChoix.put(ConfigManager1.getInstance1().getCurrentConfig(), Main.choixviseur);
                                        break;
                                    case ARMES2:
                                        Main.memoireChoix.put(ConfigManager2.getInstance2().getCurrentConfig(), Main.choixviseur);
                                        break;
                                }
                                Main.switcharmes = Main.Switcharmes.ARMES1;
                                switch (Main.switcharmes) {
                                    case ARMES1:
                                        Main.choixviseur = Main.memoireChoix.getOrDefault(ConfigManager1.getInstance1().getCurrentConfig(), Main.Choixviseur.VISEUR1);
                                        break;
                                    case ARMES2:
                                        Main.choixviseur = Main.memoireChoix.getOrDefault(ConfigManager2.getInstance2().getCurrentConfig(), Main.Choixviseur.VISEUR1);
                                        break;
                                }
                                System.out.println("mouse wheel Up");
                            }
                        }
                        if (Main.change) {
                            if (!Main.rightClick) {
                                System.out.println("Armes2enjeux");
                                switch (Main.switcharmes) {
                                    case ARMES1:
                                        Main.memoireChoix.put(ConfigManager1.getInstance1().getCurrentConfig(), Main.choixviseur);
                                        break;
                                    case ARMES2:
                                        Main.memoireChoix.put(ConfigManager2.getInstance2().getCurrentConfig(), Main.choixviseur);
                                        break;
                                }
                                Main.switcharmes = Main.Switcharmes.ARMES2;
     
                                switch (Main.switcharmes) {
                                    case ARMES1:
                                        Main.choixviseur = Main.memoireChoix.getOrDefault(ConfigManager1.getInstance1().getCurrentConfig(), Main.Choixviseur.VISEUR1);
                                        break;
                                    case ARMES2:
                                        Main.choixviseur = Main.memoireChoix.getOrDefault(ConfigManager2.getInstance2().getCurrentConfig(), Main.Choixviseur.VISEUR1);
                                        break;
                                }
                                System.out.println("mouse wheel Down");
                            }
                        }
                    }
     
                    if (quit.contains(event.getX(), event.getY())) {
                        System.out.println("Exit/CloseApps");
                        try {
                            GlobalScreen.unregisterNativeHook();
                            MouseListener.executorService.shutdown();
                            Gameselection.Servicegameselection.shutdown();
                            Weapons_Config.Serviceweaponsconfig1.shutdown();
                            Weapons_Config2.Serviceweaponsconfig2.shutdown();
                            System.exit(1);
                        } catch (NativeHookException e1) {
                            e1.printStackTrace();
                        }
                    }
                }
     
                @Override
                public void mousePressed(MouseEvent event) {
                    mouseDown = true;
     
                }
                @Override
                public void mouseReleased(MouseEvent e) {
     
                    mouseDown = false;
     
                }
                @Override
                public void mouseEntered(MouseEvent event) {
                    lastCoord = lastCoord1 = lastCoord2 = lastCoord3 = lastCoord4 = lastCoord5 = lastCoord6 = lastCoord7 = lastCoord8 = lastCoord9 = lastCoord10 = lastCoord11 = of(new Point(event.getX(), event.getY()));
     
                }
                @Override
                public void mouseMoved(MouseEvent event) {
                    lastCoord = lastCoord1 = lastCoord2 = lastCoord3 = lastCoord4 = lastCoord5 = lastCoord6 = lastCoord7 = lastCoord8 = lastCoord9 = lastCoord10 = lastCoord11 = of(new Point(event.getX(), event.getY()));
     
                }
                @Override
                public void mouseExited(MouseEvent event) {
                    lastCoord = lastCoord1 = lastCoord2 = lastCoord3 = lastCoord4 = lastCoord5 = lastCoord6 = lastCoord7 = lastCoord8 = lastCoord9 = lastCoord10 = lastCoord11  = empty();
     
                }
            };
               addMouseListener(mouseInputListener2);
               addMouseMotionListener(mouseInputListener2);
        }
     
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
             Graphics2D g2 = (Graphics2D) g;
     
                    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
     
                switch (Main.size) {
     
                    case SIZE1:
     
                        if (Main.Overlay) {
                            g2.setColor(GRIS);
                            g2.fillRoundRect(3, 10, 600, 310, 30, 30);
                            g2.setColor(NOIR);
                            g2.fillRoundRect(8, 15, 590, 300, 30, 30);
                            g2.setColor(BLANC);
                            g2.drawRoundRect(25, 21, 55, 16, 10, 10);
                            g2.drawRoundRect(87, 21, 100, 16, 10, 10);
                            g2.drawRoundRect(194, 21, 99, 16, 10, 10);
                            g2.drawRoundRect(301, 21, 99, 16, 10, 10);
                            g2.drawRoundRect(408, 21, 99, 16, 10, 10);
                            g2.drawRoundRect(30, 46, 312, 40, 10, 10);
                            g2.drawRoundRect(30, 95, 312, 40, 10, 10);
                            g2.drawRoundRect(30, 144, 312, 40, 10, 10);
                            g2.drawRoundRect(30, 192, 312, 40, 10, 10);
                            g2.drawRoundRect(30, 240, 312, 40, 10, 10);
                            g2.drawRoundRect(408, 99, 99, 16, 10, 10);
                            g2.drawRoundRect(408, 149, 99, 16, 10, 10);
     
     
                            g2.setFont(myFont1);
                            g2.setColor(JAUNE);
                            g2.drawString(Main.GameSelected, 410, 56);
     
                            g2.drawString(Main.Exit, 54, 33);
                            g2.setColor(ROUGE);
                            g2.drawString("Exit:", 31, 33);
     
     
                            g2.setColor(BLANC);
                            g2.drawString("OverlayMode:", 93, 33);
                            g2.drawString("Paramettre", 325, 33);
                            g2.drawString("Select Game", 427, 33);
                            g2.drawString("Config_SLOT1", 420, 111);
                            g2.drawString("Config_SLOT2", 420, 161);
     
                            Color fil6= COLOR1;
                            if (lastCoord5.isPresent() && quit.contains(lastCoord5.get())) { fil6 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil6);g2.fill(quit);
                            Color fil7= COLOR1;
                            if (lastCoord6.isPresent() && Moving.contains(lastCoord6.get())) { fil7 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil7);g2.fill(Moving);
                            Color fil8= COLOR1;
                            if (lastCoord7.isPresent() && Overlay.contains(lastCoord7.get())) { fil8 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil8);g2.fill(Overlay);
                            Color fil9= COLOR1;
                            if (lastCoord8.isPresent() && Paramettre.contains(lastCoord8.get())) { fil9 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil9);g2.fill(Paramettre);
                            Color fil10= COLOR1;
                            if (lastCoord9.isPresent() && SelectGameWeapons.contains(lastCoord9.get())) { fil10 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil10);g2.fill(SelectGameWeapons);
                            Color fil11= COLOR1;
                            if (lastCoord10.isPresent() && ConfigArmes1.contains(lastCoord10.get())) { fil11 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil11);g2.fill(ConfigArmes1);
                            Color fil12= COLOR1;
                            if (lastCoord11.isPresent() && ConfigArmes2.contains(lastCoord11.get())) { fil12 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil12);g2.fill(ConfigArmes2);
                            }
     
     
     
                            Color fil2 = COLOR1;
                        if (lastCoord1.isPresent() && slot1.contains(lastCoord1.get())) { fil2 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil2);g2.fill(slot1);
                            Color fil3 = COLOR1;
                        if (lastCoord2.isPresent() && slot2.contains(lastCoord2.get())) { fil3 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil3);g2.fill(slot2);
                            Color fil4 = COLOR1;
                        if (lastCoord3.isPresent() && viseur.contains(lastCoord3.get())) { fil4 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil4);g2.fill(viseur);
                            Color fil5 = COLOR1;
                        if (lastCoord4.isPresent() && armes.contains(lastCoord4.get())) { fil5 = mouseDown ? COLOR1 : COLOR2; }g2.setColor(fil5);g2.fill(armes);
     
     
                            g2.setFont(myFont);
                            g2.setColor(COLOR5);
                            g2.drawString("Viseur :", 50, 222);
                            g2.setColor(COLOR5);
                            g2.drawString("Slot1 :", 50, 125);
                            g2.setColor(BLEU);
                            g2.drawString(ConfigManager1.getInstance1().getCurrentConfig().name, 224, 125);
                            g2.setColor(COLOR5);
                            g2.drawString("Slot2 :", 50, 174);
                            g2.setColor(VIOLET);
                            g2.drawString(ConfigManager2.getInstance2().getCurrentConfig().name, 224, 174);
                            g2.setColor(COLOR5);
                            g2.drawString("Arme :", 50, 270);
     
     
                            switch (Main.switcharmes) {
                                case ARMES1: g2.setFont(myFont);g2.setColor(BLEU);g2.drawString(ConfigManager1.getInstance1().getCurrentConfig().name, 225, 270);break;
                                case ARMES2: g2.setFont(myFont);g2.setColor(VIOLET);g2.drawString(ConfigManager2.getInstance2().getCurrentConfig().name, 225, 270);break; }
                        if (Main.switcharmes == Main.Switcharmes.ARMES1) {
                            switch (Main.choixviseur) {
     
                                    //   case VISEUR1: g2.setColor(VERT);g2.setFont(myFont);g2.drawString("  RedDotX1", 180, 222);break;
                                    case VISEUR1:
                                        g2.setFont(myFont);
                                        g2.setColor(VERT);
                                        g2.drawString(ConfigManager1.getInstance1().getCurrentConfig().Scopex1name, 180, 222);
                                        break;
                                    case VISEUR2:
                                        g2.setFont(myFont);
                                        g2.setColor(VERT);
                                        g2.drawString(ConfigManager1.getInstance1().getCurrentConfig().Scopex2name, 180, 222);
                                        break;
                                    case VISEUR3:
                                        g2.setFont(myFont);
                                        g2.setColor(VERT);
                                        g2.drawString(ConfigManager1.getInstance1().getCurrentConfig().Scopex3name, 180, 222);
                                        break;
                                    case VISEUR4:
                                        g2.setFont(myFont);
                                        g2.setColor(VERT);
                                        g2.drawString(ConfigManager1.getInstance1().getCurrentConfig().Scopex4name, 180, 222);
                                        break;
                                }
                            }
                        if (Main.switcharmes == Main.Switcharmes.ARMES2) {
                            switch (Main.choixviseur) {
     
                                //   case VISEUR1: g2.setColor(VERT);g2.setFont(myFont);g2.drawString("  RedDotX1", 180, 222);break;
                                case VISEUR1:
                                    g2.setFont(myFont);
                                    g2.setColor(VERT);
                                    g2.drawString(ConfigManager2.getInstance2().getCurrentConfig().Scopex1name, 180, 222);
                                    break;
                                case VISEUR2:
                                    g2.setFont(myFont);
                                    g2.setColor(VERT);
                                    g2.drawString(ConfigManager2.getInstance2().getCurrentConfig().Scopex2name, 180, 222);
                                    break;
                                case VISEUR3:
                                    g2.setFont(myFont);
                                    g2.setColor(VERT);
                                    g2.drawString(ConfigManager2.getInstance2().getCurrentConfig().Scopex3name, 180, 222);
                                    break;
                                case VISEUR4:
                                    g2.setFont(myFont);
                                    g2.setColor(VERT);
                                    g2.drawString(ConfigManager2.getInstance2().getCurrentConfig().Scopex4name, 180, 222);
                                    break;
                            }
                        }
     
                        switch (Main.positions) {
                                case STANDING: g2.drawImage(Standing2, 360, 200,   this);break;
                             //   case STANDING: g2.drawImage(Standing2, 380, 182, 50, 70,  this);break;
                                case CROUCH: g2.drawImage(Crouch2, 360, 240, this);break;
                                case PRONE: g2.drawImage(Prone2, 350, 225, this);break; }
     
                }
            g2.dispose();
            }
     
    }
    C'est la seul class ou j'utilise : super.paintComponent().

    Doit je utilise aussi super.paintComponent() dans les class ou j'affiche mes jcombobox, textfield??

  4. #4
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    Tu dois faire super.paintComponent() des que tu surcharges paintComponent() sauf si tu prends soin de correctement initialiser ta surface graphique au debut du rendu.

    PS : évite d’invoquer dispose() sur un Graphics que tu n'as pas crée toi-même (puisqu’ici tu te contentes caster celui que tu as reçu en paramètres). Ou alors tu fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Graphics2D g2 = (Graphics2D) g.create();
    [...]
    g2dispose();
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  5. #5
    Membre du Club
    Homme Profil pro
    Artisant
    Inscrit en
    Avril 2018
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Artisant
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2018
    Messages : 169
    Points : 60
    Points
    60
    Par défaut
    Bonsoir,

    D.accord, je pense avoir compris.

    Le dispose je l'es mis dernièrement en faisant des test pour essayé d.enleve mon problème d.aparition de mes jframe dans mes autre jframe.

    Est ce bien ma class Action qui pose probleme?

  6. #6
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 854
    Points
    22 854
    Billets dans le blog
    51
    Par défaut
    En l’état il m'est difficile de répondre a cette question puisque je ne peux pas reproduire ce soucis meme apres avoir simplifie le programme au max :

    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
    package transparentframe;
     
    import javax.swing.*;
    import java.awt.*;
     
    public class Main {
        public static void main(String... args) {
            SwingUtilities.invokeLater(Main::startEDT);
        }
     
        private static void startEDT() {
            final var mainFrame = createNewFrame();
            mainFrame.setTitle("Main");
            mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            mainFrame.setUndecorated(true);
            mainFrame.setVisible(true);
            mainFrame.setBackground(new Color(0, 0, 0, 0));
            mainFrame.setSize(700, 400);
            final var action = new Action();
            action.setSize(700, 400);
            mainFrame.getContentPane().add(action);
            mainFrame.getContentPane().setLayout(null);
            final var button = new JButton("Test");
            button.setSize(100, 35);
            button.addActionListener(event -> {
                final var frame = createNewFrame();
                frame.setTitle("Test");
                final var panel = new JPanel();
                panel.setBackground(Color.ORANGE);
                frame.add(panel);
                frame.setVisible(true);
            });
            mainFrame.add(button);
        }
     
        private static JFrame createNewFrame() {
            final var result = new JFrame();
            result.setResizable(true);
            result.setAlwaysOnTop(true);
            result.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            result.setLocationRelativeTo(null);
            result.setSize(500, 400);
            return result;
        }
    }
    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
    package transparentframe;
     
    import javax.swing.*;
    import java.awt.*;
     
    final class Action extends JComponent {
        private static Color COLOR1 = new Color(0.85F, 0.90F, 0.90F, 0.4F);
     
        public Action() {
        }
     
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
    //        Graphics2D g2 = (Graphics2D) g;
            final var g2 = (Graphics2D) g.create();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(COLOR1);
            g2.fillRect(0, 0, getWidth(), getHeight());
            g2.dispose();
        }
    }
    EDIT - essaie peut-être de rajouter setOpaque(false); dans le constructeur de Action juste au cas ou.
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  7. #7
    Membre du Club
    Homme Profil pro
    Artisant
    Inscrit en
    Avril 2018
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Artisant
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2018
    Messages : 169
    Points : 60
    Points
    60
    Par défaut
    Bonjour,

    J'ai trouvé d'ou viens le problème.

    En faite pour pallier a une baisse de frame rate (https://www.developpez.net/forums/d1...alog-ramer-pc/)

    J'avais essayé de lance mes autre fenêtre dans d'autre thread..

    ça fonctionnais mais comme vue dans ce poste, j'avais des bug d'affichage...

    En faite j'essayais de contourner le problème.

    J'ai a force de cherche trouve d'ou viens la baisse de framerate mais je ne comprend pas pourquoi.

    C'est simplement du a ma fenêtre principale qui est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    frame.setUndecorated(true);
       frame.setBackground(new Color(0, 0, 0, 0));
    si je supprime ses lignes, plus aucun soucis de performance...

    Et ce du au faite que j'ai créer mes dessin direct sur la jframe sans avoir créer de jpanel avant?

    Merci


    Fred

  8. #8
    Membre du Club
    Homme Profil pro
    Artisant
    Inscrit en
    Avril 2018
    Messages
    169
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Corse (Corse)

    Informations professionnelles :
    Activité : Artisant
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2018
    Messages : 169
    Points : 60
    Points
    60
    Par défaut
    Bonsoir,

    Problème résolu enfin pour mon type de projet.

    Etant donné que ma JFrame principale est undecorated, j'ai passe mes autre JFrame ainsi et plus de problème de chute de frame rate.


    Pourquoi? ca je ne sait pas mais ca juste a rajoute des boutons de fermeture le tour est joué.



    Cordialement

    Fred

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Apache2] Bug Affichage/Chargement incomplet...
    Par Atomicfryer dans le forum Apache
    Réponses: 3
    Dernier message: 27/09/2009, 12h24
  2. Bug affichage JFrame avec les marges (Insets)
    Par utoria dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 28/04/2007, 15h55
  3. [C#] [GDI+] Bug affichage
    Par Tips dans le forum C#
    Réponses: 8
    Dernier message: 05/12/2005, 17h41
  4. [TScrollBox] Bug affichage
    Par Pedro dans le forum Composants VCL
    Réponses: 10
    Dernier message: 14/09/2005, 11h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo