JAVAnewbie
asked on
Hyperlink on JLabel?
hi, is there a way to make my label to become a hyperlink to certain websites?
like when i click on the label, it will direct me to the website?
like when i click on the label, it will direct me to the website?
Easier to use a button, and it will provide better use feedback.
if you want it to have a link underneith
You can use
yourLabel.setText("<HTML>< U>www.google.com</U></HT ML>")
and also use font
You can also chnage Cursor on mouse over event to Hand to give it a perfect look
You can use
yourLabel.setText("<HTML><
and also use font
You can also chnage Cursor on mouse over event to Hand to give it a perfect look
ASKER
zzynx >> i am not sure if JLabel can have ActionListener assigned to it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
armoghan >> let me try first.
>> i am not sure if JLabel can have ActionListener assigned to it?
It can't
It can't
>> zzynx >> i am not sure if JLabel can have ActionListener assigned to it?
You are right of course.
Stupid me ;°)
You'll have to go for
yourLabel.setText("www.google.com");
yourLabel.addMouseListener ( new MouseAdapter() {
public void mouseClicked(MouseEvent e)
Runtime.getRuntime().exec( "cmd /c start http://www.google.com");
}
});
as armoghan said.
You are right of course.
Stupid me ;°)
You'll have to go for
yourLabel.setText("www.google.com");
yourLabel.addMouseListener
public void mouseClicked(MouseEvent e)
Runtime.getRuntime().exec(
}
});
as armoghan said.
ASKER
tks everyone
yourLabel.addActionListene
public void actionPerformed(ActionEven
Runtime.getRuntime().exec(
}
});