Skip to content

Tag: swing

Custom Component undefined constructor in Java

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…

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…

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…

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