How do I make a "hyperlink" in a JFrame?

I have a JFrame with JLabels and JButtons.
If you click on a JButton (or a JLabel) I would like to open a new window (or IE) with a certain website.
How shall I write?

This example uses a button:
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;
public class MainFrame extends JFrame implements ActionListener {
private JButton button1;
private String url;
public MainFrame(String url) {
super("Test");
this.url = url;
setBounds(50,50,50,50);
button1 = new JButton("Click Here");
button1.addActionListener(this);
getContentPane().add(button1);
setVisible(true);
public void actionPerformed(ActionEvent e) {
try {
JFrame jf = new JFrame("Another Test");
jf.setBounds(0,0,800,600);
JEditorPane jep = new JEditorPane(url);
jep.setEditable(false);
jf.getContentPane().add(jep);
jf.setVisible(true);
catch (IOException ex) {
System.out.println(ex);
public static void main(String[] args) {
MainFrame mf = new MainFrame(args[0]);
Just call like this: java MainFrame http://java.sun.com (or any address, but you must include the protocol)
If you connect to the internet through a proxy, this will throw an exception, so you'll need to set your system properties with the proxy server address.
Hope this helps

Similar Messages

  • How can i make my hyperlinks open in a new window or tab?

    how can i make my hyperlinks open in a new window or tab?

    The program is InDesign… we need to cease links which will open the linked document in a separate window.  Also, the links must be maintained once a pdf is made and the files moved to another computer….

  • How can I make outside hyperlinks work in Muse?

    Hi, I am a very frustrated newbie in Muse, struggling to make my first website work. I created the website for a chamber of commerce, so I am trying to create a table of members with links to their business websites. I could not import a Word document table so did a table by hand in Muse. I also created hyperlinks using the copy and paste method, and the hyperlink tool at the top - it worked fine but was taking too long to try and hand do a table format. So after researching the Internet, determined that importing the Word table into InDesign and converting it to a PNG would work. So I successfully accomplished that, but the links do not work in the preview nor the published version, and the document was not editable. Once again I was stuck. I then tried to copy and paste from the InDesign document using text boxes, but that hasn't worked either. Can somebody please help?

    I doubt MU can do this.  It's pretty limited in scope &  I don't think it supports server-side code which you would need to parse feeds.  But feel free to post your question in the MU forum.  Maybe somebody there has a workaround.
    http://forums.adobe.com/community/muse/help_with_using_adobe_muse
    Nancy O.

  • How do I make the hyperlink underlined when I scroll over it?

    Hello!
    I'm having trouble with my hyperlinks changing color when I scroll over them so I decided to underline them instead. Can anyone tell me how to do that?
    Thanks!

    Never mind, I figured it out. It's the underlined "U" next to the color in the inspector, duh!

  • How do I make a Hyperlink open in a different window?

    Hello,
    When people click my Hyperlinks they leave my website. Is there a way for the hyperlinks to open in a new window so that my website always stays open on the desktop?
    I hope that is clear?

    I don't recall the previous versions to 08, but in 08 in the inspector when you enable a hyperlink to an external page there is an option to have the link open in a new window.

  • How do I make a hyperlink with dynamic data from a php data base table?

    Level - Dreamweaver infrequent user
    I have a standard master-detail couple of pages using MySQL and PHP. This function is working correctly. One of the data items on the Details page contains the name of a PDF document (including the .pdf suffix). The PDFs are stored in the PDFs library under the Site Root. I am wanting the ability of the page user to look at the associated PDF. Keeping it as simple as possible I just set up a text field 'View Report' followed by the Dynamic Text for the document name. I tried defining the Link Properties with the PDFs library name (plus the root level) followed by the code I thought it needed to identify the selected PDF document ( <? php echo $row_rslivesDetail['ReportLink']; ?> ). The first part is correct because when the code failed I changed it to a fixed PDF document and that worked. I've tried various combinations but not been successful. Can someone please suggest what I'm doing wrong with the code.
    Regards
    Cliff

    Do the PDFs actually reside in your MySql database or are they just in a folder on your server?
    To parse files from a folder, you could use something like this:
    <h2>PDF Files</h2>
    <?php
    class SortingIterator implements IteratorAggregate
    private $iterator = null;
    public function __construct(Traversable $iterator, $callback)
    if (!is_callable($callback)) {
    throw new InvalidArgumentException('Given callback is not callable!');
    $array = iterator_to_array($iterator);
    usort($array, $callback);
    $this->iterator = new ArrayIterator($array);
    public function getIterator()
    return $this->iterator;
    ?>
    <!--results-->
    <h3>2014</h3>
    <?php
    function mysort($a, $b)
    return $a->getPathname() > $b->getPathname();
    $item = new SortingIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('pdfs/2014/')), 'mysort');
    foreach ($item as $file) {
    echo '<li><a href="' . $file . '">' . $file->getFilename() . '</a> - '. round( $file->getSize() / 1052) . '  KB </li>';
    ?>
    </ul>
    In my example above, pdfs is my main folder and 2014 is my sub-folder. 
    Results echo inside a list with each file name hyperlinked.  See screenshot.
    Nancy O.

  • 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

  • How can I make Applet call up a JFrame??

    hello ..
    I'm making a game, and I have a flash screen done in Applet (the very first logo that appears ) so I can just load it in the browser ... someone told me that I can't make another applet that would hold the menu choices and such come up in the same browser window, so I made it into a JFrame .. so I have an Applet calling up a JFrame, and I don't know how to do that ..
    any suggestions???

    Hmm...but that doesn't put it on the screen thgou, does it?
    IIRC applets embedded in the web page cannot contain menus - you have to 'break out' your applet so that it becomes a separate window.
    To do this you would have a small standard applet embedded in your web page which then invokes your main JFrame-based application (not applet!).
    When the user loads the web page, the embedded applet starts and then launches the JFrame-based application.
    eg:
    import java.awt.*;
    import java.awt.applet.*;
    public class RunApplet extends Applet {
        public void init() {
            MyApplet myA = new MyApplet();
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    public class MyApplet extends JFrame {
        private JPanel pnlCenter;
        private JLabel lblSomeText;
        public MyApplet() {
            try {
                myInit();
            catch(Exception e) {
                e.printStackTrace();
        private void myInit() throws Exception {
            //Create components to display...
            pnlCenter = new JPanel();  //Main container inside the frame.
            lblSomeText = new JLabel("GUI stuff displays here!");
            pnlCenter.add(lblSomeText);
            //Put them on the screen...
            getContentPane().add(pnlCenter);
            //Show it...
            setTitle("My First Windowed App");
            setVisible(true);
    }Hope this helps.
    Paul.

  • How do I make hyperlinks open in new window?

    Hi, I'm using Acrobat X Pro.  I have a pdf uploaded to a website, and within that pdf are two hyperlinks to other websites.  Currently, if I click on the links, they open in the same window.  How do I make the hyperlinks open in a new window by default? In Acrobat X Pro, I tried editing the hyperlinks by right-clicking them and selecting properties, but I don't see an option to specify how the link should open.  Is this option available for web links?

    I think the best you can do is use the app.launchURL JavaScript method and specify that you want to open in a new window:
    // Script for link action
    app.launchURL({cURL: "http://www.example.com", bNewFrame: true});
    For this method's documentation, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.150.html

  • How can I make hyperlinks work from a Flash/SWF presentation?

    How do you make hyperlinks/buttons work in Flash/SWF Captivate 5.5 presentations? This did not seem to be an issue with Version 4. I cannot publish to video (i.e. mp4) or as an executable file for posting on our internal system. If it cannot be done in Flash/SWF, how else can I get buttons/hyperlinks to work? Thank you.

    Welcome to our community
    Please take a look at the links below. Not only do they answer your question, they are there to help you get the best forum experience.
    Forum Participation Suggestions
    Frequently Encountered issues
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • How can i make hyperlink to local file for dowloading

    How can I make hyperlink to a local file for downloading it, it seams that only www links work in web Ui.
    Thanks

    If we assume that you have a LabVIEW application running on your cRIO that is exposing some data through web services, there are a couple of possibilities.
    You can create a web service call that returns the log data. In order for the browser to treat this as a file, you must set the correct content type in the http header. To do this you can't use the default form of data output. Instead you must create an "httpRequestID" input to your web service VI. With this you can call "Write Response.vi" to give the log data and "Set HTTP Header.vi" to specify the type (text/text probably works for a log). You can look at "examples\comm\webservices\address book\FindContacts.vi" to see an example of calling these 2 VIs. Once you create that web service entry point, you can set that as the URL of the hyperlink control and it should work.
    Another option is to have the cRIO application write to a log file that is under the root of the web server running on the machine. (This is the same place the xap for your Web UI Builder application is put.) This file could then be served up through the web server just like any other file.
    With either of these solutions there may be concerns about the browser caching results rather than requesting new content each time. There are additional values that can be set in the http headers with the first solution that can help with this, but I think there is still some variation between browsers.

  • How to automatically make twitter @name fields into hyperlinks in Indesign?

    Hi folks,
       I have a book of tweets coming out and would like to publish Kindle, ePub and PDF versions of it, which would need hyperlinks throughout to work at all. So what I need is a way to automatically convert
    @Me
    into
    <A HREF="http://www.twitter.com/Me">@Me</A>
    as it were.
    There are about 1000 of them, so I don't want to have to do it manually!
    I have already used a GREP style to automatically format the @text (it's always one word, so it's easy) but the automatic hyperlink tool does not seem to allow customisation of what hyperlinks look like.
    Does anybody have any ideas as to the best way to approach this?
    Thanks,
    Ivan

    Hello John... Thanks.. My problem in large part stems from the way InDesign handles hyperlinks and what happens during the pdf process.. I have been having real problems with the "shared" destination default etc.. Anyways:  then I had to put in a twitter link and I couldn't find any clear description of how to do this in InDesign or the help community. I went around in circles.. The problem was with html tags.. and twitter exceptions and etc.. Anyways: the whole thing worked out after I spent many hours on the net.. mostly trying to find the right language to use to phrase the problem..  Not being a "tweeter" complicated issues.. (I had to do this for those who do tweet)... The answer, in short was this:
    get a retweet button;
    put retweet button in InDesign doc. 
    Post a tweet (in this case it was "Save the Date: HCV Training March 26, Houston TX  [link to permanent pdf of the training flyer]..
    Twitter will generate a short url.
    In Twitter, hover mouse over post and then "More" pops up
    Click on Embed
    Copy Embed code
    Paste embed code to text file
    Make URL hyperlink for retweet button and in the Destination put: http://twitter.com/share?text=Save%20The%20Date%20Houston%20March%2026&url=http://t.co/AQV rqixC0O
    Note: The above contains the message (after the text=) which must use %20 in lieu of any spaces in the text description.  Then after the &url= paste the short url that you copied from the embed code.
    Make sure that the InDesign link is NOT a shared destination and that it is a URL
    Save file and export to PDF
    As you can see... this took a while to figger out.. I found several posts on the internet but none stood alone... So here you go.

  • How can I make hyperlinks work in InCopy when I export to PDF without using InDesign?

    I created an InCopy document with hyperlinks linking to other InCopy documents. When I exported to PDF, these hyperlinks don't work. Is there any way I can make these hyperlinks work without using InDesign? Thanks.

    beer and no prepress schrieb:
    If it's for the web, why not export to JPEG?  Why PDF?
    Terrible idea. In a JPG the text will not be alive, you loose all interactivity.
    And making JPGs with InDesign is not what the program is meant to make.

  • How do you make a link open on a new page (typically the target="_blank" command) in MUSE?

    how do you make a link open on a new page (typically the target="_blank" command) in MUSE?

    Newer version does not have the same interface.  I'm stuck trying to understand how to add a "blank" target to a hyperlink...  See how your screenshot has a dropdown associated with the "Hyperlink" object?  Mine doesn't...

  • How do I maintain my hyperlinks when converting a Microsoft Word Document to a PDF file?

    How do I maintain my hyperlinks when converting a Microsoft Word document to a PDF file?

    Hi Marbarrose,
    When you make word file including hyperlinks then convert in pdf.
    It will automatically maintain hyperlinks.
    Regards,
    Florence

Maybe you are looking for

  • My HP Photosmart C4599 will no longer talk to my MacBook wirelessly -- Help?

    After downloading a new version of Firefox, my MacBook quit talking to my printer.  I've reinstalled printer software and run a Wireless Network Test Report & Configuration Page.  The printer still tells me that mly printer is off-line.  Has anyone e

  • CSS layout, is the code done well?

    I'm thinking of using this PHP CMS for a client site. It's totally customizable, but since I'm not too big on CSS positioning, I wondered what some of you CSS layout enthusiasts think about their code. http://208.106.156.20/ Thanks in advance, Patty

  • No Document Opened

    Hi all, I got a problem with opening and creating new document in SOLAR01. Each time I create, or try to open a document, nothing displayed in SAP editor (no template, no doc display) for any Office document. It prompts "No document opened" Previousl

  • HP 19-2014 All-in-One for installing problem to OfficeJet 6500a

    I downloaded the printer driver provided by HP support team who gave me HP support URL and installed printer driver on my windows 8 new computer.  When I installed the Office jet printer, I didn't have USB cable to connect.  I used the RJ45 to connec

  • Require SQL to get week information

    Hi, i need to get the week start date and end date in my report as a report break. Can you assist me? How would i go about doing this? This is the spec: Week Start Date The Report prints the Start Date of the week. Company has indicated that the star