Campbell Ritchie wrote:Most people extend JPanel, overriding only the paintComponent() method to do drawing etc. Not paintComponents(). Are you creating the buffered image from the drawing? If so, how? I would be interested to see how you do that
Campbell Ritchie wrote:
As for the Action class. Why are you saying anything about Canvas? Waht does opening a new file mean? Does it mean you are opening a file to save your work, or that you are clearing the display to start drawing anew? What does the new file dialogue do? Is it used elsewhere? If not, why not make it a private (probably static) nest class in the Action class? If you are clearing the Canvas, are you saving the previous drawing anywhere?
Please explain more.
That doesn't sound a good idea to me; as a general rule of thumb avoid subclassing display classes. There are only a few that should actually be subclassed.
Campbell Ritchie wrote:Welcome to the Ranch
Short answer: NO.
Longer answer: Always consider what your display is going to look like. It will usually look better if you don't have windows/dialogues/etc. appearing and disappearing unexpectedly. But it is probably a bad idea to use two frames. If you want to click a button and have a new display appear with your image, it is usually better to use a JDialog with a JPanel added, and display the image on that panel. Unless the image is small (500×500px counts as small, 2048×3072px counts as large), you are probably better off using a scroll pane. See whether these two Java™ Tutorials sections help: 1 2.
I wasn't clear in my post. If you have a small image, display it on a JPanel. If you have a large image, add the panel you are showing the image on to a scroll pane. Is that any clearer?