B
Bojan
Hi all,
For some reason the paintComponent is never called to print the
image. The image is valid, i have tested it with setIconImage(image)
and it worked fine. Why is the paintComponent never called? Any help
would be appreciated. Thanks in Advance.
The ProgressFrame is called from a run method, which is in a class
that implements Runnable. Which is called by creating a new thread.
Here is the code for the ProgressFrame:
public class ProgressFrame extends JFrame {
public ProgressFrame()
{
Container contentPane = this.getContentPane();
URL url = this.getClass().getResource("/Resources/busy.jpg");
Image image = Toolkit.getDefaultToolkit().getImage(url); //new File
("/Resources/busy.jpg");
DrawingPanel panel = new DrawingPanel(image);
contentPane.add(panel);
setTitle("Loading");
setSize(384, 230);
setResizable(false);
setVisible(true);
toFront();
}
}
class DrawingPanel extends JPanel
{
Image img;
DrawingPanel (Image img)
{ this.img = img; }
public void paintComponent (Graphics g) {
super.paintComponent (g);
g.drawImage (img, 0, 0, this);
} // paintComponent
}
For some reason the paintComponent is never called to print the
image. The image is valid, i have tested it with setIconImage(image)
and it worked fine. Why is the paintComponent never called? Any help
would be appreciated. Thanks in Advance.
The ProgressFrame is called from a run method, which is in a class
that implements Runnable. Which is called by creating a new thread.
Here is the code for the ProgressFrame:
public class ProgressFrame extends JFrame {
public ProgressFrame()
{
Container contentPane = this.getContentPane();
URL url = this.getClass().getResource("/Resources/busy.jpg");
Image image = Toolkit.getDefaultToolkit().getImage(url); //new File
("/Resources/busy.jpg");
DrawingPanel panel = new DrawingPanel(image);
contentPane.add(panel);
setTitle("Loading");
setSize(384, 230);
setResizable(false);
setVisible(true);
toFront();
}
}
class DrawingPanel extends JPanel
{
Image img;
DrawingPanel (Image img)
{ this.img = img; }
public void paintComponent (Graphics g) {
super.paintComponent (g);
g.drawImage (img, 0, 0, this);
} // paintComponent
}