Bonjour !
Je cherche à afficher un Jpanel(Background) derrière un autre JPanel(Objects). J'ai essayé avec ce code(en regroupant les deux JPanel dans un 3ème), mais il me les affiche en tout petit en haut de ma JFrame...
Classe de la JFrame:
Classe du JPanel principal:
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 package com.helloworld.rendering; import javax.swing.*; public class MainFrame extends JFrame{ public MainFrame(){ this.setVisible(true); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setSize(1280, 740); this.setResizable(false); this.setLocation(200, 100); this.setTitle("DrawBackground"); this.setContentPane(new MainPanel()); } }
Merci !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 package com.helloworld.rendering; import javax.swing.*; public class MainPanel extends JPanel{ public MainPanel() { this.add(new DrawBackground()); //this.add(new DrawObjects()); } }
Partager