Help. HTMLDocument.getElement(id) doesn't work, return me null.

i think the method getElement(String id) would get me the whole tag with the specific id, but it returns me null value. The following is my html and a test program. What's wrong with it? Please Help. Thank you very much.
here is my boo.html file
<html>
<body>
<p id=abc> hello </p>
</body>
</html>
here is my little test program
import javax.swing.JEditorPane;
import javax.swing.text.Element;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
public class Boo{
private JEditorPane editorpane = new JEditorPane();
private HTMLDocument doc;
public Boo(){
     try{
editorpane.setPage(getClass().getResource("boo.html"));
} catch (Exception e) {e.printStackTrace();}
     doc = (HTMLDocument) editorpane.getDocument();
     System.out.println(doc);
     Element el = doc.getElement("abc");
     System.out.println(el);
public static void main(String[] args) {
Boo bo = new Boo();
System.exit(0);
here is the result:
ey@troy:/work/ey> java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ey@troy:/work/ey> java Boo
javax.swing.text.html.HTMLDocument@b753f8
null

thanks hiwa, i saw you replied my thread from javaworld as well.
and i tried your code, which utilises a JFrame to make my program a GUI program. but it turns out still not working, still return me null value.
and i tried the following code, which will definitely return me the right thing:
try{
          editorpane.setPage("file:///work/ams/bightml.html");
             doc = (HTMLDocument) editorpane.getDocument();
      } catch (Exception e) {e.printStackTrace();}
     System.out.println(doc);
     Element el = null;
     el = doc.getElement("D");
        int i=0;
     while (el == null){
          try{
               Thread.sleep(i*500);
               el = doc.getElement("D");
               } catch (Exception e) {e.printStackTrace();}
                i++;       
     System.out.println(el);From the code, the "bightml.html" is an html file which has a table with 1000 lines. and i tagged some of the <td> with IDs. i found out it will take more time for the program to locate the tag towards the end of the html.
And i also find out: in the following codes, if you make the thread sleep some time after the first line, the result of the second line will give you more:
      doc = (HTMLDocument) editorpane.getDocument();
      System.out.println(doc.getText(0, doc.getLength()));and this also make me think, the " doc = (HTMLDocument) editorpane.getDocument();" is not thread save as well.
anyone knows something about this?
oh, did i mention my machine? it's a P4 2.4G running under Suse 9.1 with java 1.5.0_01.
Thanks.

Similar Messages

  • Help! My iMessage doesn't work on my new iPhone 5s, I've changed my sim twice, but iMessage only works with my Apple ID.

    Recently got a new iPhone 5s and the iMessage doesn't work. I tried the sim in another phone and it didn't work either so I put a completely new sim in my iPhone and iMessage doesn't work. It will only work when I use my Apple ID for received messages. I don't know what to do. I have reset everything and it still doesn't work. My software is up to date. Please help!

    ACTIVATING FACETIME AND IMESSAGES
    Activating Facetime and Imessages on your phone requires the ability to send SMS messages and depending upon where you are that might be an international SMS.  Check with your carrier to see if your plan supports sending of international SMS messages.  If you are having trouble activating Facetime or Imessages turn them both off on your device and reset the device (Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for device to restart (no data will be lost)).  Wait for the device to restart and wait a minute and turn Facetime and imessage back on and wait for activation.  If that does not fix things read the following articles:
    http://support.apple.com/kb/TS4268
    http://support.apple.com/kb/ts3367

  • Help with Youtubevideo which doesn't work in internetexplorer

    Hi there,
    I'd tried to implement a youtube video  guided by this :  http://www.heathrowe.com/adobe-edge-preview-4-append-youtube-video/
    It worked fine  in firefox and chrome  but  it doesn't work in internetexplorer :-(
    Is there a way to modify the code so it would work in all browsers?
    I also tried a hint via google  to change the codepart   .....      $("<iframe type='text/html'     .....     to   ....    $("<iframe type='application/x-shockwave-flash'
    but it didn't work either...so I'm stuck now
    Thanks for your help
    Greetings
    martin

    Thanks Schrene,
    strange...i opened it online from my notebook in IE  and it worked...but my workstation has the same IE Version  9.0822  etc.. and it does not work from there...
    well...anway... basicly  it works :-)
    thx :-)
    Martin

  • Help! photo booth doesn't work

    There's nothing happen when i click on the photo booth icon on dock. I tried to use my isight another application and it works. So i tried to reinstall it with the DVD. It doesn't work also. anyone know how to resolve this problem? >""<

    To Apple Discussions!
    Repair permissions & restart your computer.
    It would be very helpful if you would supply which OS version you are using by completing My Settings over here in the right column.--->
    It would help in providing you w/the correct troubleshooting solutions.

  • Help: v('p1_test'):=1; doesn't work why?

    I want to update states on p34_level_1, 2, 3, 4 etc..
    But it seems I can use v('p34_level_1') one way?
    for example:
    Variable_Value:= v('p34_level_1'); -- <----works correctly
    but I cant go:
    v('p34_level_1'):= Variable_Value; -- <----DOESN'T work
    Below show my code basically i want to loop through some fields and update the contents with values,
    any ideas? or suggestions?
    I get this error:
    ORA-06550: line 17, column 28: PLS-00103: Encountered the symbol ":" when expecting one of the following: := . ( % ;
    declare
    count_levels number(12,0);
    begin
    -- Count levels
    select count(level_id)
    into count_levels
    from wi_ccqual_level
    where bu = :p1_buid;
    -- update page
    FOR i IN 1 .. count_levels
    LOOP
    v('P34_LEVEL_' || i): = i;
    --i = i;
    END LOOP;
    END;

    Hi Vanadium
    Function v('ITEM') just reads item values from APEX environment.
    If you want to update item values from PL/SQL you should use apex_util.set_session_state API
    Syntax: apex_util.set_session_state(item,value)
    So you should write: apex_util.set_session_state('P34_LEVEL_'||i , i );
    I hope this helps you
    Oscar

  • Help with fuzzy search (doesn't work if change order of certain 2 letters)

    Hi,
    need some help with fuzzy search. It's pretty simple - we use fuzzy search on varchar2 columns that contain first name and last_name. The problem is that i don't really understand why it can't find name in some cases.
    Say i want to search for 'Taekpaul'. Then
    where CONTAINS(first_name,'fuzzy(TAEKPAUL)',1) > 0 - works
    where CONTAINS(first_name,'fuzzy(TAEKPALU)',1) > 0 - works (changed order of the 2 last letters)
    where CONTAINS(first_name,'fuzzy(TEAKPAUL)',1) > 0 - doesn't work, finds 'Tejpaul' that is completely unrelated (changed 2nd, 3rd order)
    How can i make it find 'Taekpaul' even if i search for TEAKPAUL? Is it related to index? Like Text index should be created with some different parameters?
    Thanks!
    Edited by: Maitreya2 on Mar 3, 2010 2:08 PM

    Thanks, adding '!' worked :)
    Do you know where i can read more about '!' and other special characters? I think i didn't see anything like that here: http://download.oracle.com/docs/cd/B14117_01/text.101/b10730/cqoper.htm#BABBJGFJ
    I also started using JARO_WINKLER_SIMILARITY function that is actually better i think for what i do. But it's very buggy - sometimes Oracle crashes and kills connection when you try to use it.
    Ahha, it's here: http://download.oracle.com/docs/cd/B19306_01/text.102/b14218/cqspcl.htm
    So, ! is soundex. Whatever it means..
    Edited by: Maitreya2 on Mar 5, 2010 12:14 PM

  • Help! IPOD clickwheel doesn't work!

    hi guys,
    I just wanna get some help..
    I dropped my IPOD last night,
    then the IPOD itself, its working..
    But the clickwheel doesnt even work..
    The display clearly shows up, the hold button completely works, but the clickwheel doesn't work..
    what shall i do?
    please help me...

    Plz I need help.

  • [Need Help ] My swf file doesn't work,but preview work ?

    Hi... I'm new in Adobe flash CS3 , When i try to open up preview ,my project work just fine, but after exporting ,my movie keep on running, i've been trying  with the simple file,and it doesn't work too.
    This is the fila file and the exporting result 
    http://www.mediafire.com/?4433nrlo3z88dhj

    Most people are not willing to download files, and using a service like medifire lessens the chances (a viral-behaving site).  You will increase your chances of geting help if you explain the details of your design, what is not working, and provide any relevant code in your posting.  A link to demo the failed functioning swf could be helpful as well.

  • Help please - Flash player doesn't work, windows 7

    Hi
    My flash player has stopped working.  I can download the latest version 10.2.152.32 and it says it has installed successfully.  When I try to view a web page it either says i need the latest version and takes me back through the latest update successfully but still doesnt work or it just has an empty box with a red cross in the top left corner.
    I cannot find it flash player by searching for it on my computer.  I have unistalled and reinstalled it several times and it still doesn't work.
    I have tried looking for it in manage addons but it is not listed, only shockwave active x which is enabled.
    I have no idea what to do next.  I am using windows 7 32bit.
    Thanks in advance.
    Paul.

    Hi
    Thanks for the reply.
    In the flash folder in syswow64 there is: flash10n.ocx, flashinstall,flashutil10n_activex.dll and flashutil10n_activex.
    I followed all of the instructions for install and uninstall on the other thread, i ran the malware that you linked to and it found some affected files whichI removed but still not able to run flash despite it saying it installed correctly.
    I hope you can help, thanks.

  • Please help! connection.rollback() doesn't work for me.

    I have two updates to the database. If either one fails, all the changes should be rolled back.
    I set the auto commit to false before the updates started and invoked rollback() if any exception was caught.
    During the execution of the program, an exception was caught. And one table got updated and the other didn't.
    I can see "TRYING TO ROLLBACK~!!!! ROLLBACK!!!" and "ROLLBACK FINISHED!!!" printed out. But the change made to
    one table did not get rolled back.
    And I tried to call rollback() right after the first update was made. But it didn't rollback the changes made
    to the database.
    Why doesn't the rollback() work?
    Development environment:
    Database:     MySQL Server 4.1
    jdbc driver:      mysql-connector-java-3.1.8
    JDK:          jdk1.5.0_04
              Connection connection = dbConn.getDBConnection();
              String insertDummy1= "insert into dummy1 values(?)";
              String insertDummy2 = "insert into dummy 2 values(?)";
              PreparedStatement psCA = null;
              PreparedStatement psCD = null;
              try {               
                   connection.setAutoCommit( false );
                   psCA = connection.prepareStatement( insertClientAccount );
                   psCA.setString(1, cName);               
                   psCA.executeUpdate();
                   psCA.close();                         
                   // connection.rollback();
                   psCD = connection.prepareStatement( insertClientDetail );
                   psCD.setString(1, cName);               
                   psCD.executeUpdate();               
                   psCD.close();
                   connection.commit();
              } catch(Exception e){
                   if( connection != null ) {
                        try {
                             System.out.println("TRYING TO ROLLBACK~!!!! ROLLBACK!!!");
                             connection.rollback();
                             System.out.println("ROLLBACK FINISHED!!!");
                        } catch(Exception ex) {
                             System.out.println("Exception!! try to roll back >>> " + ex.getMessage() );
                             ex.printStackTrace();
                   processResult = "Failed to complete the process. " + e.getMessage();
                   System.out.println("Exception!! >>> " + e.getMessage() );
                   e.printStackTrace();
              } finally {                                             
                   psCA = null;
                   psCD = null;
                   try{
                        connection.close();
                   } catch(Exception e){
                        System.out.println("Exception!! >>> " + e.getMessage() );
                        e.printStackTrace();
                   return processResult;
              } // try

    In MySQL, there are several different storeage engines/table types. Some of these table tables support transactions (and therefore commit() and rollback() ) and some do not. I believe that if you use a non-transactional table type, it's effectively the same as having autocommit=true (and commit() and rollback() are then silently ignored).
    See:
    http://www.developer.com/db/article.php/2235521
    http://dev.mysql.com/doc/mysql/en/storage-engines.html
    I have used the InnoDB storeage engine and have had no issues with transactionality.

  • Urgent help: why smtp authenticator doesn't work ?

    Please help me :
    My smtp server authenticates me whether a valid user when I send email. I have had setup an authenticator as following :
    //Setup authenticator
    Authenticator auth = new SMTPAuthenticator();
    // Get session
    Session session = Session.getDefaultInstance(props, auth);
    class SMTPAuthenticator extends Authenticator
    public PasswordAuthentication getPasswordAuthentication()
    String username="userid";
    String password="passwd";
    return new PasswordAuthentication(username, password);
    But It still prompted error with noting me:" login fail, this smtp server authentication required ".What's the problem?
    I'm a valid user in this smtp server. and the userid and passwd has no error, for it worked well when I used them to setup win2000 outlook express.
    I also tried to used authenticated javax.mail.Service's connect .
    Transport transport = session.getTransport("smtp");
    transport.connect(smtphost, username, password);
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
    but it didn't work yet ! If I use Authenticator ,is it still necessary to use connect(smtphost, username, password) ?
    Urgently, Please help me, any source code practising well with authenticating smtp server , please send it to [email protected]
    Thanks

    Just use " props.put("mail.smtp.auth", "true");"

  • My answer to the friends  who are helping me,but it doesn't work........

    its not working...
    what I did is.....
    I start I tunes ,make connection with IPAD,(hear a signe ) but cannot see on my screen(pc-screen)where the IPAD is ????
    I see only an externe disk and a dvd .......but NO   IPAD
    Ican see up( in the corner)...."I PAD".....I click on it ,and click on "photo's"...
    Then I remove de little"v" by syncronisatie".....and "foto's out "
    I click on "synchroniseren"and thats it ...."
    After this there is nothing anymore;;;;;
    You can help me (maybe) with desings or fhoto's where i can SEE it what i have to do.....or a clear explication in Netherlands or french.....
    What means the words;"synced" and "Photos app" re-sync"?And what means :it:"move/remove/de-select;" in slow motion ....and with more explaining words....
    I'm 70 jrs old ,not good in english and not good in I pads
    of cource it is not easy to work with a IPAD 1 when there is'n an explication in your own language
    Thanks !! and I 'm waiting for more help 
    ANNA-LOUISA

    It makes things easier if you reply on your original thread rather than starting a new one - you should see a 'reply' button at the bottom of each post.
    How did the photos get onto your iPad e.g. were they copied to the iPad from your computer ? If not then you should be able to delete them directly in the Photos app on your iPad. If they were copied from your computer then they are removed from the iPad using the same process as you used to put them onto the iPad :
    Connect the iPad to your computer and select it on the left-hand sidebar (if you are using iTunes 11 on your PC then control-s should get the sidebar to show) :
    On the right-hand side of the iTunes screen select the Photos tab :
    If you just want to remove some folders/albums that you had copied from your computer then de-select them on the list :
    If you want to remove all photos that you had copied to your iPad from your computer then select and sync a folder that doesn't have any photos in it :

  • My ipod turned off and won't turn back on, help! Home button doesn't work and neither does Recboot!

    Hello! So I've had my Generation 5 IPOD for nearly two years. Tonight after a shower I tried to charge my IPOD (thinking it had just died because it was short on battery anyway) but it didn't turn on. I would reboot it by pressing the power and home button but sad to say, my home button stopped working about a month ago. : ( After this, I tried connecting it to a charger, two computers AND I downloaded Recboot with the extensions for a PC/Windows, it still did not want to connect. I'm not sure what to do besides maybe taking it to a Apple Store and getting the home button fixed and try to reboot it manually as I always have in the past. Any advice? Right now it's black with no signs of connecting to any machines. If I can't get the home button fixed, could I wait until the battery drains for it to just get recharge? If so how long does it take for the IPOD battery to just die so I can do this? Granted it was always sorta dying before this happened (it was red.) so it shouldn't or wouldn't take too long right?
    Please! : ( Any help would be appreciated. I live in a small town and the closet Apple store is about an hour away.

    If the screen and iPod does not show any life then letting the batter drain will not do anything.
    If you tried another cable and tried ReBoot on another computer and still problem then your iPod has to be repaired/replaced
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar

  • Help! my bluetooth doesn't work at college

    I have a PowerBook G4 with a wireless mouse. I also have a USB bluetooth adapter for my HP photosmart 8150 printer. Both worked fine when I was at my house, and now that I am at college, neither work! My Bluetooth is always unavaible, and I do not understand why. There is a public wireless network here that we use as well as the ethernet one. One of my friends in a dorm without the wireless has the mouse, and hers works perfectly. Is the wireless network interfering? I used wireless at my house, and it worked fine! Help, I don't understand the details of Bluetooth. Thank you!

    Hello catalina:
    Welcome to Apple discussions.
    There are several possibilities. The college wireless network could be causing some interference. Try this:
    Unplug everything from your computer. Take the battery out for awhile (I know, this sounds a bit hokey, but I have read that this can help). Start your computer. If the Bluetooth icon is missing, it could have failed (I am assuming you have a built-in Bluetooth module).
    Oh, make sure that the Bluetooth module was not shut off by accident.
    Barry

  • Help! My pan doesn't work..

    I have a PreSonus inteface and Logic pro 9 . Everything works great except when I pan
    tracks I hear no panning going on. The display appears to be panning the track but
    it is not happening audibly, not on my headphones either.
    This is probably something so easy to do that I am overlooking. Please advise!

    tenorhighc wrote:
    I have a PreSonus inteface and Logic pro 9 . Everything works great except when I pan
    tracks I hear no panning going on. The display appears to be panning the track but
    it is not happening audibly, not on my headphones either.
    This is probably something so easy to do that I am overlooking. Please advise!
    It's déjà vu all over again!
    http://discussions.apple.com/thread.jspa?threadID=2541466&tstart=45
    See if this helps.
    pancenter-

Maybe you are looking for