?
Solved

making a spread sheet out of a JTable

Posted on 2000-04-19
7
Medium Priority
?
333 Views
Last Modified: 2012-05-04
I am using JDK1. 2 to create a program that uses SWING to generate a JTable. How would I go about manipulating the JTable so that I can select different selection combinations of rows and columns within the JTable like on a standard spread sheet.

At present the JTable only allows me to select entire rows.

Thanks.......
0
Comment
Question by:luinzi
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:kylar
ID: 2732621
try calling setCellSelectionEnabled(true), setColumnSelectionAllowed(true), setRowSelectionAllowed(true) and setSelectionMode(JList.MULTIPLE_INTERVAL_SELECTION) on your table. That will allow you to select multiple non-contigious sections.

Kylar
0
 

Author Comment

by:luinzi
ID: 2732630
Do I need to place these code fragments into ny specific methods at all?
0
 
LVL 4

Accepted Solution

by:
kylar earned 200 total points
ID: 2732640
Call them on the table itself after you create it:

JTable mytable = new JTable();

mytable.setCellSelectionEnabled(true);
mytable.setSelectionMode(JList.MULTIPLE_INTERVAL_SELECTION);
mytable.setColumnSelectionAllowed(true);


like that.

Kylar
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:luinzi
ID: 2732674
That sounds too easy..... but it works apart from setSelectionMode(JList.MULTIPLE_INTERVAL_SELECTION); as JList seems to be an unknown variable.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2733424
what about one more import statement ? :)

import com.sun.java.swing.JList ;
(or
import javax.swing.JList;
)
0
 
LVL 4

Expert Comment

by:kylar
ID: 2738105
Heh, yeah. that would work. You can substitute setSelectionMode(2) if you're using JDK1.2.

If the stuff all works like you wanted, why not grade the question?

Kylar
0
 

Author Comment

by:luinzi
ID: 2739055
Thanks! I got it all working in the end!

Cheers!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

839 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