Problems with java swing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Problems with java swing

Hello! I’m having two problems with my java swing code: 1. The dice image and the button aren’t placed one under another. 2. The JPanel called “panelDentro” isn’t placed at the center of the panel called “panelBlanco”. Can you help me? (You can use replit to see the output) I don’t want ChatGPT answers, please. https://code.sololearn.com/cUg49824pH4y/?ref=app

9th Aug 2023, 3:54 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
5 Answers
+ 2
I've just started reading about this. I didn't see it in your code, but have you heard about Grid Layout? That might help, or even LinearLayout. Jayakrishna 🇮🇳 and A͢J are my "Java experts", they might have a better, more direct answer.
10th Aug 2023, 7:00 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
I thought that I'd tagged them... 🤔 I'll send them the link, see if they have time.
10th Aug 2023, 11:36 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Ausgrindtube thank you
10th Aug 2023, 11:40 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 1
Hi, i would replace your panelDentro with a BorderLayout and add dado label to CENTER and button to SOUTH like this panelDentro.add(dado,BorderLayout.CENTER); panelDentro.add(tirar,BorderLayout.SOUTH); And also give your panelBlanco a BorderLayout and then add your panelDentro to panelBlanco like this panelBlanco.add(panelDentro,BorderLayout.CENTER);
15th Aug 2023, 6:14 PM
JavaBobbo
JavaBobbo - avatar
0
Ausgrindtube should I ping them? I will search about that layouts. Thank you for your answer!
10th Aug 2023, 8:47 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar