Please pardon me if this is hard to follow, but I have a specific problem that I need help solving. I have done a ton of research, and I have tried numerous solutions but no
I would like the image to change size with the size of the JFrame
Instead of doing custom painting in your own component you can use Darryl's Stretch Icon. The Icon will automatically be resized based on the space available.
which is why I dont just use 'setPreferedSize();'.
If you do use custom painting then you should NOT use setPreferredSize(). You SHOULD be overriding the getPreferredSize()
method to return the size of the image. Remember the preferred size is just a suggestion to the layout manager. The layout manager can use or ignore the size.
If you want to scale the image automatically in your paintComponent() method then the code should be:
Dimension d = getSize();
g.drawImage(paint, 0, 0, d.width, d.height, this);
So the real challenge in your code (no matter which solution you choose) is to make sure you are using a layout manger that will give all available space to your component so the image can be scaled automatically.