Help - Search - Members - Calendar
Full Version: Using JTable events?
MSFN Forums > Coding, Scripting and Servers > Web Development (HTML, Java, PHP, ASP, XML, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
YoussefGamil
Hi,
Iam really having a problem..
I want to make a Table which shows the value of the selected item and
it's index in the selected Column and Row..
So, could anyone help me by an examples,please?
Thanks for help.
Youssef Gamil
Stalkie
Check this out http://java.sun.com/docs/books/tutorial/ui....html#selection
YoussefGamil
THANKS FOR YOUR HELP biggrin.gif biggrin.gif thumbup.gif thumbup.gif
but,I think I should search Google first to save your work
as I found this page before using google after asking that question..

THANKS AGAIN
THANKS 4 ALL

BUT,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 AGAIN
THANKS 4 ALL
Stalkie
You can try something like this (haven't tested it)

CODE
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;
   }
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.