Update picture in JPanel

i'm have a picture, i showed it in JPanel, but my picture is change at any time, how i can update new picture on JPanel when my picture is updated
//add picture in JPanel
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
class ImagePanel extends JPanel {
    private Image img;
    public ImagePanel(Image img) {
        this.img = img;
        Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
        setPreferredSize(size);
        setMinimumSize(size);
        setMaximumSize(size);
        setSize(size);
        setLayout(null);
    public void paintComponent(Graphics g) {
        g.drawImage(img, 0, 0, null);
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.rmi.Naming;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
public class ShowClient extends JFrame implements MouseMotionListener{
    public ShowClient() {
        super("Control Client");
        UpdatePicture();
    //this method
    public void UpdatePicture(){
        ImagePanel panel =
                new ImagePanel(new ImageIcon("screen.jpg").getImage());
        JScrollPane scrollPane = new JScrollPane(panel);
        this.setLayout(new BorderLayout());
        this.add(scrollPane, BorderLayout.CENTER);
        scrollPane.addMouseMotionListener(this);
          when mouser move will have a new picture.
    public void mouseMoved(MouseEvent e){
        int x = e.getX();
        int y = e.getY();
        EventServer event = null;
        try {
            event = (EventServer)Naming.lookup("//localhost/Client");
            event.MouseMove(x, y);
        catch (Exception exp){
            System.out.println("Err " + exp);
        UpdatePicture(); //why here my JPanel don't show new picture
    public void mouseDragged(MouseEvent e){
    public void Show(){
        this.setDefaultCloseOperation(HIDE_ON_CLOSE);
        Toolkit tool = Toolkit.getDefaultToolkit();
        Dimension size = tool.getScreenSize();
        this.setSize(size);
        this.setVisible(true);
}Thank a lot of !!
Edited by: bathong on May 23, 2009 10:39 AM

>
If you mean that the image file is updated, you will need to either reload the Image from the file using ImageIO#read(...) or flush() the Image.
When you load the image using the ImageIcon constructor that takes a String parameter, it is cached by Toolkitand will not be reloaded even if the file content changes.
Why create an ImageIcon just to retrieve its Image? Use ImageIO and just load an Image.
db
>
I rewrite as :
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
class ImagePanel extends JPanel {
    public BufferedImage img;
    public ImagePanel(BufferedImage img) {
        this.img = img;
        Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
        setPreferredSize(size);
        setMinimumSize(size);
        setMaximumSize(size);
        setSize(size);
        setLayout(null); 
    public void paintComponent(Graphics g) {
        g.drawImage( img, 0, 0, null);
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.rmi.Naming;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
public class ShowClient extends JFrame implements MouseMotionListener{  
    public ShowClient() {
        super("Control Client");
        UpdatePicture();
    public void UpdatePicture(){
        try { 
            File file = new File("screen.jpg");
            BufferedImage buff = ImageIO.read(file);
            ImagePanel panel = new ImagePanel(buff);
            JScrollPane scrollPane = new JScrollPane(panel);
            this.setLayout(new BorderLayout());
            this.add(scrollPane, BorderLayout.CENTER);
            scrollPane.addMouseMotionListener(this); 
        catch (Exception exp){
            System.out.println("Error here " + exp);
            exp.printStackTrace();
    public void mouseMoved(MouseEvent e){
        int x = e.getX();
        int y = e.getY();
        EventServer event = null;
        try {
            event = (EventServer)Naming.lookup("//localhost/Client");
            event.MouseMove(x, y);
        catch (Exception exp){
            System.out.println("Err " + exp);
        UpdatePicture();
    public void mouseDragged(MouseEvent e){
    public void Show(){
        this.setDefaultCloseOperation(HIDE_ON_CLOSE);
        Toolkit tool = Toolkit.getDefaultToolkit();
        Dimension size = tool.getScreenSize();
        this.setSize(size);
        this.setVisible(true);
}but new picture also can't update!! please help me, thank !!!!

Similar Messages

  • Exception has been thrown by the target of an invocation error while updating picture in user Profile

    Hi,
    I am working on updating picture of user profile in sharepoint 2013.
    I am getting error "exception has been thrown by the target of an invocation" while creating Thumbnail at the below line.
    "file = (SPFile)mi_CreateThumbnail.Invoke(null, new object[] { original, idealWidth, idealHeight, folder, fileName, null });"
    I have added SPUtility.ValidateFormDigest() before calling this method. but no luck.
    Please help me on this.
    Thanks
    Hareesh

    Hi,
    According to your post, my understanding is that you want to update picture in user Profile.
    If we are giving an option to change the Profile picture in our custom component, we need to create 3 different files and update the reference in User Profile property.
    To create Thumbnail, we can use the code as below:
    /// Get sealed function to generate new thumbernails
    public SPFile CreateThumbnail(Bitmap original, int idealWidth, int idealHeight, SPFolder folder, string fileName)
      SPFile file = null;
      Assembly userProfilesAssembly = typeof(UserProfile).Assembly;
    Type userProfilePhotosType = userProfilesAssembly.GetType("Microsoft.Office.Server.UserProfiles.UserProfilePhotos");
      MethodInfo [] mi_methods = userProfilePhotosType.GetMethods(BindingFlags.NonPublic | BindingFlags.Static);
      MethodInfo mi_CreateThumbnail = mi_methods[0];
      if (mi_CreateThumbnail != null)
        file = (SPFile)mi_CreateThumbnail.Invoke(null, new object[] { original, idealWidth, idealHeight, folder, fileName, null });
      return file;
    Then we can invoke the method as below:
    using (MemoryStream stream = new MemoryStream(buffer))
    using (Bitmap bitmap = new Bitmap(stream, true))
    CreateThumbnail(bitmap, largeThumbnailSize, largeThumbnailSize, subfolderForPictures, accountName + "_LThumb.jpg");
    CreateThumbnail(bitmap, mediumThumbnailSize, mediumThumbnailSize, subfolderForPictures, accountName + "_MThumb.jpg");
    CreateThumbnail(bitmap, smallThumbnailSize, smallThumbnailSize, subfolderForPictures, accountName + "_SThumb.jpg");
    More information:
    Update User Profile picture programmatically in SharePoint
    Upload User Profile Picture programmatically in SharePoint 2013
    Upload User Profile Pictures Programmatically – SharePoint 2013
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to Update Picture column in User Information List?

    Hi,
    The user updated his profile picture in mysite about 10 days ago. The updated picture is shown on his mysite but the same is not in sync with User Information List. The 2 timer job which takes care of the profile synchronization are scheduled as below:
    Profile Synchronization : hourly
    Quick Profile Synchronization : every 2 minutes
    And both the timer job status are shown as successful, yet the picture url is not updated.
    Can anyone kindly let me know is there any way to update the same manually.
    Please note that the version of SharEPoint is 2007 and Windows server 2003.
    Thanks in Advance.

    Hi Sheetal Lomate,
    It is correct to check the profile synchronization jobs to make sure profile information syncs between user profiles and user information list.
    If it is still not synced, please use the following stsadm command:
    stsadm –o sync –listolddatabases <x number of days>
    If one or more content databases show up in this list, clean up the list, they can be added to the list again:
    stsadm –o sync –deleteolddatabases <x number of days>
    Related reference:
    User Profiles and User Informtation list synchronization:
    http://www.sharepointchick.com/archive/2009/06/17/user-profiles-and-the-user-information-list-or-userinfo-table.aspx
    Thanks,
    Qiao
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Qiao Wei
    TechNet Community Support

  • Apple tv3 runs slowly on all apps in the box,after the last update.Picture sometimes runs slowly on netflix ,and all the apps in the apple tv3 box.But the sound is ok.Anyone else have this problem?

    Apple tv3 runs slowly on all apps in the box,after the last update.Picture sometimes run's slowly on netflix ,and all the apps in the apple tv3 box.But the sound is ok.Anyone else have this problem?I have a 20Mbit wireless line,but i had put a cable from my router to my apple box,but it did not help.

    Are you using a home network?
    Try the following :                 
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on the router
    - Reset network settings: Settings>General>Reset>Reset Network Settings

  • Save Picture From JPanel

    I want to know how to write JAVA Program like Paint Brush. I build GUI completely but
    I have Problem about Save Picture form JPanel(Save to .JPEG, .GIF) Please suggest me example code or website about this.
    Thank for your Suggestion

    Look into the javax.imageio package.
    There is even a small tutorial for ImageIO in the docs for the SDK. Go to the main index-page of the SDK-doc and look for ImageIO (filed under Java Foundation Classes)

  • After I updated, pictures has gotten a yellow tint where it should be white.

    after I updated, pictures has gotten a yellow tint where it should be white. I checked the same websites in safari, and those sites shows perfect color.
    What can I do to fix this issue?
    Being a photographer, this is quite a big problem

    You are on Windows 2000, you do not have a "Firefox" button, and should consider yourself to be fortunate in that you still have menus and don't have to do anything to get the menus back instead of the "Firefox" button. (The same applies to Windows XP users).
    Use the "File" menu to get to Import. You are not on Windows 7 or Vista, and don't have to put up with the nonsense added for Aero.
    If you want the "Firefox" button you can get it with View -> toolbars -> (uncheck) Menu Bar. The menu bar and the "Firefox" button were supposed to be mutually exclusive (which is impossible in some cases without being incompatible).
    Once you are using the "Firefox" button ...
    Use the "Alt" key to view the menu bar (temporarily) containing File, Edit, View, History, Bookmarks, Tools, and Help. On Windows 7 and Vista, the menu bar was hidden by default in Firefox 4 and above. These menu items are more or less available under the "Firefox" button which has the most used of the built-in Firefox menu items available in a different format.
    To get back to having menus again. "Firefox" button -> Options (second column) -> (check) Menu Bar
    You can make '''Firefox 7.0.1''' look like Firefox 3.6.*, see numbered '''items 1-10''' in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 thru 8.0, look like 3.6)]. ''Whether or not you make changes, you should be aware of what has changed and what you have to do to use changed or missing features.''
    * http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface

  • Blog Summary Page Does Not Update Picture

    For some reason, when I create a new blog entry by duplicating the last one and adding new content, the Blog Summary page will not update the picture. I sometimes either have to create a new blank blog entry, or drag a different picture into the placeholder, followed by my original.
    Is this happening to anyone else? I think I am going to finish out my year-long blog project with iWeb/MobileMe, then drop both! This is getting to frustrating.

    LawsonStone wrote:
    Is this happening to anyone else?
    Perhaps to this person:
    _blog summary didn't show the pictures_.
    LawsonStone wrote:
    I think I am going to finish out my year-long blog project with iWeb/MobileMe, then drop both! This is getting to frustrating.
    A wise move — problems with iWeb's blog are a recurring theme on these forums: Lost all blog entries or all comments or unable to publish, etc. If you switch to a dedicated blogging platform you're likely to have a better experience. For a success story using a non-iWeb blog hosted on WordPress, see this old thread:
    _To blog or not to blog_

  • Update picture slows down

    Hi
    I am trying to make a little robot that can draw a 2D map of the suroundings. (It uses a rotating distance sensor, like af radar)
    I whant to use the picture-control, to draw in the information, so i can get a printable picture out. I have already created a "picture-radarbeam" that reprecents one meassurement in the picture, and it works just fine.
    So, the problem is then i try to put the picture in a while-loop and i want the program to sketch the measurements all the time (I mean updating the picture canstantly). Short after it starts, its slows down dramaticly (It seams like it reamember all the preavues sketches, and sketch them all every time the picture updates.). I tried to solve the problem by write the pictue to a image-file, and then load it again to a picture-string, but that is also a very slow solution.
    Any sugestions?
    Best reguard
    Steffen Rasmussen - Danish Univerity of Science
    LabVIEW 2009 and 2011 user, with LabVIEW toolkit for Lego Mindstorms NXT.

    Yes, the right way would be to NOT use a shift register and uncheck "erase first?"
    This should work well assuming that all parts of the image are being overdrawn with new data as a new data arrives. That's why I wanted to see the code.
    LabVIEW Champion . Do more with less code and in less time .

  • IPhoto 6.0.4 new won't update pictures permission error

    I am still using 10.3.9; just got iLife 6.0; installed fine. Did whatever updates allowed to me. Trying to open iPhoto; as usual, goes through the updating process to all photos. here's where it gets interesting.
    I am the only user on this computer. I am the admin.
    iPhoto says that there are permission issues and to go into the iPhoto pictures folder and allow read and write. I did that. nothing. So then I went back and went folder to folder ensuring all were okay. All fine.
    Nothing.
    I can't sit here and check all of the 1000s of pictures to see which one is somehow not correct on permissions. Is this a glitch? Am I missing something? its never done this on all of the previous upgrades. Little help from you old pros

    Carl:
    Try the following: download and run BatChmod on the iPhoto Library folder with the settings shown here, putting your administartive name in the owner and group sections. You can either type in the path to the folder or just drag the folder into that field. That often works where just the Info window does not.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.

  • Ios 6 update picture of a battery on screen

    My Ipad 2 is trying to update to the Ios6 and the screen has a picture of a battery on it that is partially red, but it is hooked up to my computer to do the download.

    The Statusbar is gone and the "lock" with it. Security information about a web page is shown by the Site Identity Button.<br />
    https://support.mozilla.com/en-US/kb/Site+Identity+Button
    You can add a padlock to the location bar with the Padlock add-on- https://addons.mozilla.org/firefox/addon/padlock-icon

  • IPhoto 6.0.6 update picture thumbnails

    I had my camera hooked up to my Mac. When I opened up iPhoto for the second time, I had to update the thumbnails. The camera had a few pictures on it and iPhoto made thumbnails for those pictures. But not for the pictures from our last few years. The pictures are there, but no thumbnails. How can I make thumbnails for these pictures?

    Would it help if I deleted iPhoto 6.0.6 from my Mac, and put iPhoto 6.0.5 and see if I can look at my pictures?
    No.
    The issue is not with the iPhoto application but with your Library. Changing the application will not change the Library.
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.
    Regards
    TD

  • IPhoto does not update pictures

    Any pictures I change in an external editor, I saved it as the orginal file would update in iPhoto, i.e. the picture would change to reflect the changes.
    In 6, it does not, if you select it and go full screen the corrected image will show, but in the main window it remains as the old picture.
    Is there a fix for this?

    Gary:
    To have iPhoto recognize edits made my a 3rd party editor like Photoshop Elements you must set iPhoto's preferences (in the General section) to open that 3rd party editor when you double click on the thumbnail. Then if you edit and save with the same file name and extension iPhoto will recognize the edit, both in the media window and in the thumbnail window. If you create a layered file or do an edit that requires a different extension you must either flatten the file and save in the original format or save to the desktop and import the new file.
    If you want to have both the 3rd party editor and iPhoto's without having to go into the preferences each time just set the preferences back, to edit in the main window. Then when you want to use the 3rd party editor just Control-click on the thumbnail and select Open in external editor from the drop down menu. That way you can have the best of both worlds.

  • CS4 doesn't update picture when adjustment layers are changed

    Basically the problem I have after just downloading CS4 is that, other than loving the improvements to the program, I'm irritated by the fact that I can't see the effect of any adjustments I make in the layers pallete until I click on the actual picture, or zoom it in or out.  Occasionally it will update on it's own but most of the time not.  Anybody ever had this problem?  Could it be related to the GPU thing -- maybe need new drivers?

    Well, I updated to the latest ATI driver and it still does the same thing.  It live-updates when I'm making adjustments in say a curves or levels or any other adjustment dialog, but the real problem is, if I turn a layer on or off I have to then either zoom or click the image to see the current status.  As I said earlier, very irritating when you're trying a bunch of different adjustments then want to turn off one or the other to quickly see the difference.
    Paul

  • Updating components in jpanel

    Hi, all
    I have a report application which will update me system utilization in several jpanel. Those panels stored in a hashtable and I programmed it refresh each 5 minutes. Here is how I do it.
    Step 1: remove all
    mypanel=(JPanel)panels.get("1");
    mypanel.removeAll();
    mypanel.validate();
    Step 2: show progress
    mypanel.add(<updating message in jlabel>);
    mypanel.add(<a progressbar>);
    mypanel.validate();
    Step 3: add new content
    mypanel.removeAll();
    mypanel.add(<a graph in jlabel>);
    mypanel.add(<a jtable with data>);
    The problem is the old content still remains when progress bar appeared. Didn't I just remove all components in step 1? How can I have a empty panel with only progress bar?
    Thanks,
    Vincent Chen

    Damn, I found what the problem is, but if I gave the solution to the OP, that would mean confessing I have followed the link, and admitting to belong to the "not worth mentioning" category!Well, since my cover's blown anyway, let's caugh it up:
    Your have an attrubute searchType of type SearchType, you initialize it to reference a new SeearchType() , and you use its status for the search, however you never add the instance in the panel's widget hierarchy. Instead you add a new SearchType() .
    Same for attribute style :
    searchType = new SearchType();
    style = new Style();
    this.add(new SearchType(), c);
    this.add(new Style(), c);
    // in event handler
    search(txfQuery.getText(),searchType.getSelected(),style.caseSensitive(),limitation.getLimNum());
                                    ^
                                    *At this point, the instance referenced by searchType has never been displayed, so the checkbox, combobox, and whatnot that the user has interacted with are not the ones whose state you read.

  • Update picture for a user using powershell

    Hi,
    Is it possible to update a update a user profile picture using powershell?
    Thanks
    nish

    Hi,
    in your case it should be : 
    $profile["PictureURL"].Value = "http://dspm07pics/Userpics/andreas_seitz.jpg";
    Mourad

Maybe you are looking for

  • Can I return my refurbished phone?

    I lost my phone some I ordered a refurbished phone through the Verizon store. Later that day someone gave me their old Verizon phone, which I would rather use. Can I return the refurbished one they just mailed me and have them activate the phone my f

  • Order of values passed to ODCIAggregateIterate

    I have implemented my own aggregate function that concatenates varchar2 values together. It works perfectly, however, the order of the aggregated data is inconsistent and does not match the order that it occurs in the table the aggregation is over (

  • Name of database connected to this application server

    dears , i have Oracle Application Server 10g (10.1.2.0.2) i want to get database UNIQUE_name that is connect to this application server !!! i run this command SELECT sys_context('USERENV', 'DB_UNIQUE_NAME') FROM dual; it gave me name of application s

  • Need help with adobe flash player 10.2 keeps crashing

    ok i am having a problem with the adobe flash player ten it keeps crashing on firefox ie8 and google chrome operating system is windows xp  32 bit really need help because this has been going on for 3 weeks straight  and i downloaded the adobe flash

  • 9ir2 on Debian Woody installation hints (when dbca fails)

    "Woody" is the soon-to-be-released Debian 3.0, and contains glibc 2.2.5. The current 'stable' Debian release, Potato, has glibc2.1, so that won't work. The installation went fairly smooth, until the configuration assistants were supposed to be fired