I've made a code to draw on a Jpanel
frame1.add( new JPanel() {
public void paintComponent( Graphics g ) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.white);
g2.fillRect(0, 0, width, height);
//Drawnig Part
});
- Every thing is OK
- Now My question is how to save what I've drawn on my
JPanel
in a filea.PNG
or any other type - I have spent a lot of time to write the
Drawing Part
, So it will be helpful if you can suggest a solution by changing the required parts of my code, instead of rewriting the whole code.