Results 1 to 8 of 8
- 04-01-2009, 11:34 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 8
- Rep Power
- 0
-
you may wish to post your code that's doing the refreshing. Most of us are terrible at guessing what your problem is without pertinent code.
- 04-02-2009, 01:33 PM #3
Member
- Join Date
- Apr 2009
- Posts
- 8
- Rep Power
- 0
My code snippet is:
Java Code:public void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Timer timer = new Timer(3000, new ActionListener() { public void actionPerformed(ActionEvent e) { String comp =(String)jComboBox1.getSelectedItem(); ImageIcon ii = new ImageIcon(comp+"resized.jpg"); JLabel lab = new JLabel(); lab.setIcon(ii); jInternalFrame1.setTitle(comp); org.jdesktop.layout.GroupLayout jInternalFrame1Layout = new org.jdesktop.layout.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 300, Short.MAX_VALUE) .add(lab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 333, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(0, 240, Short.MAX_VALUE) .add(lab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) ); jInternalFrame1.setVisible(true); jInternalFrame1.revalidate(); jInternalFrame1.repaint(); } }); timer.start(); }
- 04-04-2009, 05:04 AM #4
Aw, c'mon. What's your problem, that you don't know what code is pertinent to your problem or that you don't care? You post a whole lot of GroupLayout code that has nothing to do with loading and displaying images, and only one line that IS possibly related to the problem, that too without a hint of what might be contained in the variable "comp" and where and how (and whether) the variable is updated.
I will say this however: if you're trying to reload the SAME image file (which is concurrently modified by some other means) in your running program, then the behavior you describe is expected, as the ImageIcon constructor that takes a String parameter loads the Image via Toolkit, which caches the image and doesn't load it from disk repeatedly.
If that guess is correct, you have two options:
1) Load the image via ImageIO#read and use the ImageIcon constructor that takes an ImageORJava Code:Image image = ImageIO.read(new File(comp+"resized.jpg")); ImageIcon ii = new ImageIcon(image);
2) Invoke the flush() method on the ImageIcon's Image whenever you want it to update from disk.In the second case you don't need to setIcon on the label repeatedly, but you may need to invoke repaint().Java Code:ImageIcon io = new ImageIcon(comp+"resized.jpg"); // once only : : // to reload the image from disk io.getImage().flush();
I would also recommend that you learn to code your own layouts, relying on a visual designer to do everything for you severely limits what can be done.
db
- 04-04-2009, 09:01 AM #5
Member
- Join Date
- Apr 2009
- Posts
- 8
- Rep Power
- 0
Thank you very much. Now my code is displaying refreshed image.
- 04-04-2009, 09:12 AM #6
Member
- Join Date
- Apr 2009
- Posts
- 8
- Rep Power
- 0
Hello,
Now the problem is i am using six of this kind of function in my program.So at a time only one image refreshing in the internal frame and others are not working. Also the layout of whole program disturbs. What should i do?Sometime blank image also appears in frame. I am using another program for updating image in the folder.
- 04-05-2009, 12:15 PM #7
Member
- Join Date
- Apr 2009
- Posts
- 8
- Rep Power
- 0
Can anyone got the solution. Please help.
-
Similar Threads
-
Repositioning An unwanted JInternalFrame
By marco.c84 in forum AWT / SwingReplies: 8Last Post: 03-18-2009, 09:42 PM -
Problem with JInternalFrame
By hameem in forum AWT / SwingReplies: 1Last Post: 12-11-2008, 04:23 PM -
setting the view to a jsp page from a self refeshing page
By deepal_205 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 08-15-2008, 04:41 PM -
[SOLVED] jScrool in JInternalFrame
By gustio in forum New To JavaReplies: 2Last Post: 07-22-2008, 10:05 AM -
Converting multiple banded image into single banded image... Image enhancement
By archanajathan in forum Advanced JavaReplies: 0Last Post: 01-08-2008, 05:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks