I’m not sure if this is a math or a programming question, but i don’t know how i can transform the coordinates of a JPanel to the coordinates of a graph. If i have a JPanel with 800×1000 size and the graph has the sizes -2 to 2(x) and -2 to 2(y) and i am drawing something on ths graph(i
Tag: jpanel
Buttons not visible until mouseover
I created a frame and panel (for Graphics) and add buttons to the panel. However, when I run my program buttons are not visible until I hover over them. Maybe it is something wrong with graphics methods. How the problem can be solved? Answer Your painting code is mostly wrong. For example: If you need to over…
Why does paintComponent get called only on some JPanels?
I’m trying to add a background to different JPanels (henceforth they will be called Window). These Windows are classes I created and make them inherit JPanel. Then depending on the state of the program one Window is set as the content panel of the program’s JFrame. The problem comes when in some W…
Buttons not showing up in JPanel
I’m having a ton of trouble figuring out why the buttons in this won’t show? They were showing up earlier today when I test ran the program but now I’ve been stuck for 2 hours trying to get the buttons to show up again. It’s also really weird because the panel is definitely showing up …
JPanel not showing in JFrame, but JFrame still changes size
I don’t know what I did, or what went wrong, but a change I made at some point in the last while has made my JPanel completely invisible. The JFrame it’s nested in still changes in size to house it, and I can still toggle the content in the combobox. In my desperation, I tried replacing the conten…
How to make all images in Grid Overlay flush?
I am trying to implement a GUI for a maze-based game I created that meets the following specific conditions: The GUI itself has a set size and is not resizable (line 41) . The master panel (line 57) that contains all the maze images is scrollable. All maze image components are flush with each other. If maze i…
Adding JavaFX PieChart in JPanel
I want to add a Pie chart inside a JPanel. I have gone through this and this. But it didnt helped me. I tried this code in the debugger but it is not getting pass line X. Somehow setScene function is not working and pie chart is not visible in the panel. Here’s my code: I am not sure why
Ending a timer using keyadapters?
So, I am creating this reaction time game that shows a blue ball and once you see that blue ball, you press up arrow key to get your reaction time once it turned blue. However, I am having trouble in creating a timer. I want the timer to start once the ball actually turns blue and want that timer to
How do I put two Jpanels/Jbuttons in the borderlayout north section?
How do I display two JPanels in the ‘North’ in borderlayout? Here’s and example code that outputs a GUI with three distinct rows, Top, Middle, Bottom. There’s one button covering the first row, 3 buttons covering the second row, and one covering the bottom row. Output of above code: ou…
JComponent not being drawn on JLayeredPane, JPanel is
I’ve added a JLayeredPane to a JFrame. To said pane i’ve added a JComponent with overloaded paintComponent(Graphics g) method, which calls super.paintComponent(g) among other things. The JComponent …