JPEG File Preview in a panel

Hi All
I had a need to give a preview of a jpeg or a bitmap file selected in a file chooser.
i created a panel and set the image selected as imageicon of the panel.
This works well except for the files which are named as "DSC0231" or "IMG_089"
i have no idea as to what is wrong...
can anyone guide me?

public class ImageBrowser {
private File selected;
     public ImageBrowser(File selected) {
          this.selected=selected;
new AppFrame(this.selected).setVisible(true);
class AppFrame extends JFrame {
private ImageCanvas canvas = new ImageCanvas();
File chosen;
public AppFrame(File selected) {
     String new_file=selected.toString().replaceAll("\\\\","/");
     chosen=new File(new_file);
     System.out.println("inside the new one:"+chosen.getAbsolutePath());
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setTitle("My APP");
setSize(500, 500);
this.setLocation(100, 100);
initFrame();
onOpen();
private void initFrame()
JScrollPane scrollPane = new JScrollPane(canvas);
setContentPane(scrollPane);
protected void onOpen()
if (chosen != null && chosen.exists() && chosen.isFile())
     System.out.println("inside the new one:"+chosen.getAbsolutePath());
try
     String file_path= chosen.toString();
//ImageIcon icon = new ImageIcon(chosen.toURL());
ImageIcon icon = new ImageIcon(utils.loadbitmap(file_path));
canvas.setImageIcon(icon);
                    getContentPane().validate();
setTitle(chosen.getName());
//this.setSize(icon.getIconWidth(), icon.getIconHeight());
catch (Exception e)
setTitle(e.getLocalizedMessage());
* Canvas for displaying images.
class ImageCanvas extends JPanel {
private ImageIcon imageIcon = null;
private Dimension size = null;
public ImageCanvas()
setBackground(Color.white);
public void setImageIcon(ImageIcon icon)
this.imageIcon = icon;
if (icon != null)
     System.out.println("hello");
size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
repaint();
public ImageIcon getImageIcon() {
return this.imageIcon;
public void paint(Graphics g) {
super.paint(g);
if (imageIcon != null) {
imageIcon.paintIcon(this, g, 0, 0);
public Dimension getPreferredSize() {
if (imageIcon == null) {
return super.getPreferredSize();
} else {
return size;
that is the code i found somewhere to do the job... and while calling,
File selected = new File(selected_file);
new ImageBrowser(selected);
meanwhile is there any limitation on the size of the image for an imageicon??
i mean the number of pixels??
thanx

Similar Messages

  • How do I programmatically display jpeg files on the front panel

    Hi,
    I would like to be able to programmatically display various jpeg images on the front panel of a VI. I would mostly like to be able to display one image at a time and have the ability to programmatically change the image to different ones under program control. I found a picture indicator but not sure how to use if or if this is the best way. Thanks for any help.
    Dave Adams

    Yes, you can use a picture indicator.
    The attached simple codelet shows how to display a jpeg image on it (Make sure the image indicator is big enough).
    Let us know if you need help with the rest of the coding.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DrawJpeg.gif ‏2 KB

  • In PSE 13, when I open a folder, jpeg files have a preview image, but PSD, DNG and CR2 files don't. Also, no thumbnail below the file list.

    Working in PSE 13, when I open a folder, jpeg files have a preview image, but psd files just have white sheet of paper as preview.  I have to open the file to be able to see it.  Also, there is no thumbnail of the file below the file list.Surely, there's a setting that needs to be changed. I did not have this problem with Elements 12. This is a real bother because I have to use Lightroom to see all the file types. It seems as if Elements is using the standard Windows file loader that can't show previews of file types it doesn't know including .PSD, DNG and CR2. Is that a bug or did I do something wrong? Thanks for any help.

    I am using Windows 7 64 bits. Working in the editor, I never use the organizer. The screen above is not the same at all that I got in Elements 12, it was completely different and showed me a thumbnail below the listing when I single clicked on one of the files. In Elements 12, I also could see  a thumbnail of all the file types, not only the jpegs. It is as if the loader is the regular Windows used anywhere, not the right one for Elements. I hope someone understands my problem.. Thanks.
    Mike

  • Why having displayed both generic icons for the PDF and JPEG files and automatic preview of the JPEG files in an ordinary folder are mutually exclusive in Win7?

    In Win7 Pro all my:
    PDF documents, with the 'Large Icons' option chosen in the View tab, display contents of their first page with a tiny thumbnail in the icon's lower right corner, instead of a generic PDF icon.
    JPEG files show Icon size photos, instead of a generic Nero 9 PhotoSnap Essentials icon.
    Folders containing the JPEG photos, however, automatically show preview, when opened, which is desirable feature.
    I found that the Win7 option "Always show icons never thumbnails" in the View tab: Windows Explorer -> Tools -> Folder Options, (where ironically the present 'thumbnails' have nothing to do with 'Thumbnails' from the View option in WinXP), causes the unwanted effects described in points 1 & 2, when unchecked.
    Checking this option solves the problem of the PDF and Nero icons. This time, however, I can only see a Nero 9 PhotoSnap Essentials icons, instead of photos preview on opening of any standard folder with the JPEG photos.
    Did I make a mistake somewhere or maybe Microsoft made changes in Win7 with respect to WinXP, which make it impossible to have both the features working at the same time?

    Hi,
    You can install the Win 8.1 software drivers using this link.
    http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?cc=us&dlc=en&lc=en&product=4323648&task=&
    Once installed, it should have the same features as the Win 7 drivers for scanning.
    Please click the “Kudos Thumbs up” on the left if this has helped you and “Accept as solution” if this has helped solved your problem.

  • Show preview/filial JPEG file

    one more :-)
    I know, I can import images with the JPEGs handled as seperate images. But this is not what I usually want. I would however like, to see the original image produced by the camera. At least a command to add the JPEG file into the stack and remove it as "filial file" so one could see and work with it.
    It makes sens for me to see the original JPEG as reality link when working with images. Current cameras also produces quite acceptable images from the start, so it is a bit of a loss to just hide them.
    Julian

    Might try this ueli...
    Safe Boot , (holding Shift key down at bootup), it will try to repair your Disk Directory while the spinning radian is happening, so let it go, run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, try trashing this file...
    /Users/YourUserName/Library/Preferences/com.apple.Preview.plist
    Reboot. Set up Preview Prefs again.

  • Extracting JPEG files from Adobe Lightroom previews

    I need to figure out how to extract previews from Adobe Lightroom as JPEG files.  I am trying to develop an external app that will read Lightroom's plugins - I need to do it in either C++, C# or Java.  So far all examples I found were in Lua.  Any help/code examples would be greatly appreciated.

    I think he is looking for C/Java code, not a script/plugin.
    In any case, anybody looking to recover previews should be aware that most plugins or external apps DO NOT assign a proper ICC profile to the extracted previews. The extracted previews are *usually*, meaning NOT ALWAYS AdobeRGB, but untagged: will be interpreted as sRGB. Yeah, that's why they will look different than the original.
    I don't know about JF's plugin.
    (Adobe's recovery script does NOT handle ICC profiles correctly).
    PreviewExporter is the only plugin I know of that handles ICC profiles properly - if anybody knows how JF's plugin handles ICC profiles - do tell.
    Note: PreviewExporter includes source code - it should be straight-forward to translate to C/Java.
    Rob

  • I'm using OSX 10.7.4 how do I convert gif files to jpeg? Preview does not have a "save as" choice.

    I'm using OSX 10.7.4 how do I convert gif files to jpeg? Preview does not have a "save as" choice.

    GraphicConverter (the best shareware ever devised for the Mac) will do this for you:
    http://www.lemkesoft.com/

  • Save failure while editing jpeg files in Preview

    I edited some jpeg files in Preview but when I saved them they were converted to "Unix Executable Files." Why and is there any recovery method?

    All this stuff moved under TOOLS. Except the stuff under COMMENT. For instance, insert pages is under the PAGES section of TOOLS. For some reason Adobe thought this would be easier for us all.

  • Preview cannot save after modified a jpeg file

    I open a jpeg file by using preview. After I crop the same image, preview does not allow me to save with the same image name, another name or even duplicate it.

    Not a preference thing.
    You can close the open document you saved the jpeg from without saving it. Then open the jpeg image saved from it.  If the layered image was never saved there will be no PSD file on your system for the layered state.  If you Flatten a new layer document  before saving it as a jpeg file. During the course of the save as jpeg the jpeg images file will become the backing file associated with the open document and the current document name should change from un-named or whatever to the filename.jpg you just saved.  New documents have no backing file till they are saved to disk.
    If you open a jpeg file and add layers the document becomes layered jpeg does not support layers so Photoshop would want to save a layer document as a layerd file.  If you flatten before the save. Save would default to replace the jpeg file currently backing the opened modified and flattened document.

  • Finder crashes when previewing JPEG files

    My finder just crashes when I use the finder in Column or Coverflow modes. It happens not with all jpeg files but I can't find a pattern here. When I open those same files with Photoshop CS3, Lightroom or Bridge CS3, they open without any problems.
    The info I get on the "log" is the following (very helpfull indeed):
    08/01/31 07:20:56 Finder[117] * _NSAutoreleaseNoPool(): Object 0x1601cad0 of class NSCFNumber autoreleased with no pool in place - just leaking
    Stack: (0x9224727f 0x92154962 0x938f1b4f 0x938f18c0 0x2dcc7f 0x2dcdb9 0x9cd0 0x91a40075 0x91a3ff32)
    Can somebody help? I've read that this may be a problem associated with files opened with photoshop or lightroom...

    Try installing the Mac OS X 10.6.8 Update Combo
    Then restart your Mac.
    It's ok to do this even though you are already running v10.6.8.

  • How to view .jpeg files in Yosemite

    Am using Yosemite (10.10.2) on my iMac and want to view rather old .jpeg photos. When I attempt to open them, I get an error message saying Photoshop 3.0 is required. When the file titles are displayed in Finder, I can see the little-bitty picture, so I think the Mac knows the picture is there, just reluctant to let me view it.  (I tried using Preview and iPhoto and neither one works for this.)
    Is there some way to view these photos with the existing Mac programs?
    Thank you,
    TBS2

    Thanks for all the replies. I tried to respond to everyone individually, but the rules say I can only post content every 30 seconds. Hence this combined reply.
    Don't have "Quick Look" on my iMac. I did use the "Get Info" option to open all .jpeg files with Preview. Didn't work. Did try to open the files from within Preview using the "Open file" option.
    Tried opening with Firefox (thanks to whomever posted that hint somewhere on the blog) and the Firefox error message says there is an error in the file.
    I am able to open other .jpeg files with Preview, so I am now of the belief there is a problem with the file, not with how my system is handling it.
    Suppose a "fixer" of some kind is in order, but I don't know what that is!
    Thanks again for everyones help.
    TBS2

  • How can I use a JPEG file as a background image for my vi in 8.5

    Im working on a vi that I plan on using as part of an alarm system.  I would like to use a JPEG file of my house as a background image for the vi, or possibly to just be displayed in a window on the control panel.  I have seen people use their own images before, but never looked at what this involved.
    Im trying to use the "read JPEG file" vi and the "draw flattened pixmap" vi to accomplish this.  The vi does run, but nothing shows on the front panel.  If I try to create an indicator from the "new picture" output of the "draw flattened pixmap" vi, I get an empty white window on the front panel.
    Any advice?
    Thanks
    Solved!
    Go to Solution.

    Guruthilak wrote:
    the earlier vi (using the JPEG) works fine. just increase the size of the picture control
    I figured this was the problem. And to the OP, I'm glad a bitmap worked, but no I didn't mean use any sort of LabVIEW programming at all. I meant open your image in Microsoft Paint, Press ctrl+A to select the whole thing. Then copy the image to the clipboard. Now select your front panel and press ctrl + v to paste it. No programming needed and the image is there. However, if you want to programmatically change it, you will need a picture control.
    CLA, LabVIEW Versions 2010-2013

  • JPEG Files in Premiere Getting Mixed Up Within a Project

    JPEG files loaded into my project are getting mixed up.  It's like Premiere can't tell the loaded files apart. That is, I load several JPEGs in to the project, each with a different file name, put them onto the Timeline, and, later, when I click on the file name in the Project panel, several of the different files display the same image of one of the JPEGs in the Poster Frame, the Source Frame, and in the Project Sequence.   The file names remain listed in the Project panel continue to show the correct file name, but several show the same image when selected. 
    I assumed something happened when the files were Imported and were now confused in the project.  To try to fix this, I Cleared all of the bad files off the Timeline and out of the Project panel.  Changed the source file names in Windows Explorer (i.e., added an "a" to the file name) and re-Imported the files into Premiere.  It seemed to work, but a little while later, some of the same files, plus some newly Imported files, all turned to the same image again.  I again repeated the Clearing process for the bad files, changed the source file names once again in Windows Explorer, changed the Folder name in Explorer, and again re-Imported the files into Premiere.  Again, after a while several of the files all had changed to the same image on the Timeline, the Poster Frame, and the Source Frame.
    It's like the program has somehow mixed these files up and, whatever caused the mix up, remains persistent even with files that have been renamed.
    This happens to approximately 20 JPEGs out of perhaps 70 JPEGs in the Project.  It has not happened on any previous projects.
    I can't tell if my Premiere (5.0.3) has become corrupted somehow or if this error is limited to this one Project.  Is there a way I can transfer my work into a new project (I really don't want to have to start completely over).
    I'm fairly desperate.  Thanks!
    --Dave

    See this thread for a workaround:
    http://forums.adobe.com/message/3684577#3684577
    This bug has been fixed in Premiere Pro CS5.5.

  • Time Machine - AppleXsoft - file preview and support

    Deleted an external drive while trying to install Time Machine. Ran AppleXsoft but downloaded several thousand Jpegs and movies to desktop.  Can't file preview like the software says because they say the file isn't suporte and my emails [email protected]  keep bouncing back.  Anyone been down this road?  I have a Macbook Air.

    aschmid wrote:
    Yes you are right, I know it isn't supported - as so many other things but they work!
    This one is notorious for working for a while, then . . . not.
    In addition to the problems above I got a pop-up from Time Machine saying the backup file is broken and it needs to create a new one. I told it to go ahead and what happened is that it actually proceeded to DELETE the old backup file before creating a new one - there goes my several months of backup history!
    Yes, just as it says in the message. See #C13 in [Time Machine - Troubleshooting|http://web.me.com/pondini/Time_Machine/Troubleshooting.html] (or use the link in *User Tips* at the top of this forum).
    All I can say do now is connect my drive directly to my iMac and figure out a way how I can backup my other iMac and the MacBook I have. On the AE this just worked remotely.
    Yeah. Until it didn't.
    Really not much options here to backup a home with 3 Macs!?!
    Sure there is. Back the others up to the same drive, over your network, via sharing. See #22 in [Time Machine - Frequently Asked Questions|http://web.me.com/pondini/Time_Machine/FAQ.html] (or use the link in *User Tips* at the top of this forum), for details and setup instructions.

  • Bridge CS3 not writing metadata to JPEG files

    For the last couple of months (without my noticing until a couple days ago) all JPEG files that I have edited using Bridge CS3 (on Windows XP) do not have the metadata built into the file. Here are the symptoms: use "File Info" to edit the metadata for a JPEG file (i.e. add a title, description, copyright info, etc.), all appears normal, but if you do any of the following, the metadata you entered disappears:
    - duplicate (the metadata does not exist in the duplicate file)
    - move or copy to another folder
    - open in Photoshop or any other software that can read metadata (File Info shows none of the metadata you entered)
    - rebuild the cache for the folder
    Strangely, the metadata still appears with the file when you look at it in Bridge as long as you don't do any of the above.
    This is really awful as I've put a lot of time into entering this metadata for hundreds of files. Older files (pre-Nov 08) don't have this problem and the metadata is "sticky" and doesn't get deleted. So, somehow my Bridge CS3 got corrupted along the way.
    Has anyone experienced this and more importantly -- do you have a solution? I've tried reseting all Bridge settings (but that of course purged the cache and deleted all my metadata.)

    Hey,
    There are various date/time fields shown in properties panel in Organizer. The dates mentioned in general section are read from OS whereas the dates in EXIF field are read from image's EXIF data. In EXIF data there are three date/time fields-
    1. Date time- This date/time info shows date modified of EXIF properties. So when you are writing a tag into imags's IPTC, you are doing some change in EXIF data. Hence this date should change to date when you are writing a tag into IPTC.
    2. Date time original - Represents date time when a image was shoot.
    3. Date digitized - Represents the date when the image was digitized (in digital camers there is hardly some delay between an image is shoot and it is digitized. So this field is always same as date original).
    So, in your scenario, Date time in EXIF should change whenever you are writing any tag into its IPTC.
    Please let me know if you need more info on it.
    ~Andromeda

Maybe you are looking for

  • If I deposit money into my bank account will it let me download more apps?

    Basically I bought about 4 songs and a game on Monday I didn't know how much was in my bank account and well, since Wednesday I've not been able to buy anymore apps or songs etc. It says: "there is a billing problem with a previous payment. Please up

  • RMI example just doesn't work (jdk1.5.0_01+jdk1.5.0)

    Hi! RMI example from the "Getting Started Using Java RMI" (http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html) doesn't work. Everything compiles fine , but when starting server with a command: java -classpath test example.hello.Serv

  • CS4, what are the most pressing issues and are they solved ???!!!

    I'll be visiting the Adobe booth at the IBC on the 15-th to have a sneak preview of CS4. To properly report back what I have seen, I need a short list of the most pressing issues and what interests you most to see solved or added. Just to name a few

  • Howto Export key from J2ME keystore

    I have generated a keypair with the J2ME WTK Sign MIDLet GUI tool, so the key is in the default WTK keystore (_main.ks). I need to get the key into a J2SE keystore so that I can use the keytool utility to manage the key and a certificate. How can I e

  • Proxy settings for installing TREX

    hi all while installing TREX server it is asking following settings <b>Proxy Server Name</b> <b> Proxy Server Port</b> <b> Proxy User Name</b> <b>Proxy User Password</b> is the above settings are mandatory for installing TREX if so,wht info i've to g