Method to load images while blocking thread

Hi!
I'm new to Java and have been researching how to do the following for hours with no real success:
I need a way to load an image (jpg/gif/what have you) while blocking the thread it is running in.
I do not really want to use MediaTracker because it feels much too complicated for what I need. Here is a code snippet:
private Thread getImages = new Thread(
          new Runnable(){
               public void run() {
                    while(!imgNameList.isEmpty()){
String imagePath = imgNameList.remove(0);
                         ImageIcon image = new ImageIcon(getDocumentBase(), imagePath);
                         if(image.getImageLoadStatus() == java.awt.MediaTracker.COMPLETE) {
                              imgList.add(image);
                         This thread is initiated by my applet, and I just want it to do something very simple. I want it to load ALL the images from the URLs in imgNameList ArrayList<String> and if they are valid images, add them to the imgList ArrayList<ImageIcon>.
I do not understand why my code does not work.
I have read in multiple places that ImageIcon blocks the thread. But the condition mage.getImageLoadStatus() == java.awt.MediaTracker.COMPLETE is not ever true.
I am totally exasperated by this inexplicable behaviour.
Any advice will be greatly appreciated.
Many thanks.

Thanks for the replies.
The URLs were correct.
ImageIcon already implements MediaTracker by itself in the background, so I really don't want to have to do it myself.
The status was always 4.. ERRORED.. even if the image loaded just fine anyway, as in I could display it after.
I suspect it may be some strange thing due to Applet permissions or something of that sort. Eventually I gave up, so I just did as follows:
ImageIcon to load the image.
Get the height of the ImageIcon to do two things:
A) Make sure that the image is actually loaded (not just returning right away like GetImage)
B) Make sure it's a valid image (i.e. height greater than 0)
When I have some time I'll look over this carefully but for now it works so it'll have to do.

Similar Messages

  • Prealod iFrame  - Loading image

    Hi,
    I have implemented a jQuery Modal Dialog with an iFrame page inside and I was thinking to add a "loading" functionality to this dialog using GIF image.
    My iFrame is implemented the way it is described here: {message:id=9426960} and I know that I can do this "loading thing" directly in my iFrame page this way:
    [http://ayasenchuk.blogspot.com/2010/02/apex-page-with-animated-loading-modal.html]
    But I want it do right in my dialog script, like it is done here:
    http://plugins.jquery.com/content/jquery-ui-frame-dialog-loading-pane
    or here:
    http://www.blog.highub.com/javascript/javascript-library/preload-iframe-using-javascript/
    or even here:
    http://stackoverflow.com/questions/2939314/use-jquery-with-and-iframe-progress-indicator
    Is that possible, does anyone has experienced this?
    Thanks

    Hi Vee,
    Thank you for ypur reply and posted ideas to resolve my issue.
    I really like the last option (the Plug-in) and actually before posting this thread I did contact Dna (developer of this Plug-In) to see how it is working.
    So, I did try to put it into my app where it looks like this:
    <link rel="stylesheet" href="http://tdanryan.com/demo/framedialog/assets/css/shpblack/jquery-ui-1.8.4.custom.css"
        type="text/css" media="screen" charset="utf-8" />
    <script type="text/javascript" src="http://tdanryan.com/demo/framedialog/assets/js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://tdanryan.com/demo/framedialog/assets/js/jquery-ui-1.8.4.custom.min.js"></script>
    <script type="text/javascript" src="http://tdanryan.com/demo/framedialog/assets/js/jquery-framedialog-1.1.2.js"></script>
    <style type="text/css">
    .loading-image { background: transparent url('http://tdanryan.com/demo/framedialog/assets/im/progress-indicator-alpha.gif')
    no-repeat center center; }        
    </style>
    <script type="text/javascript">
         var openNewInv = function(){
         var apexSession = $v('pInstance');
         var apexAppId = $v('pFlowId');
         var assetNumber = $v('P3_ID');
         var url = "http://son-orcl2:8080/apex/f?p="+apexAppId+":15:"+apexSession+"::NO:15:P15_ASSET_ID:"+assetNumber;
                    jQuery.FrameDialog.create({
                        url: url,
                        loadingClass: 'loading-image',
                        title: 'Create Inventory Record',
                        width: 630,
                        height: 360,
                        autoOpen: false,
                        stack: true,
                        autoResize: true,
                        draggable: true,
                        buttons: {
                            "Cancel": function(){ $(this).dialog("close"); } 
                        open: function(event, ui){
                            // to hide a button panel
                            $(".ui-dialog-buttonpane").hide();
                            // this disables resizing without the iframe resized to content size.
                            $(".ui-resizable-handle").hide();
                        close: function(event, ui){                              
                $(function(){
                    openNewInv();                           
            </script>It just gave me the errors (see below, the same as from my workspace test)
    I did try to implement this solution on apex.oracle.com so it will load yahoo.com (instead of my application page link) in my modal window as an iFrame and will show a loading image while preloading wthe iFrame web site. But id doesnt work. I did use FireBug to see what is happening and it gives me errors when page is loading:
    elem.document.body is null
                    elem.document.body[ "client" + name ] || docElemProp;                      jquery-1.5.2.js (line 8346)and
    jQuery.FrameDialog.create is not a function
                    close: function(event, ui){                                                                f?p=32...61::YES (line 49)and when I click on "Create" to open my modal popup it gives:
    jQuery.FrameDialog.create is not a function
                    close: function(event, ui){                                                               f?p=32...61::YES (line 48)Here is my workspace link and credentioal so u can see my script.
    [http://apex.oracle.com/pls/apex/f?p=32646]
    user: guest
    psw: apex_demo
    Thanks

  • Loading images with properties in Forms6

    Hello !
    I would like to use Mmix32.ocx with Forms6 to have properties and
    methods of loaded images !
    But I don't know how , cause I imported Ole library interfaces MMix control without results !
    I need an exemple !
    thanks !

    Me too !
    I would like to use Mmix32.ocx with Forms6 to have properties of images !
    I imported Ole library interfaces MMix control !
    I have an error:
    FRM-41344:ole object not defined for <item name> in current record !

  • Loading Images in CrEme JVM

    Hi all,
    I'm trying to load images on an HP iPAQ using the CrEme JVM for Windows CE 4.1. I'm using the awt Toolkit getImage() method with a MediaTracker. Everything runs fine on the desktop, but CrEme won't render any images. Here's my code:
    package ImageTest;
    import java.awt.*;
    import java.io.*;
    public class ImageTest extends Frame
         Image m_Image;
         public ImageTest()
              setVisible(true);
              setSize(Toolkit.getDefaultToolkit().getScreenSize());
              setTitle("Image Test");
              try
                   MediaTracker mt = new MediaTracker(this);
                   m_Image = Toolkit.getDefaultToolkit().getImage("filename.gif");
                   mt.addImage(m_Image, 0);
                   mt.waitForAll();
                   System.out.println("Image dimensions: " + m_Image.getWidth(null) + ", " + m_Image.getHeight(null));
                   paintComponent(this.getGraphics());
              catch(Exception e)
                   e.printStackTrace();
         public void paintComponent(Graphics g)
              g.drawImage(m_Image, 0, 0, null);
         public static void main(String[] args)
              ImageTest test = new ImageTest();
    }If anyone knows any method of loading images in CrEme, I would greatly appreciate it.
    Thanks.

    I have the same problem using Creme. I would really very grateful if you could help me...
    package src;
              import java.awt.*;
              import java.awt.image.BufferedImage;
              import javax.swing.*;
              public class MapPanel extends JPanel {
                   Image image;
                   BufferedImage mBufferedImage;
                   int width = this.width;
                   int height = this.height;
                   static String path = "/resources/Forum.jpg";
                   public MapPanel()
                        loadImage(path);
                   createBufferedImage();
                   public void loadImage(String fileName)
                   try
                        image = Toolkit.getDefaultToolkit().getImage(fileName);
                        MediaTracker mt = new MediaTracker(this);
                        mt.addImage(image, 0);
                        mt.waitForAll();
                   catch(InterruptedException ie)
                        ie.printStackTrace();
                   return;
                   public void createBufferedImage()
                   mBufferedImage = new BufferedImage(image.getWidth(this),
                   image.getHeight(this),
                   BufferedImage.TYPE_INT_RGB);
                   Graphics2D g2 = mBufferedImage.createGraphics();
                   g2.drawImage(image, 0, 0, this);
                   g2.dispose();
                   public void paintComponent(Graphics g)
                        super.paintComponent(g);
                   g.drawImage(image, 0, 0, this);
              }

  • (EPG Install) Error while loading image

    Hi,
    I am facing "ORA-22288: file or LOB operation FILEOPEN failed" error while running apex_epg_config step. But all the steps before that (i.e. APEX Install [@apexins users users temp /i/] and change admin password) went all fine.
    I am trying to install APEX 4.1 on "Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production".
    I went through [url https://forums.oracle.com/forums/thread.jspa?messageID=9673913]this thread. But I am not passing /apex directory (apex directory is under "C:/Ash/Technical/Database/Oracle/apex4.1") , here is the outcome:
    C:\Ash\Technical\Database\Oracle\apex4.1\apex>
    11:33:41 sys@dev10db> @apex_epg_config.sql C:/Ash/Technical/Database/Oracle/apex4.1
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.21
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.03
    Directory created.
    Elapsed: 00:00:00.03
    declare
    ERROR at line 1:
    ORA-22288: file or LOB operation FILEOPEN failed
    No such file or directory
    ORA-06512: at "SYS.XMLTYPE", line 296
    ORA-06512: at line 18
    Elapsed: 00:00:00.04
    Commit complete.
    Elapsed: 00:00:00.00
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.14
    declare
    ERROR at line 1:
    ORA-31001: Invalid resource handle or path name "/images"
    ORA-06512: at "XDB.DBMS_XDB", line 473
    ORA-06512: at line 37
    Elapsed: 00:00:00.17
    timing for: Load Images
    Elapsed: 00:00:01.42
    Session altered.
    Elapsed: 00:00:00.00
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.48
    Commit complete.
    Elapsed: 00:00:00.01
    Session altered.
    Elapsed: 00:00:00.01
    Directory dropped.
    Elapsed: 00:00:00.07I am installing from my windows XP, but the db server is on Linux.
    Error above (line 18) is actually on this line of "apex_epg_config_core.sql" (my db charset is UTF8)
    filelist_xml xmltype := xmltype(bfilename(upload_directory_name,file_list),nls_charset_id('AL32UTF8'));
    The error clearly suggest that the there is an issue with access my directory or file in that directory.
    And I believe the 2nd error "ORA-31001: Invalid resource handle or path name "/images"", will go itself once the first one is resolved.
    I went through the documentation and other forum threads, but I am stuck with this EPG install, it may be very silly thing that I may be missing, but any help in this matter would be highly appreciated.
    Thanks,
    Ash
    Edited by: ash0602 on Sep 5, 2011 5:19 PM

    Thanks Andy and Kiran for taking time to respond.
    Andy, "@apex_epg_config.sql C:/Ash/Technical/Database/Oracle/" will not solve the problem, neither changing directory's name from apex4.1 to apex_4.1_en, as my directory structure till images is: "C:\Ash\Technical\Database\Oracle\apex4.1\apex\images".
    Kiran, sorry but I do not understand the difference between what I have written what you mentioned above.
    Though I understood the issue, when you see the apex underlying code (apex_epg_config_core.sql) it is actually creating a directory object ('APEX_IMAGES') in the database. While I was trying to refer the directory on my local windows PC ('C:\Ash\Technical\Database\Oracle\apex4.1\apex\images'). I then logged into the LINUX server and ran the command and it all went fine, see the response below:
    SQL> @apex_epg_config /opt/oracle/product/11.2.0/db1
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    old   1: create directory APEX_IMAGES as '&1/apex/images'
    new   1: create directory APEX_IMAGES as '/opt/oracle/product/11.2.0/db1/apex/images'
    Directory created.
    old  47:     if '&IMGUPG' != '' then
    new  47:     if '' != '' then
    old  48:         l_mv_folder := '&IMGUPG';
    new  48:         l_mv_folder := '';
    PL/SQL procedure successfully completed.
    Commit complete.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    timing for: Load Images
    Elapsed: 00:00:31.78
    Session altered.
    PL/SQL procedure successfully completed.
    Commit complete.
    Session altered.
    Directory dropped.Though I moved 1 step forward, but my apex login page (http://<server>:8080/apex/apex_admin => redirected to http://<server>:8080/apex/f?p=4550:10:<session>) refuse to come up as it is now showing "[url https://forums.oracle.com/forums/thread.jspa?threadID=1112378]apex is undefined" error.
    I did the installation as [@apexins users users temp /i/] mentioned in the docs, and this is first install not the upgrade.
    Any help on this ['apex' is undefined] (javascript error) would be really helpful.
    Thanks,
    Ash

  • [svn:bz-trunk] 12951: Changed synchronized PropertyProxyRegistry#getRegistry method to non-synchronized to avoid threads blocking in message push .

    Revision: 12951
    Revision: 12951
    Author:   [email protected]
    Date:     2009-12-15 02:17:31 -0800 (Tue, 15 Dec 2009)
    Log Message:
    Changed synchronized PropertyProxyRegistry#getRegistry method to non-synchronized to avoid threads blocking in message push.
    Checkintests: Pass with the usual 3-4 tests that time out with and without this change.
    QA: Yes
    Doc: No
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/io/PropertyProxyRegistry.java

    Revision: 12951
    Revision: 12951
    Author:   [email protected]
    Date:     2009-12-15 02:17:31 -0800 (Tue, 15 Dec 2009)
    Log Message:
    Changed synchronized PropertyProxyRegistry#getRegistry method to non-synchronized to avoid threads blocking in message push.
    Checkintests: Pass with the usual 3-4 tests that time out with and without this change.
    QA: Yes
    Doc: No
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/io/PropertyProxyRegistry.java

  • How could I load image via a Form when it is in runtime by not using default block

    1. How could I load image from my local computer to the database via a Form when it is in runtime?
    2. And how to display the image stored in the database on a Form ?
    Thanks buddy ~
    A nice member answered this question already, but I want to know how could I do it by using manual create block instead of using database item directly~
    Could anyone help me pls~

    This is the only way I know right now:
    1) Create this table
    SQL> desc av_data
    Name Null? Type
    BLOB_ID NOT NULL NUMBER(10)
    BLOB_TYPE NOT NULL VARCHAR2(10)
    DESCRIPTION NOT NULL VARCHAR2(25)
    BLOB_DATA LONG RAW
    2) On form create a button with this 'when-btn-prssed' tgr:
    DECLARE
         v_dirname          VARCHAR2(255);
         v_filename          VARCHAR2(255);
    BEGIN
         v_dirname := 'C:\';
         v_filename := get_file_name(v_dirname, NULL,
         'Bitmap file (*.bmp)|*.bmp|'                    ||
         'JPEG file (*.jpg)|*.jpg|'          );
         IF v_filename IS NOT NULL THEN
    read_image_file(v_filename, 'ANY',
    'av_data_image.blob_data');
         END IF;
    END;     
    3) Add this pre-insert trigger too :
    :av_data_image.blob_type := 'IMAGE';
    Sorry if this is not exactly the answer you're looking for.
    Bob

  • Loading Images into Applets

    I've been having problems loading an image into an Applet. I've found that when the getImage() call is put into the init() method it loads the image fine, also implementing an imageUpdate call. However, now I'm trying to expand on this by putting it into a button click, it hangs indefinitely while waiting for the image to load.
    Another interesting point I've noticed is that the Canvas subclass ImageSegmentSelector uses a PixelGrabber in its constructor to put the Image into a buffer - when this class is created from the imageUpdate() call, NOT the init() call, the grabPixels() call hangs indefinitely too!!
    Any feedback, please,
    Jonathan Pendrous
    import java.applet.*;
    import java.net.*;
    import jmpendrous.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    public class XplaneGlobalSceneryDownloader extends Applet implements ActionListener{
    ImageSegmentSelector worldMap;
    Image img;
    URL url;
    int longtitude = 36;
    int latitude = 18;
    boolean imageLoaded;
    TextField t1, t2,t3;
    Label l1,l2,l3;
    Button b1;
    Applet a1;
    public void init() {
    a1 = this;
    l1 = (Label) add(new Label("Number of horizontal sections: "));
    t1 = (TextField) add(new TextField("45",3));
    l2 = (Label) add(new Label("Number of vertical sections: "));
    t2 = (TextField) add(new TextField("45",3));
    l3 = (Label) add(new Label("URL of image file: "));
    t3 = (TextField) add(new TextField("file:///C:/java/work/xplane_project/source/world-landuse.GIF",60));
    b1 = (Button) add(new Button("Load image"));
    b1.addActionListener(this);
    validate();
    // THIS CODE WORKS FINE ...
    /*try { url = new URL("file:///C:/java/work/xplane_project/source/world-landuse.GIF"); }
    catch(MalformedURLException e) { System.exit(0);   }
    img = getImage(url);
    //int w=img.getWidth(this);
    while(imageLoaded==false) { try { Thread.sleep(1000);   } catch(InterruptedException e) {System.exit(0);    } }
    worldMap = new ImageSegmentSelector(this, img, longtitude, latitude);
    add(worldMap);
    //resize(worldMap.getWidth(), worldMap.getHeight());
    validate();*/
    //repaint();
    //worldMap = new ImageSegmentSelector(this, img, longtitude, latitude);
    //repaint();
    public void actionPerformed(ActionEvent e) {
    try { longtitude = Integer.parseInt(t1.getText()); } catch (NumberFormatException ex) {System.exit(0); }
    try { latitude = Integer.parseInt(t2.getText()); } catch (NumberFormatException e2) {System.exit(0); }
    try { url = new URL(t3.getText()); }
    catch(MalformedURLException e3) { System.exit(0);   }
    img = getImage(url);
    //int w=img.getWidth(this);
    while(imageLoaded==false)
    { try { Thread.sleep(1000);   } //KEEPS ON LOOPING
    catch(InterruptedException e4) {System.exit(0);    } }
    worldMap = new ImageSegmentSelector(a1, img, longtitude, latitude);
    add(worldMap);
    //resize(worldMap.getWidth(), worldMap.getHeight());
    validate();
    public boolean imageUpdate(Image i, int flags, int x, int y, int w, int h){
    // THIS NEVER GETS CALLED AT ALL //
    if (((flags & ImageObserver.WIDTH) != 0) && ((flags & ImageObserver.HEIGHT) != 0)) {
    //worldMap = new ImageSegmentSelector(this, i, longtitude, latitude);
    //add(worldMap);
    //validate();
    //repaint();
    imageLoaded = true;
    return false;
    return true;
    }

    Sorry, thought this had been lost.
    You can load a file if the applet itself is run from the local filesystem - it loads it fine from the init(), but not otherwise. But I haven't got the applet to run from a browser yet without crashing (it's OK in the IDE debugger), so that's the next step.

  • Problem with loading image to Applet.

    Hello. Im preety new to Java, and currently ive got problems with adding an image to my applet. I tried to make game, similar to Mario - a platform based one. I found a source code of something close to that, and wanted to test but i couldnt get images loading. Here's the code :
    Main class :
    package pl.wat.edu;
    import java.applet.*;
    import java.awt.*;
    public class Main extends Applet implements Runnable{
         Thread th;
         private final int speed = 15;
         private Level obecny_poziom;
         private Image dbImage;
         private Graphics dbg;
         MediaTracker mt = new MediaTracker(this);
         private Image ziemia1;
         @Override
         public void destroy() {
              // TODO Auto-generated method stub
              super.destroy();
         @Override
         public void init() {
              // TODO Auto-generated method stub
              super.init();
              setSize(stale.wielkosc_apletu_szerokosc, stale.wielkosc_apletu_wysokosc);
              //setBackground(Color.blue);
              //ziemia1 = getImage(getCodeBase(), "g1.GIF");
              obecny_poziom = new Pierwszy(this, this);
         @Override
         public void start() {
              // TODO Auto-generated method stub
              super.start();
              // create new thread
              th = new Thread (this);
              // start thread
              th.start ();
         @Override
         public void stop() {
              // TODO Auto-generated method stub
              super.stop();
              // Thread stop
              th.stop();
              th = null;
         public void run() {
              // TODO Auto-generated method stub
              while (true){
                   repaint();
                   try
                        Thread.sleep(speed);
                   catch (InterruptedException ex)
                   // do nothing
         @Override
         public void paint(Graphics arg0) {
              // TODO Auto-generated method stub
              super.paint(arg0);
              //arg0.drawImage(ziemia1,10,10,this);
              obecny_poziom.paintLevel(arg0);
         public void update (Graphics g)
              if (dbImage == null)
                   dbImage = createImage (this.getSize().width, this.getSize().height);
                   dbg = dbImage.getGraphics ();
              dbg.setColor (getBackground ());
              dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
              dbg.setColor (getForeground());
              paint(dbg);
              g.drawImage (dbImage, 0, 0, this);
    }and Level class that have draw levels from String rows :
    package pl.wat.edu;
    import java.applet.Applet;
    import java.awt.*;
    public abstract class Level {
         //private LevelElement [] elements;
         private WorldTile [] tiles;
         private WorldTile[][] tablica_kolizji;
         private Color [] colors;
         private Component parent;
         private int lewa_granica;
         private int prawa_granica;
         private int dlugosclevelu;
         private Image ziemia = null;
         private Image titi;
         private Applet applet;
         public abstract void resetLevel();
         public Level(Component parent, Applet applet) {
              super();
              this.parent = parent;
              this.applet = applet;
              ziemia = applet.getImage(applet.getCodeBase(), "g1.GIF");
         public void initializeLevel(String [] definitions){
              tablica_kolizji = new WorldTile [stale.dlugosclevela] [definitions[0].length()];
              lewa_granica = 0;
              prawa_granica = stale.wielkosc_apletu_szerokosc;
              int licznik_kratek = 0;
              for(int i=0; i<definitions.length; i++){
                   char [] definition_line = definitions.toCharArray();
                   for(int j=0; j<definition_line.length; j++){
                        if (definition_line[j] == ':')
                             tablica_kolizji[i][j] = null;
                        else if (definition_line[j]== 'g'){
                             Ziemia tile = new Ziemia(j*stale.szerokoscTile, i*stale.wysokoscTile, stale.ziemia_id, ziemia, parent);
                             tablica_kolizji[i][j] = tile;
                             licznik_kratek = 0;
              tiles = new WorldTile [licznik_kratek];
              int licznik = 0;
              for (int i = 0; i<tablica_kolizji.length; i++){
                   for(int j=0; j>tablica_kolizji[i].length; j++){
                        if (tablica_kolizji[i][j] != null){
                             tiles[licznik] = tablica_kolizji[i][j];
                             licznik++;
         public void paintLevel(Graphics g)
              try
                   // draw background
                   // draw all elements in elements array
                   for(int i=0; i<tiles.length; i++)
                        tiles[i].rysujTile(g);
              catch(Exception ex)
                   // do nothing
    Any ideas why this Image doesnt show up ?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    michali7x4s1 wrote:
    Thats a code i found somewhere, tried to check how some things work.Have you used exceptions before? If not, please read the sun tutorial on them as they are very very important. Also, whether this is your code or someone else's doesn't matter as it's yours now, and you would be best served by never throwing out exceptions as is done in this code. It's like driving with a blindfold on and then wondering why you struck the tree. It's always best to go through the tutorials to understand code before using it. If it were my project, I'd do it in Swing, not AWT. Fortunately Sun has a great tutorial on how to code in Swing, and I suggest you head there as well. Best of luck.

  • Loading images into memory

    I have an applet that I need to load images into memory. For instance, lets say I am in the first section of the applet. While that section is being showed, I want to load the background image of the second section into memory.
    To load the initial image into momory, I am just using a Mediatracker. No problem there. But I don't want to load all 20 backgrounds into memory at the same time as they take a lot of time. My understanding is that if I create a new MediaTracker while the first chapter is running, it will potentially cause some chaos, as that will stop my thread from running while I have an image loading.
    Somebody told me perhaps I could create a new thread and have that thread load the backgroudn into momory? Perhaps something like this?
    public class TestClass extends JApplet {
         private TestClass thisClass;
         public void init() {
              thisClass = this;
              Runnable r = new Runnable() {
                   public void run() {
                        MediaTracker tracker = new MediaTracker(thisClass);
                        Image nextImage = getImage( getDocumentBase(), getImagePath() +"img1.jpg");
                        tracker.addImage(nextImage,0);
                        try {
                             tracker.waitForID(0);
                        } catch (InterruptedException ie) {
                             System.out.println(ie.toString());
              Thread t = new Thread(r);
              t.setDaemon(false);
              t.start();
              while(t.isAlive()) {
                   int i = 1;     
              t.stop();
              t.destroy();
    }No idea if I am on the right track or not? Another friend told me something about swing helpers but couldn't tell me much more?
    Thanks in advance!

    I use media tracker when I need information about how percent the image is loaded. you can use JLabel to load the images since it has own image observer in it.
    hope you just want to deal with it. easiest way I can offer :)

  • Problem with loading image

    Hi
    I cant able to load the image my code is so simple whats the
    problem please help me........
    when me using the image tag its able to load but while using
    from the script its unable to load why??
    but i want it to be loaded in the same
    format..........(D:\images\azshear\SHAR-29-10-2006-21.0.jpg),is it
    possible??

    You need to use a double slash to escape the source attribute
    in the function. Unfortunately you cannot use the escape global
    method because it ignores the slash character.
    img.source="D:\\images\\azshear\\SHAR-29-10-2006-21.0.jpg";
    Another way to code this is to use a forward slash instead of
    a double back slash.
    img.source="D:/images/azshear/SHAR-29-10-2006-21.0.jpg";
    It works for the Image tag because the image tag will escape
    the slash character

  • Problem with Loading Images?

    <pre><i>Locking duplicate thread.
    Please continue here: [[/questions/982030]]
    </i></pre>
    Hi,
    I'm using Firefox 26.0 and I'm kinda new user to Firefox.
    I'm having this random issue with facebook (sometimes with other websites too),
    Sometimes when I open a page, the Images doesn't show as usual.
    Sometimes it takes up to 10sec - 2 mnts to finish loading all the images.
    My internet is 8Mbps so I don't think its due to that?
    Here is a screenshot of the exact issue: http://i.imgur.com/I3eOQaI.jpg
    But it get fixed for a while (say 1-2 days) if I clear the cookies and caches. I visits a lot of webpages so clearing cookies and caches all the times is kinda not pretty possible.
    I also tried disabling all my add-ons, and ran a full scan with McAfee.
    Can anyone tells me what exactly could be the issue? It gets pretty annoying sometimes!
    Thanks in advance!
    Regards,
    Abey

    '''Hi, Thanks for Visiting this Question. But it was a duplicate of https://support.mozilla.org/en-US/questions/982030 (The Same question) Accidentally posted twice''' and I couldn't find an option to delete it, so please '''ignore''' this :-)
    Original thread: [[https://support.mozilla.org/en-US/questions/982030|"Problem with Loading Images"]]
    Warm Regards,
    Abey

  • Blocked threads

    Hi, I need help to solve the following problem:
    I have a thread T calling a method x() of a class C.
    The problem is that, by my point of view, the method C.x() is an atomic function and it could be blocking or it could take too much time.
    Now I need to kill the thread after a while (i.e. after timeout expiration).
    I know that the Thread.close() method is deprecated and that, in this case, Thread.interrupt() can't solve the problem (I can't use status variables).
    I've also read something about java.nio package but I don't know how to use it.
    Is there anybody can help me?
    Thanks

    I'm implementing a simple server that gets request from clients.
    Clients open a socket connection on a well known port.
    When the server receives a new connection request it creates a new thread.
    This thread is in charge to receive, parse the commands coming from the client (via socket). Based on the request it calls the related method for the class. Normally the method is a call for a CORBA object's function. And the problem is that the response (that is, the function has finished) could come after a while and it is out of my control (for example CORBA objects has problems or the request itself takes time).
    After timeout expiration I need to kill all the blocked threads, because the server must handle a maximum number of threads, and if I don't kill blocked threads no other clients (requests) are admitted.
    thanks for your help
    d.

  • [How .. ]: Load image to SAP Screen.

    Hi All,
    I'm having a project where i should display the corresponding picture.
    These are questions that i'm going to ask :
    1. How can i store the image to SAP Server ? Could you direct me step by step please ..
    2. How can i load the picture from the program ? Could it also be directed step by step ..
    Many thanks all.
    Still need your guidance a lot.
    Kindly Regards,
    Niel.

    Niel,
    Say thanks to Pavan Praveen who helped me with this sometime back.
    To create a logo u have to remember one thing is u have to upload that logo through OAER or SE78
    for uploading logo in OAER
    Enter class name as PICTURES
    Class type as OT
    Object key the name of ur logo want to upload
    then press F8 or execute
    Then it will automatically creates a folder for ur LOGO and upload ur logo in that folder
    After that In the left side bottom of the page u can c the following options
    1)Detail
    2)Document Info
    3)Keywords
    4)Create
    goto Detail in which u can find the Object Id
    which u have to paste in the function module of this program
    Check this program1
    *& Report  ZREPORT_LOGO                                                *
    REPORT  ZREPORT_LOGO.
    DATA:
    docking TYPE REF TO cl_gui_docking_container,
    picture_control_1 TYPE REF TO cl_gui_picture,
    url(256) TYPE c .
    DATA : sum(4) , num1(4) , num2(4).
    PARAMETERS: p_dummy(4) DEFAULT '4' .
    PARAMETERS: p_dummy1(4) DEFAULT '5' .
    AT SELECTION-SCREEN OUTPUT.
    PERFORM show_pic.
    START-OF-SELECTION.
    num1 = p_dummy.
    num2 = p_dummy1.
    sum = num1 + num2.
    WRITE : / sum.
    *& Form show_pic
    FORM show_pic.
    DATA: repid LIKE sy-repid.
    repid = sy-repid.
    CREATE OBJECT picture_control_1 EXPORTING parent = docking.
    CHECK sy-subrc = 0.
    CALL METHOD picture_control_1->set_3d_border
    EXPORTING
    border = 5.
    CALL METHOD picture_control_1->set_display_mode
    EXPORTING
    display_mode = cl_gui_picture=>display_mode_stretch.
    CALL METHOD picture_control_1->set_position
    EXPORTING
    height = 100
    left = 500
    top = 10
    width = 300.
    CALL METHOD picture_control_1->load_picture_from_url
    EXPORTING
    url = 'c:/pic.bmp'.
    IF sy-subrc NE 0.
    ENDIF.
    ENDFORM. "show_pic
    Check this program 2
    program zsap_picture_demo.
    set screen 200.
    TYPE-POOLS cndp.
    CLASS    c_event_receiver
    DEFINITION
    class c_event_receiver definition.
    The class is used to test the events raised by the cl_gui_picture
    class
      public section.
        methods event_handler_picture_dblclick
                for event picture_dblclick of cl_gui_picture
                importing mouse_pos_x mouse_pos_y sender.
        methods event_handler_context_menu
                for event context_menu of cl_gui_picture
                importing sender.
        methods event_handler_context_menu_sel
                for event context_menu_selected of cl_gui_picture
                importing fcode sender.
      endclass.
    DATA
      data function like sy-ucomm.         " OK-Code field in screen 200
      data url  type cndp_url.                " URL-field in screen 200
      data url2 type cndp_url.               " URL-field in screen 200
      data picture_control_1 type ref to cl_gui_picture.
      data picture_control_2 type ref to cl_gui_picture.
      data container_1 type ref to cl_gui_custom_container.
      data container_2 type ref to cl_gui_custom_container.
      data event_receiver  type ref to c_event_receiver.
      data event_tab type cntl_simple_events.
      data event_tab_line type cntl_simple_event.
      data return type i.
    PBO
    before_output
    module before_output output.
      set pf-status 'MAIN0001'.
      IF PICTURE_CONTROL_1 IS INITIAL.
    Create controls
        create object container_1
          exporting container_name = 'PICTURE_CONTROL_1'.
        create object container_2
          exporting container_name = 'PICTURE_CONTROL_2'.
        CREATE OBJECT PICTURE_CONTROL_1 exporting parent = container_1.
        CREATE OBJECT PICTURE_CONTROL_2 exporting parent = container_2.
    Register the events
        EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_PICTURE_DBLCLICK.
        append EVENT_TAB_LINE to EVENT_TAB.
        EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTEXT_MENU.
        append EVENT_TAB_LINE to EVENT_TAB.
    EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTEXT_MENU_SELECTED.
        append EVENT_TAB_LINE to EVENT_TAB.
        CALL METHOD PICTURE_CONTROL_1->SET_REGISTERED_EVENTS
          exporting
            EVENTS = event_tab.
        CALL METHOD PICTURE_CONTROL_2->SET_REGISTERED_EVENTS
          exporting
            EVENTS = event_tab.
    Create the event_receiver object and set the handlers for the events
    of the picture controls
        create object event_receiver.
        set handler event_receiver->event_handler_picture_dblclick
                    FOR PICTURE_CONTROL_1.
        set handler event_receiver->event_handler_context_menu
                    FOR PICTURE_CONTROL_1.
        set handler event_receiver->event_handler_context_menu_sel
                    FOR PICTURE_CONTROL_1.
        set handler event_receiver->event_handler_picture_dblclick
                    FOR PICTURE_CONTROL_2.
        set handler event_receiver->event_handler_context_menu
                    FOR PICTURE_CONTROL_2.
        set handler event_receiver->event_handler_context_menu_sel
                    FOR PICTURE_CONTROL_2.
    Set the display mode to 'normal' (0)
        CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
             EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
        CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
             EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    Set 3D Border
        CALL METHOD PICTURE_CONTROL_1->SET_3D_BORDER
           exporting border = 1.
        CALL METHOD PICTURE_CONTROL_2->SET_3D_BORDER
           exporting border = 1.
    new async implementation since 4.6C
    CALL FUNCTION 'DP_PUBLISH_WWW_URL'
      EXPORTING
        OBJID                       = 'HTMLCNTL_TESTHTM2_SAP_AG'
        LIFETIME                    = cndp_lifetime_transaction
      IMPORTING
        URL                         = url
      EXCEPTIONS
        OTHERS                      = 1.
    Load the picture by using the url generated by the data provider.
        if sy-subrc = 0.
          CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL_ASYNC
             exporting url = url.
        endif.
    CALL FUNCTION 'DP_PUBLISH_WWW_URL'
      EXPORTING
        OBJID                       = 'DEMOWORD97SAPLOGO'
        LIFETIME                    = cndp_lifetime_transaction
      IMPORTING
        URL                         = url2
      EXCEPTIONS
        OTHERS                      = 1.
    load image
        if sy-subrc = 0.
          CALL METHOD PICTURE_CONTROL_2->LOAD_PICTURE_FROM_URL_async
             exporting url = url2.
        endif.
      endif.
    endmodule.
    PAI
    after_input
    module after_input input.
      case function.
    At the end of the program destroy the control
        when 'BACK'.
          CALL METHOD container_1->FREE.
          CALL METHOD container_2->FREE.
          leave to screen 0.
    Change the display mode
        when 'NORMAL'.
          CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
               EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
          CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
               EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
        when 'STRETCH'.
          CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
             EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
          CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
             EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
        when 'FIT'.
          CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
               EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
          CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
               EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
        when 'NORMAL_CTR'.
          CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
        EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
          CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
        EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
        when 'FIT_CTR'.
          CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
          EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
          CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
          EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
    Clear the picture
        when 'CLEAR'.
          CALL METHOD PICTURE_CONTROL_1->CLEAR_PICTURE.
    Load a new picture
        when space.
          CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL
               exporting url = url
               importing result = return.
          call method cl_gui_cfw=>flush.
          if return = 0.
            url = text-000.
          endif.
      endcase.
      clear function.
    endmodule.
    CLASS   c_event_receiver
    IMPLEMENTATION
    CLASS C_event_receiver implementation.
    CLASS   c_event_receiver
    METHOD  event_handler_picture_dblclick
      METHOD EVENT_HANDLER_PICTURE_DBLCLICK.
           for event picture_dblclick of c_picture_control
           importing mouse_pos_x mouse_pos_y.
        DATA pos_x(5) type c.
        DATA pos_y(5) type c.
        pos_x = mouse_pos_x.
        pos_y = mouse_pos_y.
        IF SENDER = PICTURE_CONTROL_1.
          MESSAGE I000(0K) WITH
            'DoubleClick' 'Upper Picture' POS_X POS_Y. "#EC NOTEXT
        else.
          MESSAGE I000(0K) WITH
            'DoubleClick' 'Lower Picture' POS_X POS_Y. "#EC NOTEXT
        endif.
      endmethod.
    CLASS   c_event_receiver
    METHOD  event_handler_context_menu
      METHOD EVENT_HANDLER_CONTEXT_MENU.
        data menu type ref to cl_ctmenu.
        create object menu.
        call method menu->ADD_FUNCTION exporting
          fcode = text-001
          TEXT = TEXT-001.
        call method menu->ADD_FUNCTION exporting
          FCODE = TEXT-002
          TEXT = TEXT-002.
        call method menu->ADD_FUNCTION exporting
          FCODE = TEXT-003
          TEXT = TEXT-003.
        call method menu->ADD_FUNCTION exporting
          FCODE = TEXT-004
          TEXT = TEXT-004.
        call method menu->ADD_FUNCTION exporting
          FCODE = TEXT-005
          TEXT = TEXT-005.
        CALL METHOD SENDER->DISPLAY_CONTEXT_MENU
          EXPORTING CONTEXT_MENU = MENU.
      endmethod.
    CLASS   c_event_receiver
    METHOD  event_handler_context_menu_sel
      METHOD EVENT_HANDLER_CONTEXT_MENU_sel.
        DATA DISPLAY_MODE TYPE I.
        IF FCODE = TEXT-001.
          DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
        ENDIF.
        IF FCODE = TEXT-002.
          DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
        ENDIF.
        IF FCODE = TEXT-003.
          DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
        ENDIF.
        IF FCODE = TEXT-004.
          DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
        ENDIF.
        IF FCODE = TEXT-005.
          DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
        ENDIF.
        CALL METHOD SENDER->SET_DISPLAY_MODE
             EXPORTING DISPLAY_MODE = DISPLAY_MODE.
      endmethod.
    endclass.
    Note: While creating this program I had observed the thing is it will accepts the logo which was having the URL so try to create a logo of URL but u can display the Standard SAP logo using this program
    To upload the the logo image on the right hand side of the SAP screen.
    Transaction codeSMW0
    X - Binary data for WebRFC application
    Hit Enter
    Click Execute
    Click Settings -> Maintain MIME types
    Click the Create button
    Fill in :- TYPE : image/gif EXTENSION : .GIF
    Click Save
    Click Back to the Binary data for WebRFC
    Click Create
    Fill in :- Obj. name : ZXXXX.GIF Description : Company Logo
    Click Import and specify the filename where your GIF file is located.File type is BIN. Finish press the Transfer button.
    If successful, your logo will be shown in the Binary data for WebRFC.
    Transaction codeSM30 - Table/View - SSM_CUST
    Click Maintain
    Click New Entries
    Name Value to be set
    START_IMAGE ZXXXX.GIF
    RESIZE_IMAGE NO
    Logoff and Login again
    Check this link
    http://www.sap-img.com/fu002.htm

  • Mail Slow to Load Images

    I've gotten MOST issues addressed/fixed since Mavericks came out, but one I've noticed that is a bit annoying. Images in emails are slow to load. Not just with Gmail account, other accounts as well. Any others getting this? I'm on a MacBook Pro Retina Late 2013.

    I'll try to submit this as a bug report when I get a chance.  The desired behavior would be to show as much of the message as possible without blocking the application...the way a web browser normally does when rendering a web page as elements come in.
    One other quirk: in the case of the email tracking example I gave, it does not help to disable "display remote images in HTML messages" under Mail...Preferences...Viewing. 
    Actually, when disabling this feature, it seems like Mail downloads the images, but simply does not display them.  It takes a while to display some emails without displaying the remote images when the feature is disabled, then I hit "load images" and the images instantaneously appear.  They must have already been downloaded.  If true, then this is undesirable behavior indeed, e.g., when trying to minimize bandwidth during travel or when trying not to be tracked by email senders!

Maybe you are looking for

  • Need help with updateing a JTree

    I have a JList, and JTree which mimic each other. User makes selection in list presses OK and in the JTree I need the node that matches their selection to update and have child nodes under it. Can't seem to get it working right. right now I have this

  • System error 86 while mapping c$

    Hi, thanks for your time. I'm having the next issue: I work on a domain network. Usually, we image computers and then join them to a domain. However, i find it impossible to do anything to an unjoined computer because i get system error 86. Im trying

  • Mutiple HTML Region

    Hi, In the mutiple HTML region, is it possible to have 4 regions defined, adn each of it has a query as a source of the html region. Please let me know.

  • Manual valuation w/o reset in TPM1

    Hi All I want to doa manual valuation w/o reset for Product Type 51A (FD).  I created a valuation class. I also created a update type and assign usages. I also assigned the update types to the valuation. I created postion management procedure with ty

  • Adding stars in Review mode Bridge CS4

    Hi, Although I can right click to add star rating in review mode, I can't do it using the space under the picture on the screen, it shows the 5 dots but you can't add stars by clicking on them. Kinda makes the whole review mode pointless if you can't