I wanted to create a Swing GUI , in which there should be a text which in event handling works as a JButton.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Gui implements ActionListener
{
JFrame jf=new JFrame("Link");
JLabel jl=new JLabel("CLICK HERE");
Gui()
{
jf.setSize(400,400);
jf.setVisible(true);
jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
jf.setLayout(null);
Font f=new Font("Arial",)
jl.setBounds(50,50,100,50);
jf.add(jl);
jl.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showMessageDialoge(null,"Clicked in link");
}
public static void main(String arg[])
{
new Gui();
}
}
How can I create a text into a link in a Java Swing GUI?
Please suggest a proper code.