Results 1 to 5 of 5
Thread: why my image is not updated ?
- 08-14-2008, 10:34 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 46
- Rep Power
- 0
why my image is not updated ?
This code does not work.
public void paintComponent(Graphics g) {
img = Toolkit.getDefaultToolkit().createImage(bMconnecti on.getNextImage());
i++;
g.drawImage(img,5,20,this);
g.fillOval(i, i, 10, 10);
repaint();
}
The testing oval works but my image is not displayed. why ?
If I move the first line outside of the paintComponent method it works but i can capture only the first frame of the video..
should I use another method instead of to create it each time ?
- 08-14-2008, 10:38 PM #2
Do not load images in the paintComponent method. Load them into a collection or array at construction and access them in/from the collection/array as needed in the painting code.
- 08-14-2008, 10:41 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 46
- Rep Power
- 0
I have a camera streaming, and I need to update the image in loop. How can I do this outside the paint method ? should I implement a thread ?
The problem is the code works only if
img = Toolkit.getDefaultToolkit().createImage(bMconnecti on.getNextImage());
is in the panel constructor...
thanks
- 08-14-2008, 11:36 PM #4
Put the loading on its own thread and call repaint() after each image is loaded.
-
Similar Threads
-
Number of updated records
By Java Tip in forum Java TipReplies: 0Last Post: 01-21-2008, 04:32 PM -
How to accurately test if timezone data is updated?
By Santhosh in forum Advanced JavaReplies: 0Last Post: 11-14-2007, 06:53 AM -
Updated Forum Rules
By levent in forum Suggestions & FeedbackReplies: 1Last Post: 08-12-2007, 01:09 PM -
need restore Look and Feel of application back to1.4 when jre is updated to jdk 1.6
By praveenrn in forum AWT / SwingReplies: 7Last Post: 08-11-2007, 09:44 PM -
JTextArea that I would like to have updated as strings are appended
By paul in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 05:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks