Hyperlink in java

Is it possible to create hyperlink in java. If so please give me some suggestions

use
getAppletContext().showDocument
(new URL("URL_TO_YOUR_IMAGE"));
getAppletContext().showDocument
(new URL("http://www.whatever.com"),"HTML FRAME
ID");
If "HTML frame ID" do not exists then a new browser
window will be opened. The following "HTML frame ID"
have special meanings :
"_self" current frame
"_parent" parent frame
"_top" base frame
"_blank" new window
a complete example of a button :
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
ublic class GotoURLButton extends Applet implements
ActionListener {
tton b;
TextField t;
public void init() {
t = new TextField(20);
t.setText("URL_TO_YOUR_IMAGE");
add(t);
b = new Button("Go to this URL");
add(b);
b.addActionListener(this);
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == b) {
try {
getAppletContext().showDocument(new
URL(t.getText()));
catch (Exception e) {
e.printStackTrace();
is this your stock response to every "hyperlink in java" question?? what if the question isn't related to applets? what if it's not even related to web-based code at all?
@OP: you need to be a bit more specific about what you mean by "hyperlink". don't just give me a description of what a hyperlink does ("I want something where you click and it goes to the web page" isn't good enough). where do you want this link to be present? in a swing application? a JSP? an applet? where?

Similar Messages

  • Is there any way to determine if a link is a book mark or hyperlink in java script

    Is there any way to determine if a link is a book mark or hyperlink in java script
    Sub Problem:
    I am making an array of quads of all the hyperlinks in a document. I would like to automatically skip over all the bookmarks in the starting pages of a document and just get the links of the hyperlinks.
    Now I have to manually set the pages that contain bookmarks so they are not included in the array.
    Is there any way to determine if a link is a book mark or hyperlink in java script?
    It would help automate the conversion I need below
    John
    Main Problem:
    I have been working on converting a set of pdf files with 1000’s of hyperlinks like www.site.com\folder1\file1.pdf#page=10
    To jump to a local copy of the files with a relative type link
    ../folder1/file1.pdf and then go to the proper page.
    I have found that it can be done manually by changing the hyperlink to a javascript
    var otherDoc = app.openDoc('../folder1/file1.pdf', this);otherDoc.pageNum = 10 - 1;
    and setting each destination file with a disclose()=true;
    Based on the help so far that java script cannot access the hyperlink value in a link
    See: http://forums.adobe.com/thread/1039908?tstart=60
    I have resorted to the following plan using acrobat javascript, an external keyboard macro recorder and excel in combination to get around the problem
    Four folder level acrobat javascripts with “buttons”
    One to get all the link quads in an array, in the pdf and report the total number
    The second creates a form field in the far corner of the first page and moves there.
    The third jumps to each link found by creating a form field just to the left of the link and zooms in so it can be selected by a “mouse click” from the keyboard macro recorder 
    The forth deletes the form field
    The keyboard macro recorder runs javascript 2 and then 3 then clicks on the link just to the right of the middle of the screen and uses keys to get to the advanced editing to get to edit the hyperlink .
    The hyperlink is then copied to excel where it is converted using string functions to the needed javascript text to be copied back.
    To the acrobat file into a java script (after deleting the hyperlink)
    Rinse/lather/repeat
    I have been able to convert about 150 links an hour.
    Better then hand typing, but not like having java access to the links.
    I am looking to improve the solution

    thanks for your help.
    I may have been confusing a "acrobat bookmark" and a bookmark in a word file that is converted to a pdf and ends up being a
    link of the type:
    "Go to a page in this document"
    which I do not want in my array vs
    a link of the action type:
    "Open a web link"
    Which I do want
    John
    My code, note how I have to skip pages with "Go to a page in this document" links depending on the document, I would like to use the same code for each document and skip over the "Go to a page in this document" links :
    global.ilinkindex = 1; 
    global.aLinkquads = [ [0, 1, 1, 0, 0],
           [0, 0, 0, 0, 0] ];
    function GetLinkArray()
    global.ilinkindex = 1;
    var iTotalLinks=0;
    // for ( var p = 0; p < this.numPages - 8 ; p++)                   // end before bookmarks for each page of the file x.pdf
    //  for ( var p = 0; p < this.numPages; p++)                     // for each page of the file
    for ( var p = 23; p < this.numPages; p++)                     // start after bookmarks for each page of the file y.pdf
      var cropbox = this.getPageBox("Crop", p);
      var alinksonpage = this.getLinks(p, cropbox);            // get array of links on page
      for ( var ll = 0; ll < alinksonpage.length; ll++)
       var linkquads = alinksonpage[ll].rect;     // get link Quads
       linkquads[4] = p;          // add page number to link Quads array
        global.aLinkquads[global.ilinkindex] = linkquads; // add quads to global link Quads array
        global.ilinkindex++;
    iTotalLinks = global.aLinkquads.length - 1;
    global.ilinkindex = 1;
    app.alert("Number of Links in Document is " + iTotalLinks );

  • Hyperlink in java mail

    I want to send hyperlink in java but not able to send it.
    Message msg = new MimeMessage(session);
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText("Initial link\n"+
    "<html><body><A href=\"url\"> Launch</A></body></html>\n\n");
    but it is getting printed as
    <html><body>Launch</body></html>
    actually I want to print Launch and when clicked it should go to url.
    How can I achieve this?

    The preferred approach is:
    MimeBodyPart messageBodyPart = new MImeBodyPart();
    messageBodyPart.setText(message, null, "html");
    If you need to force a particular character set, you can replace "null" with (e.g.) "utf-8".

  • How to implement hyperlink in java using swing components

    hi.....
    pls help me to find out solution
    how to implement hyperlink in java using swing components

    I've got the same problem here.
    I want to implement a HyperlinkListener to a JLabel. (Unlike suggested above, it is only supported by JEditorPane and not JLabel)
    The goal is, that if a user clicks on a Link in a JLabel, the standard browser opens and displays that page.
    Can somebody please help?
    My ultimate goal would be to also be able to add clickable HyperLinks in ToolTip texts, but i guess that'd be even more complicated.

  • Adding a hyperlink in java code

    Please let me know the procedure to add a hyperlink in java code.
    For example, I want to add a link in the following code to the output
    out.write("\n Sum : " + sum);
    Output should be
    Sum : 24
    In the above answer, I need 24 o be displayed as a hyperlink which will redirect me to some webpage on clicking.
    Awaiting the reply.

    Praveen_Forum wrote:
    i guess you are looking for something similar to this
    out.write("<a href = " + url + ">" + you text + "</a>");
    Only problem Praveen is that it makes the assumption that out is writing to a browser as in:
    PrintWriter out = response.getWriter() ;
    out.println("something here") ;
    // etcIf out writes somewhere else that won't work.
    PS.

  • Using hyperlinks in Java Report Viewer

    Hello,
    I want to use the hyperlink function in Java Report Viewer Component.
    In the Crystel Reports Developer Page Preview, I can click on a hyperlink (for example to a website), and a browser will open.
    The same on the Crystal Report Viewer 2008. The same on Crystal Report Web Viewer.
    But it doesn`t work with the Java Report Viewer Component. A click on the hyperlink has no action. Is there a possibility to activate this function, or is it impossible with the java report viewer component.
    I use Crystal Reports XI.
    Thanks in advance,
    Rufushome

    What's the "Java Report Viewer Component"?
    Sincerely,
    Ted Ueda

  • Hyperlink in Java platform

    Hi,
    I hve created parent and child report in parent report i have used Hyperlink after clicking parameter is passing based on that child report is opening.....this linking is possible when i am setting prefrence in Infoview as a Intrective but i am selecting using java portal then reort linking box is not showng where i acan set my hyperlink....
    could you plz guide me wheather report linking by hypelink is possible in java platform If yes than how....
    bz this can be done by Intreactive platform.

    Hi John,
    Thanks for reply of my question,
    I am using BO XI R3.
    this is my syntex which is working on Intreactive Platform but not working on java platform...
    ="<a href=__\"http://scsl-bisrv-01:8080/OpenDocument/opendoc/openDocument.jsp?sType=wid&sRefresh=Y&sPath=%5BMinLaw%5D&iDocID=5053&sWindow=New&lsSURLEncode%28%22SelectYear:%22%29=%5PromptYear%5D\" title=\""([Referral Count])"\" target=\"_self\" nav=\"web\">"[Referral Count]"</a>"
    let me clear with Ex what problem is coming in java plateform and how intreactive platform is working..
    Example-In my parent report i am doing hyperlink on measure respective Year column suppose 2007,2008,2009 should pass based on that child report should open..
    when i am clicking on measure my child report is opening but it is asking again to give input for prompt of year ..which i do'nt require..bz in child report containg year prompt it should directly open after clicking measure into parent report in java plateform .
    it is working Intreactive plateform bz there i am linking parent report to child report with linking wizard..this wisard is not showing into Java plateform....here when will select measure of 2009 year child report is opening based on that input without asking prompt again both the case i am passing year prompt from hyperlink box...
    so how we can open child report without asking prompt again in java...child report shld open direcly based on selected year...

  • How can I use HyperLink In Java Applet..

    I am new In Java Programming And i Want to create a Hyperlink OR URL in java Applet, How can be It possible?

    well u can use a hyperlink as a url by using url from java.net.url class
    define ur url .... u can check the API fo r that
    and by using wht u mean .. u want to browse in applet with that url or wht
    if u want to do browing in applet than u will also have to do parsing of all HTML tags
    hope it will help u

  • Hyperlink in java application

    when will they finally make it possible to include a hyperlink in a javaapplication??? this is such a basic thing to have a link in your aboutbox that links to your homepage or email.
    there are a few approaches but they are useless:
    1. use applet.getAppletContext().showDocument(); to display a link.
    useless because it works only for applets and not for standalone apps. additionally it would be stupid to put a link to my homepage in an applet which IS located on my homepage.
    2. Runtime re = Runtime.getRuntime();re.exec(PathToBrowser+" "+url);
    you have to get the path of the browser, which makes you app dependent on a certain os/browser.
    3. JLabel lbWeb = new JLabel("<html><a href=\"http://www.deutronium.de.vu\">www.deutronium.de.vu</a></html>");
    does not work either. the link looks like a likn but it doesn't work.
    the question is, why isn't java unable to open a link? there IS NO operating system which is unable to associate a document type with an application. every os is capable to start a browser when i click on a html file.
    will this feature be included in java 1.5 or will java never be able to do such simple things???

    Java is much more than just applets.Oh your right I forgot about servlets,jsp's and EJB's too. I use Java more for stand alone applications than I do for web based ones, but I would still consider it closly bound to the internet. J2EE is probably the most powerful platform for running web services. Might be a bad example for this case, since if you are running a servlet or Jsp you probably have your web browser open anyway, but my point is that although Java is a great language for stand alone applications, its real power is in web based enterprise applications, and without that feature I doubt it would have suceeded. If Java could only be used for desktop applications, I think the language would have never become the dominant force it has. I would say that gives it a binding with the internet.
    This is next to impossible considering the
    cross-platform nature. I have five web-browsers
    available to me - which one does it launch?Which ever one is associated with .html files.
    On the other hand, you can build your own
    "browser" using Java - many Java-only IDEs have one
    imbedded in them. Heck, I built one just for fun and
    it took less than 40 lines of code (I was being
    sloppy).I never said you couldn't write your own, JEditor pane is practically built for it, but there are definately situations where you would want to launch the browser registered with the system. With your own browser you have none of the personal security settings that the system browser already has set up. Then you also have to consider proxy settings and anything else specific to the browser they always use. Sure you can build that functionality in, but then your users have to set up your browser to work in thier environment, as well as the system browser. Just making more work for the user and yourself.
    I was agreeing that it would be a useful feature if it were possible to accomplish, which I belive they could. As the original poster mentioned earlier, all OS's can idnentify which browser to launch when clicking a .html file so Java should be able to find this association on each OS and provide the path to the browswer which will get called. And if there isn't an associated browser the method will fail. So what, plenty of Java methods don't work %100 of the time on all platforms. At least it will solve most situations.

  • Spawning a new browser in hyperlink in java/tomcat

    Post Author: passionlessDrone
    CA Forum: General
    Hello friends -
    I'm going crazy trying to reckon a way to spawn a new browser from a hyperlink field with the java info view / tomcat set up.  Based on some recommendations provided for .NET users, I went ahead and modified viewDHTMLReport.jsp with the following line, diretly after the CrystalReportInteractiveViewer was created:
    viewer1.setHyperlinkTarget("_blank");
    I have confidence this is being called, as I mispelled the function name on my first try and got a 505 returned from Tomcat indicating bad method name, etc.  Tragically, even with a valid method name, the page continues to render 'target="_self" no matter what value is passed in as a hyperlink target.  I have also tried modifiying DHTMLViewer.jsp and ADHTMLViewer.jsp with similar calls directly after the setProductLocale call, but the same results. 
    Is there a chance that processHttpRequest in the Viewer just doesn't pay attention to what gets set in setHyperlinkTarget and will return "_self" no matter what? 
    It also seems a bit naughty that it appears you have to globally set hyperlinks to either spawn new windows or not.
    Any insight or advice is greatly appreciated!
    Take care!
    -pD

    Post Author: passionlessDrone
    CA Forum: General
    Bump.
    Surely someone has either solved this problem or deemed it impossible. 
    Thanks!
    - pD

  • Hyperlink in Java Script Item

    Hi Java-Experts,
    can anyone send me an example for following problem:
    1)
    I want to open a hyperlink (http://www.sap.com) in a frame (iframe1).
    Therefor i need a function, that i can call later with a button.
    2)
    Is it possible to open a web Template with the "standard command" also in an iframe?
    Thank you very much in advance, best regards
    Frank

    Hi,
    Let there be no mistake. Java has nothing to do with JS
    (see also http://www.dannyg.com/ref/javavsjavascript.html and http://www.htmlgoodies.com/beyond/javascript/article.php/3470971)
    Anyway, you're JS code should look like
    frames['iframe1'].location.href = 'some URL';
    iframe1 is the name in the name attribute of your frame
    See also http://www.quirksmode.org/js/iframe.html
    Eddy
    PS. Which type of SDN Ubergeek/BPX suit are <a href="https://weblogs.sdn.sap.com/pub/wlg/6555">you</a>?

  • How do I make a Hyperlink in Java?

    Hi!
    I've made an Image Icon out of a JButton in an applet. When the button is pushed I want to link to a popup html-window. Could you please write some code down to me. Appreciated. Thx.

    Here is hyper link button and hyper link label as well.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=328882
    It will work as I tested.
    GOod luck

  • Hyperlink in application

    hi,i want to add hyperlink in java application mean when user click the hyperlink it goes to website.thanks

    I have some code that does this as a JTextField subclass if that's what you're looking for. It uses EJ Albert's BrowserLauncher code for URL display via browser. I have used it for HTTP and MAILTO
    protocols.
    In usage something like this:
                String webAddress = getBundleString("home.page");
                URL url;
                try
                    final String protocol = "http";
                    url = new URL(protocol + "://" + webAddress);
                catch (MalformedURLException mue)
                    url = null;
                UrlLabel urlLabel = new UrlLabel(webAddress, url);
                urlLabel.addHyperlinkListener(inetProtocolHandler);<mailto:[email protected]> if interested...

  • Pass  variable (hyperlink) in javascript

    Hi
    how can i pass multiple hyperlink in java, from 1 page to another page i want to open www.yahoo.com in second page how can i pass multiple hyperlink variable from 1 page to 2nd page please guide me..
    Thanks

    This is first Page TEST.asp
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
    function newWindow(newContent)
    try{
    var win = window.open('test2.asp?nc='+ escape(newContent) + 'nextWin', 'right=0, top=20,width=350,height=350, toolbar=no,scrollbars=yes, resizable=yes, statusbar=no');
    win.focus();
    }catch(e){
    // popup stopper perhaps
    alert("Do you have a popup stopper active?");
    </SCRIPT>
    </head>
    <body>
    <p>Java
    Scrpt</p>
    </body>
    </html>
    This is 2nd page TEST2.asp
    <HTML>
    <HEAD>
    <title>Untitled Document</title>
    <META content="MSHTML 6.00.2479.6" name=GENERATOR>
    <IFRAME marginHeight=0
    src="<%request("nc")%>" frameBorder=0 width=270
    scrolling=no
    height=80> <font size="2" face="Verdana">Advertisement </font></IFRAME>
    </BODY>
    </HTML>
    Message was edited by:
    AppHouse

  • JTextPane Hyperlink Functionality Help Required

    Hello there,
    I am using the JTextPane in my Java Swing Application. How do I make it Handle Hypelinks. Like lets say the use enters
    \\some_foldername\some_subfolder_foldername\some_file.xls or any other file type, It should Automatically, treat it as a hyperlink.
    Is it Possible to have such a functionlaity
    JTextPane Hyperlink Functionality
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    public class TextSamplerDemo extends JPanel {
         public TextSamplerDemo() {
              setLayout(new BorderLayout());
              // Create a text pane.
              JTextPane textPane = new JTextPane();
              setPreferredSize(new Dimension(250, 155));
              setMinimumSize(new Dimension(10, 10));
              // Put everything together.
              add(textPane, BorderLayout.LINE_START);
         private static void createAndShowGUI() {
              JFrame frame = new JFrame("Hyperlinks in Java Editors");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.add(new TextSamplerDemo());
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        UIManager.put("swing.boldMetal", Boolean.FALSE);
                        createAndShowGUI();
    }Regards,
    Hemanth

    Try something along these line
    1. get start and end off highlighted text
    2. replace highlighted text with a string builder or something similar
    <html><FONT COLOR=BLUE> <u> TEXT</FONT></u>
    Calypso
    Edited by: calypso on May 15, 2009 4:42 AM
    On second thought I think you can shorten that to
    <html>TEXT

Maybe you are looking for

  • Mismatch of qty in subcontracting challan reconcilliation

    Hi, When we issue the material using subsequent adjustment.During the reconciliation of subcontracting challan, 1) Challan quantity is not getting updated, 2) Material sent to item in subsequent adjustment  is getting added in GR quantity, in subcont

  • Exclude Title in Address End Address in Sap Script

    Hi All, We are using below code to print address of payer in check form but its printing the title also in address, Say Company etc. We donot need this. Is there any addition to this statement to remove this. ADDRESS PARAGRAPH E1 NAME        &REGUH-Z

  • Some issue with the Function Module u0093'SKWF_FIND_BY_QUERY' in a BW ECC6.0

    Hi All, Need some urgent help.. Iam facing some issue with the Function Module “'SKWF_FIND_BY_QUERY' in a BW ECC6.0 system. As shown below, in the function module, the Table “IT_PROPERTIES_RESULT” gets populated with some values based on inputs like

  • Is Patch 5017052 needed when running Forms 10.1.2.3?

    Hello - we've been running on Forms 10.1.2.02 (Linux apps server, IE6 / IE7, Windows XP, JInitiator 1.3.1.22) for a couple of years, and when we first upgraded, we applied patch 5017052, which makes changes to the base htm files to avoid a potential

  • Java Class for Image

    Dear All, Hi, I am new to Java. I have to merge some *.gif files onto some *.tiff file on the web. Does java provide any class for manipulating imabe file or provide the above action? Any help would be much appreciated. Thanks