I am having problems displaying an image I obtain from a file chooser I created. Could you give me suggestions? The image is created as a buffered image.
Here is my code:
public void actionPerformed(ActionEvent e)
{
if (e.getSource().getClass().getName().contains("JMenuItem"))
{
if (e.paramString().contains("Load")) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File("."));
int retVal = fc.showOpenDialog(null);
if (retVal == 0)
{
File file = fc.getSelectedFile();
try {
image = ImageIO.read(file);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
Here is the code for display:
public void paint(Graphics g){
super.paintComponents(g);
g.drawImage(getIconImage(), 0, 0, control);
g.drawImage( image, 0, 0,null);
repaint();
}