Parsing Problems? ImageIcon and BufferedImage

Hi to everyone
Could I ask if I will to send ImageIcon with BufferedImage as its arguement. Then what should I receieve from the server? ImageIcon only or ImageIcon with BufferedImage as its arugement?
Any help will be appreciated. Thank You.

I am sending ImageIcon over to the server, hence the server will receive as ImageIcon.
However, when I want to pass the ImageIcon which being parse to Image, this step is ok. Lastly when I want to parse the Image to BufferedImage image, I am encountering parsing problems, hence could u advise me further.
The error message "Receiving failed: java.lang.ClassCastException"
Any help will be appreciated. Thank You.
     public void getImage()
          //Object input = null;
        Image images = null;
          try{
               imgIcon = (ImageIcon)oin.readObject();
               System.out.println("Icon Width: "+imgIcon.getIconWidth());
               while((images = imgIcon.getImage()) != null)
                    System.out.println("Images Width: "+Image.getWidth(images));
                    BufferedImage bimage = (BufferedImage)images; // PROBLEM LIES HERE
                    System.out.println("Bimage Width: "+bimage.getWidth());
                    ImageServerConnection.writeImage(bimage, "happy.jpg");
                    //String fname = "joalicia";
                    //create an new folder to store those sent images.
                    //File f = new File ("c:\\Sweet", fname);
                    //create(f);
          }catch(Exception e){
               System.err.println("Receiving failed: "+ e);
     }

