Hey guys i am struggling a bit with Jframe.Pretty new to JFrame.
I hav a file in Picture class and need to bring the BufferedImage to the DrawingImageControlPanel.How do i do this.
I know the template for doing this is as stated below.
public class ClassName
extends JPanel {
instance variable declarations
helper methods
public constructors
public methods for communication
public void paintComponent(Graphics g) {
super.paintComponent(g);
drawing messages sent to g
}
}
Here is the code in Picture Class that i need to invoke
/**
* Constructor that takes a buffered image
* @param image the buffered image to use
*/
public Picture(BufferedImage image)
{
super(image);
}
Below is my code for Just the class DrawDrawingImageControlPanel
class DrawImageControlPanel extends JPanel
{
// Get Image
public DrawImageControlPanel ()
{
BufferedImage beach;
public DrawImageControlPanel (){ //**Complier say illegal start of expression and expected ';'**
beach=image;
}
}
// Draw Image into BufferedImage
public void paintComponent(Graphics g)
{
super.paintComponent(g);// invoke the superclass paintComponent
paintComponent BufferedImage = picture.getBufferedImage(); // **Complier says expected';'**
Graphics2D g2 = (Graphics2D) g;
g2.drawImage(Image, null, 0 , 0);
}
}
}
Thank you