Welcome to Dream.In.Code
Become a Java Expert!

Join 149,384 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,326 people online right now. Registration is fast and FREE... Join Now!




JTable scrolling

 
Reply to this topicStart new topic

JTable scrolling, make scrolling one table affect the other table

gyron
16 May, 2007 - 05:08 AM
Post #1

D.I.C Head
**

Joined: 9 Jan, 2007
Posts: 61


My Contributions
I have two tables designed to look like one, giving the impression of a spreadsheet with some columns to the left frozen. How do i make scrolling the table to the right scroll the left table as well?
I also want the selection on both tables to be identical i.e. if row 1 to 10 are selected on the 'fixed' table, then row 1 to 10 should be selected on the 'scrolling' table, and vice-versa.
Currently i have just managed to match the selection if one row is involved, like this:
CODE

tblFixedTable.setRowSelectionInterval(tblScrollingTable.getSelectedRow(), tblScrollingTable.getSelectedRow());


How do i expand the selections?

This post has been edited by gyron: 16 May, 2007 - 05:15 AM
User is offlineProfile CardPM
+Quote Post

spullen
RE: JTable Scrolling
16 May, 2007 - 10:46 AM
Post #2

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 330



Thanked: 1 times
Dream Kudos: 50
My Contributions
I think you might need a JScrollPane that has a JTable in it so it can scroll, I would look at the Java API for it and see about how to implement it.
User is offlineProfile CardPM
+Quote Post

gyron
RE: JTable Scrolling
16 May, 2007 - 10:48 PM
Post #3

D.I.C Head
**

Joined: 9 Jan, 2007
Posts: 61


My Contributions
Currently, the setup looks like the attached picture. I have written code that makes the enter key cross the tables on the same row, making it look like the user is working with one table.
The problem is highlighting rows on both tables. I am stumped, big time


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

gyron
RE: JTable Scrolling
17 May, 2007 - 12:27 AM
Post #4

D.I.C Head
**

Joined: 9 Jan, 2007
Posts: 61


My Contributions
Ok, ladies and gentlemen; there just is a whiz here who has solved this problem.
(http://forum.java.sun.com/thread.jsp?forum=57&thread=461976&tstart=0&trange=15)

Have a look at this file called CoolTable.java (http://jroller.com/resources/kriede/CoolTable.java) .

I modified a little bit of it, chucked it into my class and it works wonders. I'm jus speechless!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:47AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month