Solved

Java Swing: Retrieve value of cell in header

Posted on 2011-09-11
8
213 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

691 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