Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Hyperlink in Jtable - Lots of hyperlinks!

843805Mar 15 2007 — edited Mar 16 2007
Hi.

I'm trying to get it, so that when someone clicks on an item in one of my columns it opens up a browser window, depending on the row that they have clicked on.

For example, in my table i may have

Name Number
Alex 1
David 2
Mike 3

When someone clicks on Alex, i want it to take them to www.site1.com, when someone clicks on David, it takes them to www.site2.com etc...

Now i've searched the forums, and read about listeners etc, however i'm not sure how to make it so that each row has a different link.

The table is current built using:
	public GetFarms() throws Exception {
 
		URL theUrl = new URL("http://www.allydm.co.uk/Covenant/farm_list.php");
		BufferedReader in = new BufferedReader(
				new InputStreamReader(
				theUrl.openStream()));
                
		String inputLine = in.readLine();
		String[] lines = inputLine.split("<br>");
		for (int i = 0; i < ROWS; i++) {
			String[] stuff = lines.split(" ");
for (int j = 0; j < COLUMNS; j++) {
cells[i][j] = stuff[j];
}
}

in.close();

String[] columnNames = {"Username", "DA", "Sentry", "Last Update"};

sampleJTable = new JTable(cells, columnNames);
JScrollPane tablePane = new JScrollPane(sampleJTable);
tablePane.setPreferredSize(new Dimension(420, 295));
add(tablePane, BorderLayout.CENTER);
}

Does anyone have any suggestions on how i could implement links?

Thankyou for any help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2007
Added on Mar 15 2007
3 comments
348 views