Getting the title of an HTML document displayed inside a JEDitorPane

Hello everybody,
I am currently working on an HTML help file browser displaying the document inside a JEditorPane. Now I wanna do this: get the current document's title (inside <title>...</title>) and set the title of the JInternalFrame containing the editor pane (MDI - I know) to the document title mentioned.
Setting the JInternalFrame title is not a problem, but when I tried to extract the title of the document, several attempts failed:
String content = hypertextPane.getText();Applying this method gave me the following content:
<html>
  <head>
  </head>
  <body>
    <p>
    </p>
  </body>
</html>Looks somehow meager... :-X
Document currentDoc = hypertextPane.getDocument();The "document" this method returned only consisted of HTML and BIDI ROOT as root elements, and HTML had only one child element: BODY.
And the attempt
docTitle = currentDoc.getProperty(Document.TitleProperty);simply returned NULL. :-(
The editor pane's editor kit is:
new javax.swing.text.html.HTMLEditorKit()The default content type is, of course, text/html, and I never display a document which is not HTML with my editor pane.
Can please anybody help me? Thanks a lot!
Regards
Jacek.

getProperty(Document.TitleProperty) does NOT work in
my application. Here is the method I wrote for
extracting the document title:
* Returns the title of the document currently
ntly displayed by the browser
* @return <ul><li>the document's title<tt> -
t> - </tt>if such a title
*                 exists</li>
*             <li><tt>null - </tt>otherwise</li>
*         </ul>
public String getDocumentTitle() {
String content = new String();
String title = new String();
title = (String) ((HTMLDocument)
cument) hypertextPane.getDocument()).
getProperty(Document.TitleProperty);
return (title);
}The HTML pages I display with my browser all do have a
<title>...</title>. However, my method keeps returning
NULL all the time.
I built my browser with JDK 1.3.1 LINUX i586, but I
tested it with both 1.3.1 and 1.4.1. The results are
always the same. :-(
I think the promblem is, that getProperty(Document.TitleProperty) returns null until the document is loaded completly (this happens assynchronly). Add the following code to handle this issue:
        hypertextPane.addPropertyChangeListener( new PropertyChangeListener()
                    public void propertyChange( PropertyChangeEvent e )
                    if( e.getPropertyName().equals( "page" ) )
                        title = hypertextPane.getDocument().getProperty(Document.TitleProperty).toString();
                } );I use it this way

