I have a program. Here

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

    class MarqueeTest
        public static void main(String[] args)
            MyFrame frame = new MyFrame();


    class MyFrame extends JFrame implements ActionListener
        private ActionListener listener;
        private Timer t1;

        public MyFrame()
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            MyPanel panel = new MyPanel();
            listener = this;
            t1 = new Timer(50,listener);
        public void actionPerformed(ActionEvent event)


    class MyPanel extends JPanel
        private int x,y;
        private Dimension d ;

        public MyPanel()
            d= Toolkit.getDefaultToolkit().getScreenSize();
            x = d.width - 100;
            y = 25;


        public void paintComponent(Graphics g)
            x -= 5;
    if ( x < -250)
        x = d.width;
    Graphics2D g2 = (Graphics2D) g;

    Font font = new Font("Comic Sans MS",Font.BOLD,25);

    g2.drawString("Go To Web Page",x,y);

When I click "Go To Web Page", I want to open web page.Can I do it?If can do, pls tell me how I will do.Thank in advance.:-/

Recommended Answers

All 2 Replies

Next time put your code in tags, it makes it easier to read.

As for the text to open a web page, I would just have it a jLabel of a jButton. I haven't ever done it, but it is possible. An example is located here:


If you need more examples, you could always search google with a phrase like so: java jlabel hyperlink

Thank a lot for your reply.I am so sorry for my code writing style.Thank in advance.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.