Export JPanel Graphics to .png or .gif or .jpg

前端 未结 2 509
一生所求
一生所求 2020-12-14 10:46

I\'m trying to develop some sort of paint using Java.

I have a JComponent that is located inside of a JPanel.

I already can draw lines and rectangles into th

2条回答
  •  遥遥无期
    2020-12-14 11:04

    First of all, print() is the incorrect method. What I guess should work (haven't tested it yet) is: get the BufferedImage's Graphics (b.createGraphics()) and use that graphics object to paint() your panel/component.

    (e.g. yourPanel.paint(b.createGraphics());)

提交回复
热议问题