Why are you using Canvas in an application that already uses Swing (JFrame is Swing)?
BufferedImage image = new BufferedImage(blah....) Graphics2D gfx = image.createGraphics(); JButton but = new JButton("Click me"); but.update(gfx);
But it really is really really ugly!
Why aren't you taking JPanel? Afaik, you can overwrite the paint method to just call the update method so that the panel does not clear (but some time has passed when I was playing with Java). Then you can use Graphics2D, which you get as an argument in the update method, to draw the material, and it allows you to add your own buttons and other things to it ...
source share