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();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class MyFrame extends JFrame implements ActionListener
{
private ActionListener listener;
private Timer t1;
public MyFrame()
{
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setSize(d.width,d.height);
setTitle("MARQUEE");
MyPanel panel = new MyPanel();
add(panel);
listener = this;
t1 = new Timer(50,listener);
t1.start();
}
public void actionPerformed(ActionEvent event)
{
repaint();
}
}
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.setFont(font);
g2.setPaint(Color.BLUE);
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.:-/