|
-
May 11th, 2005, 06:01 PM
#1
How to show hyperlink in cell of JTable?
Hi All,
I want to show hyper link in cell of JTable . Clicking on it should display the content related to that hyper-link in browser. Thus, I have two task: one is let say for example I want to show image name "xyz.jpg" in table cell as a hyper link data. Second thing is when i click on link it should go to the URL let say http://myserver/xyz.jpg and open this image in browser.
Any help regarding this will be appreciated.
Thanx and Regards,
Premal Panchal
-
May 12th, 2005, 05:36 PM
#2
Re: How to show hyperlink in cell of JTable?
Try sth like this:
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Test extends JFrame
{
public static void main(String[]args)
{
new Test();
}
public Test()
{
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
final JTextField tf = new JTextField("http://java.sun.com", 20);
JLabel adress = new JLabel("Adress:");
JLabel label = new JLabel("Just click it!");
label.setBorder(BorderFactory.createLineBorder(Color.blue));
label.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
try
{
Runtime.getRuntime().exec("c:/Program Files/Internet Explorer/iexplore " + tf.getText());
}
catch(java.io.IOException exc)
{
System.out.println(exc.toString());
}
}
});
cp.add(adress);
cp.add(tf);
cp.add(label);
pack();
show();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|