YoussefGamil Posted August 11, 2005 Posted August 11, 2005 Hi,Iam really having a problem..I want to make a Table which shows the value of the selected item andit's index in the selected Column and Row..So, could anyone help me by an examples,please?Thanks for help.Youssef Gamil
Stalkie Posted August 14, 2005 Posted August 14, 2005 Check this out http://java.sun.com/docs/books/tutorial/ui....html#selection
YoussefGamil Posted August 14, 2005 Author Posted August 14, 2005 (edited) THANKS FOR YOUR HELP but,I think I should search Google first to save your workas I found this page before using google after asking that question..THANKS AGAINTHANKS 4 ALLBUT,Can I ask one more question which I didn't found an answer for it?Can I get JTable in form of 2D String Array?THANKS AGAINTHANKS 4 ALL Edited August 14, 2005 by YoussefGamil
Stalkie Posted August 19, 2005 Posted August 19, 2005 You can try something like this (haven't tested it)public String[][] getElements (JTable table) { String[][] values = new String[table.getRowCount()][table.getColumnCount()]; for (int i=0; i<table.getRowCount(); i++) { for (int j=0; j<table.getColumnCount(); j++) { values[i][j] = (String)table.getValueAt(i, j); } } return values; }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now