java - Not able to get the row as html? -
i trying show particular row of jtable html...but instead getting whole table output ...i want row data enclosed in html not whole table.... below trying ....where making mistake??
public static void go() { javax.swing.jtable table = new javax.swing.jtable( new object[][] { new object[] { "row00", "row01" }, new object[] { "row11", "row12" }, }, new object[] { "col a", "col b" }); table.selectall(); javax.swing.transferhandler handler = table.gettransferhandler(); if (handler == null) { system.err.println("no handler."); return; } int actions = handler.getsourceactions(table); if ((actions & javax.swing.transferhandler.copy) == 0) { system.err.println("not copy."); return; } java.awt.datatransfer.clipboard clipboard = new java.awt.datatransfer.clipboard( "export"); try { handler.exporttoclipboard(table, clipboard, javax.swing.transferhandler.copy); } catch (illegalstateexception exc) { exc.printstacktrace(); return; } java.awt.datatransfer.transferable transferable = clipboard.getcontents(null); if (transferable == null) { system.err.println("clipboard"); return; } if (!transferable.isdataflavorsupported(html_string_flavor)) { system.err.println("not supported"); return; } try { object data = transferable.gettransferdata(html_string_flavor); system.out.println(data); }
instead of using table.selectall()
, use setrowselectioninterval(int indexbegin, int indexend)
method of jtable
.
example first row :
table.setrowselectioninterval(0, 0);
Comments
Post a Comment