Similar Messages

  • Having some problems with ImageIcons and JLabels

    I'm making a checkers game, and so far it's going pretty well.
    I've got the basic game down, and you can move pieces, jump, your turn ends when you can't jump anymore, etc...
    However, I've had three problems:
    1.) I'm using JLabels to display my board (8 x 8.. well actually 9 x 9 for an outer row labelled A,B,C,D.. 1,2,3,4...) Anyway, I create the JLabels using something that looks like \:
    JLabel square = new JLabel(new ImageIcon("pic.png"));
    Now, the picture loads properly, but it seems like the picture is being cropped, and the top and bottom are getting chopped off, so my 36 x 36 pixel *.gif appears to be 36 x 30.
    You can see how there is a gap created in:
    http://img235.imageshack.us/img235/7765/prob13ky.jpg
    Now the problem may be with the GridLayout I am using, but I set the distance between the components in the container to be 0, 0 so I don't think that GridLayout is chopping my icons. I've also tried setPreferredSize(new Dimension(36,36))
    for both my ImageIcons and JLabels and for my container (which I set to size 2000,2000, just to make sure there was room). If anyone can help me, it's be appreciated.
    2.) I used to be able to view my outside row/column of squares that said A,B,C,D.... and 1,2,3,4... with the square in the corner having a random pic. For some reason now (have no clue why) I now see only the pic in the corner, and then a little gray smudge diagonally under it.
    Pic:
    http://img347.imageshack.us/img347/8308/prob24im.jpg
    I don't know what's wrong. I'm pretty sure it's none of the new methods I've written, as those are all in my static void main (String[] ar) ...... and if I comment all the methods in my main except where I first make the JFrame and set it visible, it still turns out like that. repaint() doesn't help.
    3.) For some reason, when I move another window (AIM, the console window, etc...) over my Swing window, it "erases" (turns gray, just wipes clean) the part where I have my squares that have pieces.
    What's weird is that:
    The border pieces (err.. my one visible corner piece from my second problem) don't get wiped, and some debugging text and JLabels (in a different JPanel) are fine. I don't think the JPanel matters though; the border pieces and the playing squares (which get wiped) are in the same JPanel and same array of squares.
    repaint(); also erases ALL of my playing squares, whereas moving a window over them would only erase the part that the window covered.
    Also, I added a mouseListener so that whenever I move the mouse over a square, it changes the image (to a tinted version, so you know the mouse is over it) and when you move the mouse away, it returns to normal. However, if I wildly swing the mouse around the area, it seems to lock up and freeze for a few seconds. Is there anything I can do to prevent this??
    Thanks in advance.

    It is hard to tell what your problems are without any code at all (I saw your images, but that doesn't make it easy to see what is wrong in your code). If you do post code, please use code tags (see button above posting box).
    I've seen your MouseListener problem before--we had the exact same issue in our code at work. It would freeze up while it processed all of the mouse events (unbearably slow). I'm not at work right now, so I don't recall how it was fixed. Essentially, you need to only process the event periodically. You need to only update the image if the mouse switches squares. Or, only update the image if the distance from the last mouse event is more than some specified amount. We might also have checked the time difference between mouse events before processing a new one. I could look at the code at work tomorrow, if you are still having trouble.

  • Report query parsing problem

    I didn't find any report of this problem...
    Using APEX 3.0.1.00.07, I have a report of type "SQL Query (PL/SQL function body returning SQL query)" with the "Use Generic Column Names (parse query at runtime only)" radio button selected.
    When the region source contains the string "ORDER BY" in any form that I've tried (even in a comment), attempting to save the region fails with "Your query can't include an "ORDER BY" clause when having column heading sorting enabled."
    I do indeed have column sorting enabled on certain columns, but I don't see how that is relevant under these circumstances since the query produced at runtime does not have an ORDER BY clause.
    Am I overlooking something or is this a parsing problem?
    Rodney

    Rodney,
    It's just checking for order by being included in your query, and if so and you have column heading sorting enabled, it's raising this error because you can't have both (even if it's commented out).
    Regards,
    Marc

  • SAX parser problem in JDK1.5

    I have parse the xml file using SAX in jdk1.5 environment. During the parsing, it missed the some text content.
    for example
    <employeeid>
    <empid>1001</empid>
    <empid>1002</empid>
    </employeeid>
    If i have parse the above xml file using SAX in jdk1.5 environment. The output is
    1001
    100
    during the parsing , SAX parser misses digit of 2.
    if i have parse the above xml file using SAX in jdk1.4 environment , it is working fine.
    what is the problem in jdk1.5
    please help
    bala

    What I expect the problem to be was discussed recently in a topic titled "SAX Parser Problems" that was started on March 14 at 6:59 AM by JackoBS.
    Read that and see if it fixes your problem. If so, it is not a JDK1.5 problem, but a user error.
    Dave Patterson

  • Jar files, imageIcon and image

    I am building a little POP3 client and I am making the GUI with Swing.
    I have a problem:
    i would like to put all my classes into a jar file but so i can't load images like the imageIcon and the image for my buttons.
    I have a directory with my class files and a subdirectory with the images. All classes are a part of a my own package. And so I have:
    $\>RootDirectory\ [here is all class file and subdirectories]
    $\>Rootdirectory\img [here is all images i need]
    to make the jar file i use jar cvf myapp.jar RootDirectory
    but when i lounch the application i can't see images.
    I really hope thet anybody can help me!
    sorry my bad english

    Use the getResource(String string ) of Class: For example
    ImageIcon myIcon = new javax.swing.ImageIcon(getClass().getResource("/images/VerticalRuler.gif"))
    The images dir in the above example is a subdir of app's working directory. See Class API for details
    Hope that helps
    DB

  • How to parse html for and display hyperlinks?

    I'm trying to design a report that has a text field that contains html formatted text and includes links. These links need to be clickable in a thick client Java application I'm developing and the only way I can see in Crystal Developer to make a clickable link is to have a discrete text element with a hyperlink (set using the hyperlink tab in the element properties) for each link.
    The problem I have is that there can be any number of links in the html and I need a scalable way to extract and display these links.
    So far I have used formulas in Crystal Developer to parse the html and extracte the links into a fixed size array and then display each link in a separate text element. I would like to be able to have only one 'link' text element in the report design and create as many link elements as required depending on how many links are present in the html.
    How is this possible? With some funky grouping voodoo maybe, or something else? Please help me achieve this.
    Cheers,
    Elliot.

    Hi Elliot,
    Follow these steps, and check the output.
    1.Right click on the field object and select "Format Editor".
    2.Click on the "Paragraph" tab and select the "Text interpretation" as "RTF Text" or "HTML Text".
    3.Click on "Ok" button.
    Hope this helps.

  • Parse html js and ajax

    I am trying to make a parser for a website. This web have a list of elements that i need to read for compare it with my database. I have used HTMLEditorKit.ParserCallback for parse it and Apache HttpClient for connect with it. In others website it work ok, but in this website it use javascript and maybe it use ajax. How can I process javascript from a website with Java? There is any class on Java that work like a web navigator, and i can write on forms input, click on buttons an read the final code after of this process?

    I am trying to make a parser for a website. This web have a list of elements that i need to read for compare it with my database. I have used HTMLEditorKit.ParserCallback for parse it and Apache HttpClient for connect with it. This is fundamentally a hard problem. And even when you "solve" it, your solution will inherently be brittle. You have no control presumably over the site's designers, who can (and likely will) change it. Then your solution will need to be updated.
    In others website it work ok, but in this website it use javascript and maybe it use ajax. How can I process javascript from a website with Java? There will either be embedded Javascript on the page or a URL linking to the same. Either way, you can grab the embedded Javascript or make a separate URLConnection call to get the Javascript linked in the URL. From that point, you would want to use a Javascript parser. However, the designer of the site can do just about anything with code (as opposed to static content such as HTML). The Javascript itself may be obfuscated or minified. This is an even harder task than simply obtaining elements in markup.
    There is any class on Java that work like a web navigator, and i can write on forms input, click on buttons an read the final code after of this process?I have no idea what that might be or what you are looking for. What are you actually trying to accomplish? Why do you feel you need to analyze a third-party's web page and determine how it works in a semi-automated fashion?
    - Saish

  • Having problems PrintWriter and new lines in a string

    I apologise if this topic is in the wrong place, but this is my first time asking on these forums.
    At the moment I have a window with an output text area which I want to store the contents of into a file. I use getText() to store the contents to a string, and then write the string to a file using a BufferedWriter. the code is as follows:
    BufferedWriter out = new BufferedWriter(new FileWriter(file));
    String contents = output.getText();
    out.write(contents);
    out.close();The file-name is specified by a FileChooser. All of this works fine, and the text is actually written to the file ok, except that there are no line breaks in it (it's just one continual line of text). I have tried the same process using a string containing "test\ntest" to see if it is just a problem getting the contents of the text area, however it still gives me the same problem.
    Any help on this would be much appreciated.

    Take a look at PrintWriter.
    o See if you can wrap it around a BufferedWriter. (It
    may alrady BE one.)
    o Use it's .println(...) method.That'll still make it appear as one line though. The one-and-only "line" will have the correct platform-specific line terminator (\r\n I suppose), but the string he is writing has embedded \n characters in it, which he is expecting to show up as new lines.
    The OP needs to realize that there really aren't any such thing as "lines". It's all up to the software rendering the text to treat "newline" characters/sequences special. If you were to open that file with a different tool (not Notepad, which only recognizes \r\n as newline sequences), it may display it the way you are expecting.
    Or, you'll have to parse the text and convert it to the proper newline sequences before you write it to the file.

  • [nForce] Lets solve this 1394 problem once and for all.

        
    Hi guys,
    For the past 3months I have been trying to connect my Panasonic GS150 to my comuter in order to use Avid dvxpress pro. I have the problem of when I connect the camera to the computer, nothing happens. I also have this problem with my Ipod, however testing various different devices with the computer produces a strange outcome. Various different cameras work, xp pops up witha found new hardware device (like it should). Its very strange.
    I started to think it was my system. I changed my onboard firewire to a pci card, same solution. So then, i reinstalled windows, same outcome. So i bought a new motherboard nforce2 platinum and to my total amazment, same problem. If was after i had totally failed in finding the solution that i started to look elsewhere on the net for anyone who knows the answer. It seems to be a VIA firewire chipset problem. Every post of people who had similiar problems where looking for the answer but NOONE has solved it, ive come across about 1000 posts with no reply's. Its a problem that thousands have but not many people ever use ther're firewire ports so they dont they've got the problem.
    I really dont know what the problem is anymore, is it windows, is it certain 1394 devices, or is it the Via chipset. I havent a clue, so if anyone wants to attempt to solve this problem once and forall they will be the hero of about 3000 potential customers...
    Anyone?
    Jon.

    Yes thats correct.   Regardless of the hardware, and various 1394 devices are recognised. I've bought a 4pin to 4pin cable which i will test with different devices to see if they are consistent with a 6pin to 4pin cable, it may be a power issue. Not sure what chip on pci card, heres the info from website.
    - Three external 6-pin FireWire ports
    - Interoperable with existing, as well as older, 1394 consumer electronics and peripheral products
    - Complies with OHCI requirements
    - Compliant with IEEE 1394a-2000 standard
    - Isochronous transfer support (guaranteed bandwidth) for DV video data transfer from Camcorder to PC
    - Provides three fully compliant cable ports, each supporting 400Mbits/sec, 200Mbits/sec and 100Mbits/sec traffic
    - Plug and Play & Hot-Swappable for all ports
    - Power overload and protection failure on each port
    - PCI bus master with PCI 2.2 Bus specification
     

  • I have just downloaded OSX Mavericks and am having a lot of problems with my iCloud account. I get a message "this iMac can't connect to iCloud because of a problem with (and then it quoted my e-mail address) Does anybody know what the problem could be??

    As mentioned above I have just downloaded OSX Maverick to my iMac. I am now having a lot of problems with iCloud. I get the message that "This iMac can't connect to iCloud because of a problem with, and then it goes on to quote my e-mail address. It then says to open iCloud preferences to fix this problem.
    I do this and no matter what I seem to do this message continues to return.
    Can anybody explain how to resolve this problem (please bear in mind that I am noy very computer literate).
    Many thanks
    Mike

    Hello John
    Sorry I haven't got back to you sooner.
    Thanks very much for your help, your solution solved my problem.
    Thanks again and kind regards
    Mike

  • JAN 4, 2012  As of the  Upgrade to   Lion,. and the  Email portion, ..   DOES NOT  allow a Video Clip to be sent via the Email  as the I-Photo is not supported by Video Clips  ( Previous Leopard  No problem  clip and drag  via Quick Time Pro to the email

    JAN 4, 2012 
    As of the  Upgrade to   Lion,.   2007  I-Mac  -   the  Email portion, ..   DOES NOT    allow a Video Clips to be sent via the Email 
    as the I-Photo is not supported by Video Clips  ( Previous Leopard ) 
    No problem  clip and drag  via Quick Time Pro to the email  and select the  Attchment  size to send. .  Depending on the 
    Size of the Video Clip  ..      Now  Lion only  Export's   1 size, .   only  and as a result . . teh  File is  TOO  Large and
    Will NOT  send via  E-Mail    ??? 
    Between the   Issue of   the   Lion,  and  Email  issues ,   and  the   Upgrade  of   I-Touch  to  5.1  from  4.2.1 
    as my  Photo  Size is  Huge ..    70,000  +  photos in the  Computer. .   and was   40,000  in the   I - Touch  .. .  
    The  New I-Touch  too will not Load the  same  as Previously  used  on  either  my  16 GB   or  32 GB   Unit . . 
              No Help . ..   so far, ..  as a Apple user   since   1996 ..    I  have Never  experieanced such  frustration    ??? 
                   (  any one have some help  if similar  experiances    ?     thank you     )

    JAN 4, 2012 
    As of the  Upgrade to   Lion,.   2007  I-Mac  -   the  Email portion, ..   DOES NOT    allow a Video Clips to be sent via the Email 
    as the I-Photo is not supported by Video Clips  ( Previous Leopard ) 
    No problem  clip and drag  via Quick Time Pro to the email  and select the  Attchment  size to send. .  Depending on the 
    Size of the Video Clip  ..      Now  Lion only  Export's   1 size, .   only  and as a result . . teh  File is  TOO  Large and
    Will NOT  send via  E-Mail    ??? 
    Between the   Issue of   the   Lion,  and  Email  issues ,   and  the   Upgrade  of   I-Touch  to  5.1  from  4.2.1 
    as my  Photo  Size is  Huge ..    70,000  +  photos in the  Computer. .   and was   40,000  in the   I - Touch  .. .  
    The  New I-Touch  too will not Load the  same  as Previously  used  on  either  my  16 GB   or  32 GB   Unit . . 
              No Help . ..   so far, ..  as a Apple user   since   1996 ..    I  have Never  experieanced such  frustration    ??? 
                   (  any one have some help  if similar  experiances    ?     thank you     )

  • I tried to restore my iphone but when it was restoring it said a problem occurred and now it just shows the itunes symbole and its telling me to connect to it but when i try to it  doesnt show up on my computer

    i tried to restore my iphone but when it was restoring it said a problem occurred and now it just shows the itunes symbole and its telling me to connect to it but when i try to it  doesnt show up on my computer

    Hi there starbaeza,
    You may find the information in the article below helpful.
    iOS: Forgotten passcode or device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    -Griff W. 

  • Hi I am having problems downloading and updating apps on my iPad and iPhone. The message cycles between waiting and loading then I get an error message saying unable to download app. Eventually,after many attempts it works.

    Hi Guys - for a few days I have been having problems downloading and updating apps on my iPad and iPhone. The message cycles between waiting and downloading then eventually says unable to download app. Sometimes after many attempts it wil eventually work. I tested it on an old iPhone 3G and got the same problem so it is not an iOS 5 issue. My WI-FI connection is working fine. I was wondering if this is an App Store problem? Anyone else in the UK having this problem?

    Hi John
    iTunes Support wasn't of any use to me.
    I have also been having another problem - with BBC iPlayer and other video streaming not working due to insufficient bandwidth, despite my overall download speed being consistently around 50Gb.  This is also affecting AppleTV downloads
    I am using Virgin Media as my ISP, and was wondering whether you do as well.  This might be the common thread.
    -Bernard

  • WIJ 20002 xml Parser Problem - Rich Client

    Hi,
    I have a problem with the rich client on a new installation:
    Business Objects Enterprise XI 3.1 SP3 on Windows 2008 Standard.
    If I connect with the rich client "import document"is disabled.
    if I try to create a new document from the rich client it returns the error below (I used the rich client on two workstations):
    WIJ 20002
    Version: null
    Analisi dello stack:
    java.lang.RuntimeException: java.lang.RuntimeException: XML parser problem:
    XMLJaxpParser.parse(): Element type "ABOUT_Patentnumbers" must be followed by either attribute specification, ">" or "/>".
    at com.businessobjects.wp.xml.jaxp.XMLJaxpParser.parse (Unknown Source)
    at.com.businessobjects.webi.richclient.XMLviaOccaRC.getServerConfiguration (Unknown Source)
    Have you any solution?

    The fixpack 3.5 client resolves the problem.

  • Trying to start itunes - message appears "APSDAEMON.EXE MSVCR80.DLL is missing.  Then another box indicates "Error 7 (Windows error 126).  Itunes will not start.  Can someone tell me what the problem is and how to fix?

    when I tried to update to the new version of Itunes - message box appears "APSDAEMON.EXE MSVCR80.DLL is missing".  Then another box indicates "Error 7 (Windows error 126)".  Itunes will not start.  Can someone tell me what the problem is and how to fix?

    Solving the iTunes Installation Problems in Windows
    1. Apple has posted their solution here: iTunes 11.1.4 for Windows- Unable to install or open - MSVCR80 issue.
    2. If the Apple article does not fully resolve the problem for you, then try Troubleshooting issues with iTunes for Windows updates - MSVCR80.

Maybe you are looking for

  • Error in at line-selection event...

    Hello experts, In my report, I am hiding the values of BUKRS, ANLN1 and ANLN2 during my loop. I am using field symbols as my work area for my itab which is it_output. The problem is, when I try to do this in my at line-selection event: at line-select

  • Linking HTML and CSS

    This should be simple, but it's not responding.  I've checked it dozens of times.  I have the CSS and HTML in the same folder.  I go to the index.html tab and go to "link CSS."  I navigate to the css file but what shows up in the "File/URL" window is

  • Apple G4

    Hello all,,i want someone to help me plz i need to know if the fcp7 is compatible with apple G4 or not ,,of course for a home use not in a prof. way ,,thanks Karim

  • PLD - Line Text

    Hi Members, I want to include the line text in the PLD of sale order. I need to include the line text  after the item description is displayed. I am getting the line text in PLD but its not in proper order. I need to show the line text after item des

  • Record Center Archival Strategy/Best Practise

    I am familiar with record center but I would like some guidance on how to do some of the things. Scenario : We have 4 site collections, 2 site collections are containing team sites which are built for different departments and one site collection is