Solved

Java Swing: Retrieve value of cell in header

Posted on 2011-09-11
8
208 Views
Last Modified: 2012-05-12
Please let me know how i can retrieve the value of a particular cell in the header of a JTable.

Thanks!
0
Comment
Question by:dshrenik
  • 6
  • 2
8 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 36519812
What means the value of the cell in the header?
Do you mean colunmn name?
0
 

Author Comment

by:dshrenik
ID: 36519820
Right.
0
 

Author Comment

by:dshrenik
ID: 36519837
I want to retrieve the name of column, given the column number.
0
 

Author Comment

by:dshrenik
ID: 36519840
This code is causing exceptions:
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:dshrenik
ID: 36519842
String a = table.getColumn(column).getHeaderValue().toString();
0
 

Author Comment

by:dshrenik
ID: 36519861
This seems to do the trick:
String columnName = table.getTableHeader().getColumnModel().getColumn(column).getHeaderValue().toString();

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36519880
But I think
Jtable table;
table.getCoulmName(int column)
should also return column name
0
 

Author Comment

by:dshrenik
ID: 36519882
It does. Thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now