Similar Messages

  • Whenever I open Reddit, I get the pop up, "Firefox HTML Document (0 bytes)" which asks for my permission to be downloaded. On Cricinfo, I get a similar pop up.

    On Reddit, whenever I open any page, I get this popup:
    http://i.imgur.com/3bBpw42.png
    On Cricinfo, I get a similar popup:
    http://i.imgur.com/im3tpqN.png
    This would also occur on other websites, but these are the two of the websites that I frequent a lot more. The problem is, even if I click on "Do this automatically..." button, all what it eventually does is that all such files gets saved in the default "download" folder which slows my system down. Help?

    Hello,
    This behavior is not the right behavior - neither of these sites would prompt you to download any files when you visit them. Can you please check if this happens when you open Firefox in safe mode too. Instructions for running Firefox in safe mode are below
    Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac you can open Firefox 4.0+ in Safe Mode by holding the '''option''' key while starting Firefox.
    * On Linux you can open Firefox 4.0+ in Safe Mode by quitting Firefox and then going to your Terminal and running: firefox -safe-mode (you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • How to change the title of an existing document?

    I have looked in online manuals and there are no headings for this.  I wish to change the title of an existing documents but can find no way to do so.  Any one have help on this? 

    You can also change the file name in Finder.
    peter

  • How to get the Title and Tcode of a Program during run time

    Hello,
    I am new to abap and I have this question please. Is the a way to get the title, Tcode and Author of a program during run time? I would like to get the name and title of a program or a view or an include during run time.
    Using table TADIR, you can only get the object_name and the author. Is the a way for me to get the Title of the repository object and any Tcode if any is available for the case of a program?
    I loop forward for your respond.
    Thank you.
    Sabina

    You can get it by accessing SYST.
    SY-TITLE for Title
    SY-TCODE for Tcode
    I don't think there is any field in SYST for the Author.
    To get the author name you can use the TRDIR table.
    Regards,
    Naimesh Patel

  • How to get the link of already archived document

    Dear all,
    How to get the link of already archivied document. for example i have a sales order for which subsequent documents have been archived. now i want to get the link of subsequent document.
    please give some solution
    Thanks in advance
    Thanks,
    Hemachandran.

    Hemachandran,
                The archiving object for sales order is SD_VBAK. If you run the program S3VBAKAU by transaction se38 and search based on the document numbers ( as you mentioned it is the preceeding document numbers to the current document), you will be able to retrieve the information regarding the previous sales orders.
    More information on the sales order archiving object can be found at,
    http://help.sap.com/saphelp_45b/helpdata/en/a9/55c7b690a111d1a5510000e82deaaa/content.htm
    Sojan
    <<text removed by moderator>>
    Edited by: Matt on Nov 16, 2008 5:08 PM - Do not request points

  • Get the title of a specific window not part of your app

    For an app I am writing I need to get the name of the titles of the current programs running .
    Does anyone know of a way to accomplish this (get the title of a specific window not part of your app) in Java?
    Thank you very much.
    Erik

    Crossposted, obviously with no concern over wasting the time of would-be answerers.
    http://forum.java.sun.com/thread.jspa?threadID=686650

  • How to get the size of JSP html output?

    Hi,
    Is there a JSP method to get the size of JSP HTML output.
    e.g. I would like to print the size of the JSP e.g.
    Size of this page is <%=pageContext.getPageSize()%> Kb ???
    Any ideas? Thanks.
    George
    Edited by: googchro on Jan 5, 2010 4:45 PM

    Would you like to print "the size of this page is..." before or after you calculate the size of the page.
    Because adding that bit of text to the page will make the page bigger...
    Doing it in java, the best approach would probably to have a filter counting the number of bytes that gets sent to the writer/output stream.
    A client side tool measuring the amount of bytes received would probably be easier though.
    You can always look at the Content-length header sent with a response. Though you normally don't have access to that on the java/jsp side, as it is sent by the container.
    cheers,
    evnafets

  • When I select a title in the iTunes Store and click on Play in iTunes I am sent to the download page for iTunes 10 which I have already. The selected title cannot be found anywhere in my iTunes. How can I get the title in iTunes with possibility to buy it

    When I select a title in the iTunes Store and click on Play in iTunes I am sent to the download page for iTunes 10 which I have already. The selected title cannot be found anywhere in my iTunes. How can I get the title in iTunes with possibility to buy it?

    The issue is that your credit or debit card credentials must be associated with the same country where you reside in order to purchase iTunes content.
    "Although you can browse the iTunes Store in any country without being signed in, you can only purchase content from the iTunes Store for your own country. This is enforced via the billing address associated with your credit card or other payment method that you use with the iTunes Store, rather than your actual geographic location. You can use the iTunes Store in all countries of which you’re a resident, but you’ll either need a separate iTunes Store account for each one, or you’ll need to continually be switching the billing information on your single account. Generally, it’s simpler just to set up an alternative account for these situations, although it’s worth nothing that features like iTunes in the CLoud and iTunes Match are designed to work best when using a single iTunes Store account, as you can only switch accounts with these services every 90 days."
    From here >  The Complete Guide to Using the iTunes Store | iLounge Article

  • Does anyone get the mouse lag with an external display connected via the display port?

    does anyone get the mouse lag with an external display connected via the display port?

    You don't describe the problem in great detail.  Is this the issue you are describing?
    https://discussions.apple.com/thread/4398076?start=0&tstart=0
    If so, then, "Yes."  I have the same problem.  Note that this isn't a tracking speed problem for me, it's a lag between my hand moving and the pointer moving on the external display.
    Andrew

  • How do I get the reminders, in list view, to display in date order?

    How do I get the reminders, in list view, to display in date order? I can't seem to get them to display in date order on either my ipad or iphone.
    Yes i know I can look at date view, but i don't like that view. I excepted the list view to display all reminders in date order.
    Thanks!

    You need to create a stringwriter, wrap it in a printwriter, then print to the printwriter, then convert the stringwriter to a string.
    Here's an example:
    StringWriter sw = new java.io.StringWriter();
    PrintWriter pw = new java.io.PrintWriter(sw);
    e.printStackTrace(pw);
    String strError = sw.toString();
    I hope this works. I didn't test the above code. I don't think I'm leaving anything out, but it's been a while since I've done it. Either way, it should get you on the right track to get what you need.
    Hope that helps.
    Michael

  • Will not restore or connec to itunes - just get the itunes logo and usb cale display on screen

    ipod touch will not restore or connec to itunes - just get the itunes logo and usb cable display on screen

    Hello...Any help? i cannot be the only person with this problem. My coworker is actually dealing with the same problem!!!!
    As an update i uninstalled and reinstalled all ipod updates and Itunes completely. Still only have the folder with exclmation point problem. I have followed all of Apple Ipods websites support tips. no luck..
    Please help...

  • Trying to import cd, it only shows tracks, not song titles. when i try and get the titles it says im not registered for online use even though im signed in. how can i fix this?

    Im trying to import songs from a cd, but it only shows track numbers, no title of songs.when it try to get the titles it gives error code saying im not registered for online use. i am signed into my account so i dont know how to fix this.

    The "not recognized for on-line use" error is associated with the Gracenote service that iTunes uses to look up and retrieve metadata for CDs.  Some users have reported that this error occurs when trying to import from CD, subsequent to upgrading to version 12.  A number of slightly different solutions have been reported (though all of a similar nature).
    Try walking through the following steps - before starting you may have to enable hidden files and folders to be viewed - in Windows 7 / Windows Explorer select Organize > Folder and search options, then on the View tab make sure that Show hidden files, folders and drives is selected.  Without this you won't see the AppData folder in C:\Users\username\.
    Exit iTunes
    In Windows Explorer, go to the folder C:\Users\username\AppData\Roaming\Apple Computer\iTunes
    Delete the following files:
    CD Info.cidb
    com.apple.iTunes.Gracenote.plist
    Restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    If this doesn't work: 
    In iTunes, select Edit > Preferences and make a note (or take a screenshot) of your preferences settings in all relevant tabs
    Exit iTunes
    In Windows Explorer, go to the folder C:\Users\username\AppData\Roaming\Apple Computer\iTunes
    Delete the following file:iTunesPrefs.xml
    Restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    If this second procedure does work, you'll need to restore other iTunes preferences settings to those that you noted in step 1.
    If this one didn't work: 
    Exit iTunes
    Check the following folders:
    C:\Users\username\AppData\Local\Apple Computer\iTunes
    C:\Users\username\AppData\LocalLow\Apple Computer\iTunes
    Delete any copies of the following files:
    CD Info.cidb
    com.apple.iTunes.Gracenote.plist
    iTunesPrefs.xml
    Restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    Again, if this procedure does work, you'll need to restore other iTunes preferences settings to those that you noted in step 1 of the second procedure. 
    If you're still not able to retrieve CD info: 
    Exit iTunes
    In Windows, select Start > Control Panel > Programs and Features.  Find the entry for iTunes, right-click and select Repair.
    When this process has finished, restart iTunes
    Insert a CD and see if details are now correctly retrieved from Gracenote
    If none of these have worked (and almost everything I've seen suggests you should be OK by this point), you may have an issue with the installation and configuration of iTunes itself.  If you have got this far, see turingtest2's notes on Troubleshooting issues with iTunes for Windows updates for advice on how to remove and replace of all components of iTunes.

  • Use DOM to get the element value of XML document?

    I can not to use the method getNodeValue to get the element value of XML document. How can I do for it?
    For example, for element
    <address>125 Smith Avenue</address>
    how to get the value "125 Smith Avenue" by using DOM?
    Thanks

    Thanks for all of you.
    The code indicates that I need to get the node by tag name. If I do not know the distribution of the elements and want to traverse all nodes. If the node contains value, I retrieve the value. How to implement the general case.
    For example, my XML file represent a directory hierarchy and looks like
    <root>
    <usr>
    <user>user1
    <file>file1</file>
    <file>file2</file>
    </user>
    <user>user2
    <file>file1</file>
    <file>file2</file>
    <file>file3</file>
    <file>file4</file>
    </user>
    </usr>
    </root>

  • When I go to duplicate a presentation I get the following error:  Unsaved Keynote Document.  Autosave couldn't be moved because you don't have permission to access AutoSave Information?  My permissions are set at read

    When I go to duplicate a presentation I get the following error:  Unsaved Keynote Document.  Autosave couldn't be moved because you don't have permission to access AutoSave Information?  My permissions are set at read & write.

    I noticed that I have three different log in accounts on my computer, much to my surprise. Could that be causing this problem?
    That's unlikely. You would have had to save a document into another user's account and be trying to work on it - directly from their account.
    "“Unsaved Pages Document.pages” couldn’t be moved because you don’t have permission to access “Autosave Information”.
    Have you checked the permissions on your Autosave Information folder? Here are mine.

  • I only get the top half of my screen displayed in Safari, not sure what I've done and how to correct it

    I only get the top half of my screen displayed when in Safari, not sure how ths has hapened or how to resolve it, any ideas?

    It's not at the bottom of the screen but the Safari pane/window.  Its very small.  See below.
    Ciao.

Maybe you are looking for