I’m trying to replace my Jlabels with a custom JComponent called PhotoComponent. So far, I’ve followed all the steps laid out from my instructors video on how to create the component. However, trying to replace the desired Jlabels with these two errors: This is the code for my custom component: An…
Tag: swing
paintComponent called multiple times after frame initialization
Consider the example: There is a JFrame with one JPanel with overridden paintComponent method, simply printing something to the console each time this method is called. Every time I run this program, I can see “painting panel” line 3 times in my console. Why is method paintComponent of JPanel call…
How to set the value of a JSpinner using a LocalTime object?
I am trying to make a time picker using JSpinner and Java 8’s time API. I want to make a time picker without date. Before, I was using SimpleDateFormat, but that would return time with date when I print out the value of the JSpinner. So how can I pass the value of a LocalTime object into the setValue me…
Enable a JButton when some component changed its border color [closed]
My goal is to enable a JButton only when some JTextFields and JComboBox change its border color from red to green. These components are included in three different JPanel. I try to create a function …
Make a typewriter effect in a jlabel
This is my JPanel which I’m adding in a JFrame, but the code that write letter per letter but when executed freezes and sometime later, the text appears, the text is not writing with that effect, but I think it should be working, why? when the program run and i press the buttom to run the type writter e…
How to make non-border arrow buttons with Java Swing?
I’m using Java Swing to make a UI and the idea is to make it look like the native OS (in this case, Windows). I’ve used: And everything is good so far, except for one little detail. I’m trying to use the arrow buttons to hide/show a JTextArea like the ones described in MS’s documentati…
How can I set up a JFrame button to open another JFrame, and then receive information once the second jframe is closed?
This is part of a project for school, and I’m stuck and need someone to bounce ideas off of. I have a game where there is an option to sign up or sign in for a machine-local game so a record can be kept of the person’s scores. The game is run from a base GUI JFrame, and I want
My JPanel doesn’t show after adding the paint method
I recently created my first board for my first board game and draw the board multiple ways on my JPanel.I finally decided to use Label, but since I needed to add pictures to that label, I had to change it into JLabel.The syntax is correct, but the Jlabels do not show. I tried cleaning my paint method and It s…
How to draw polyline with negative coordinates in java [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I want to draw polyline with positive and negative coordinates. e.g. 125,66 126,62 -128,59 -…
Grid not working in java swing and getting overflowed
I have a Jframe and I want to show grids as follows: There are 3rows and in the 2nd row there are two columns.So,but when I add a Jlabel and Jtextfield in 2nd row,then the 2nd column of 2nd grid goes below the 2nd row and acts as 3rd column. For eg: So “hello55” needs to come side by side