Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java Swing: Retrieve value of cell in header

Posted on 2011-09-11
8
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:dshrenik
ID: 36519840
This code is causing exceptions:
0
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

610 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