Two JTables using the same RowSorter

Ok, I have the following situation:
package testing;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class Testing
     public static void main(String args[])
          JFrame frame = new JFrame("SplitPaneTest");
          String[] columnNames =
                    {"First Name",     "Last Name",     "Sport",               "# of Years",          "Vegetarian",           "#",     "A Number"};
          Object[][] data =
                  {{"Mary",      "Campione",      "Snowboarding",      new Integer(5),      new Boolean(false),     "1",      new Float(37.1)},
                   {"Alison",    "Huml",            "Rowing",                new Integer(3),      new Boolean(true),     "2",      new Float(324.76)},
                   {"Kathy",     "Walrath",           "Knitting",           new Integer(2),      new Boolean(false),     "4",      new Float(6)},
                   {"Sharon",    "Zakhour",           "Speed reading",      new Integer(20),      new Boolean(true),     "3",      new Float(4567)},
                   {"Philip",      "Milne",           "Pool",                new Integer(10),      new Boolean(false),     "5",      new Float(1337)},};
          DefaultTableModel model = new DefaultTableModel(data, columnNames);
          JTable leftTable      = new JTable(model);
          JTable rightTable      = new JTable(model);
          leftTable.removeColumn(leftTable.getColumnModel().getColumn(6));
          leftTable.removeColumn(leftTable.getColumnModel().getColumn(5));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(4));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(3));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(2));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(1));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(0));
          leftTable.setAutoCreateRowSorter(true);
          rightTable.setAutoCreateRowSorter(true);
          JScrollPane leftScrollPane = new JScrollPane(leftTable);
          JScrollPane rightScrollPane = new JScrollPane(rightTable);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setLayout(new GridLayout(1, 2));
          frame.add(leftScrollPane);
          frame.add(rightScrollPane);
          frame.setVisible(true);
          frame.pack();
}Basically what I want to do is when the user sorts either one of the tables, I want the adjacent table to sort as well according to the column of the clicked table. Also, on an unrelated note, does anyone know of a more efficient means of setting the models of the table so I don't have to remove the unwanted columns:
          leftTable.removeColumn(leftTable.getColumnModel().getColumn(6));
          leftTable.removeColumn(leftTable.getColumnModel().getColumn(5));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(4));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(3));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(2));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(1));
          rightTable.removeColumn(rightTable.getColumnModel().getColumn(0));Thank you for your time,
Brandon

Thanks for the comment and the link. It seemed to work with OP's SSCCE when I tested it, maybe there isn't a problem when both tables also share the same TableModel?
db (busy with some office work now and no time to run any further tests)

Similar Messages

  • HT3529 will imessaging work on two iphones using the same apple id

    will imessaging work on two iphones using the same apple id

    It will. If the two phones are used by two different people, however, you will need to implement some careful management of your iMessage settings to ensure that you don't each receive each-other's messages. It is a much safer option to use different Apple IDs for each individual.
    On iOS devices, you are able to use separate Apple IDs for iMessage and Facetime, iCloud, and the iTunes and App Stores.

  • HT1495 Can two people use the same itunes account?

    Can two people use the same iTunes account? On different computers and different devices?

    Yes, READ the article from which the question was posted as it explains how to do so in detail.

  • Can two players use the same game app without erasing each other's scores?

    Can two players use the same game app on the same device without erasing each other's scores?  My two sons build up their characters and progress in their games, then the other one wants to play, erasing the first son's progress.
    Is it possible to create two player identities in the Game Center? 
    Is it possible to have two different Apple User ID accounts on the same device?  Is that even desirable?
    Many thanks!
    MCPROBW

    You can create as many individual user accounts on a Mac as you like. Then, any one or more of those users can remotely log in from another Mac and use that Mac as their own, simultaneously. Each account will remain separate from all others.
    However, since each user needs to have a Mac to do that, I'm not sure how you could effectively double the number of users as you describe.

  • How to fix the "Two computers using the same IP address" issue on the airport express

    I just bought an airport express and got dsl at my apartment, and I haven't been able to set up the wireless connection. My DSL works just fine but whenever I hook up the AX I get an error message saying that there are two computers using the same IP address on the network, but I only have one computer.
    I know this is probably a simple fix, but I've never had this issue when I set up the Extreme at my parents house and I haven't been able to find a thread on this.
    As of right now I have it set to Factory settings.
    Help please!

    This modem was designed to connect directly to a computer and you are trying to connect it to a router.
    Unfortunately, this is not a simple fix as both the modem and your AirPort Express will need to be configured differently to work together correctly.
    Connect the modem directly to your computer.
    Open up your browser and type the default IP address for the modem into the address bar. Check your documentation on the modem but it is likely 192.168.1.254
    That will bring up the configuration page for the modem.
    You may need to enter the modem access code which is on a label on the back or bottom of the device
    Look for an Advanced tab, then look for a tab labeled something like PPP Location
    Right now, you will see that "PPP is on the modem"
    Chance that to "PPP is on the computer or router"
    Click to save your new settings and the modem will restart
    If you ever need to get the modem back to its original settings, you will need to hold in the reset button on the back of the modem for 5-6 seconds and then enter in the default IP address to be able to access the settings on the modem
    Connect the modem to the AirPort Express with an Ethernet cable
    Open AirPort Utility on your Mac and click Continue to follow the guided setup to "Create a wireless network"
    You may be asked to "switch" networks when you do this. You want to switch
    Select the "Connect Using PPPoe" option when it appears
    Enter your user name and password with your provider. Leave the Service Name area blank. You want to always stay connected if you see that option
    Continue to follow the guided setup and Update to save settings
    Pull the power cord from the modem, wait a moment, then restart the modem
    Log on to the wireless network that you created during the setup and you should have an Internet connection

  • I have two iphones using the same computer and I can only find a backup for my iphone and not my girlfriends.  She uses itunes a lot more often then I do but cant find it

    I have two iphones using the same computer and I can only find a backup for my iphone and not my girlfriends.  She uses itunes a lot more often then I do but cant find it.  Really need some help.  Shouldnt her apps and details be saved online in the itunes store?  Even her apps wont appear

    If you create an Apple ID for your daughter, signing out of the existing Apple ID with the iTunes & App Store on her iPhone will not change anything on your iPhone.
    All apps include DRM protection which is tied to the Apple ID that was used to download the apps.
    If she starts using her Apple ID to download apps, when there is an app update for an app on her iPhone that was downloaded with the current shared Apple ID, she will need to use that Apple ID and password to download the app updates.

  • HT5622 I have two ipads using the same ID and password.  How do I give one of them a new ID and password?

    I have two ipads using the same ID and password.  How do I give one of them a different ID and Password?

    iTunes Store: Associating a device or computer to your Apple ID
    http://support.apple.com/kb/ht4627
     Cheers, Tom

  • Can two frames use the same SessionInfo object?

    Hi,
    I have some questions on using InfoBus Frame.
    Do parent frame and child frame HAVE TO make use the same
    SessionInfo object?
    I tried to show Master table and Detailed table in seperate
    frame without login twice. I am lucky it works since I happened
    to make two frames have the same SessionInfo object which is
    sessionInfo1 and conmment out sessionInfo1.publishSession()in
    Detailed frame.
    But when I tried to pass Master frame SessionInfo object to
    Detailed frame there is nothing showing up in the detailed frame
    it is just blank frame.
    So two frames have to use the same SessionInfo object . Dose it
    make sense?
    I would really appreciate anyone who can enlighten me on this
    subject.
    Thanks you so much for the attention.
    Julie Chi
    null

    Gopal (guest) wrote:
    : HI,
    : Julie Chi (guest) wrote:
    : : So two frames have to use the same SessionInfo object . Dose
    it
    : : make sense?
    : Yes, if you are working with a master details relation, data
    for
    : both need to be fetched from the same oracle session. So both
    ur
    : frames need to refer the same session. If u refer the detail
    : frame to a different session, u will not see any data, because
    : the information comes from a different oracle session which is
    : not aware of the master data that is fetched. I think it is
    : clear.
    : regards,
    : --Gopal
    1.Use wizard and test the frame
    2.pass the sessioninfo object in parent to child(put method in
    child, call from parent e.g ..getsessionInfo(SessionInfo ss)
    3.pass the sessioninfo object to rowsetinfo in child
    4.add Database authentication (username/password is sufficient)
    methods right before publish method
    *publish activates RowSetInfo and connects to db
    5.add methods in parent to call child
    That should work though depending on how you have set up your
    wizard generated java form, might tweak
    Thanks
    iggy de iguana
    null

  • Can two bands use the same name on iTunes?

    Hi, I'm in a band that uses the same name as another band listed on iTunes.
    Can two bands with the same name be listed on iTunes? We hope to eventually have an album for sale on the site and I'd like to know now if it's going to be a problem.

    Of course it will be a problem. You simply can not have two bands with the same name. I can think of MANY bands that had to change their names (either completely or just for certain countries) because the name was already taken. Blink (Blink-182), Bush (Bush X), The Beat (The English Beat), Yazoo (Yaz), and the list goes on and on.
    Your band better start brain storming for a new or modified name.
    Patrick

  • Two computers using the same display

    Can I use one cinema display with two computers ate the same time. that is, can i have my MBP and a Mac Mini connected and switch between the two?

    Try Gefen and have a look in their Apple Section.
    I think a 2-1 DVI KVM switch is all you need. But of course the HD Mate Scaler will do everything.
    Message was edited by: dchao99

  • HT5622 I have two iPhones using the same Apple ID. I want to change the ID on one of the phones without changing the other. Can it be done without affecting the other devices that use the ID.

    How can I change the Apple ID on one phone but the other. Right now they both use the same ID.

    Sure.
    For the iTunes/App store...Settings>iTunes/App Store...tap the ID shown, sign out...now, sign back in with the ID you want to use. Be aware, any apps obtained with the old ID can only be updated using that ID, as all apps are forever tied to the ID used to obtain them.
    Fir iCloud: Settings>iCloud...turn everything off, including Find My Phone. For Contacts/Calendars, you'll be prompted to keep the data on the phone or delete it...your choice. Then, scroll down, Delete Account. Now, set everything back up using the new ID.
    This won't affect any data stored at iCloud.com, or any other devices.

  • Two phones using the same apple id

    I use the same apple ID for my daughters phone, hoever i do not want her to have my conatcts, etc... and vice versa but it has automatically copied them, how do i get rid of these and stop it happening?

    1. To create an Apple ID, you need a valid e-mail address.
    If you don't have one, there are a number of free e-mail account you can get e.g. Google GMail, Yahoo, Microsoft Hotmail.
    2. Once you have a valid e-mail address, create Apple ID below:
    https://appleid.apple.com
    3. You can share the purchasing Apple ID for both iPhone in
    Settings > iTunes & App Stores > Apple ID: > apple id here to share purchases eg. Books, Music, Apps...
    4. All other Apple services (FaceTime, iMessage, iCloud, etc...) you can use the same purchasing Apple ID and your daughter should use a different Apple ID.

  • Can two people use the same computer with two different ipods?

    I was just wondering if me and my mother can use the same computer with our ipods?

    Glad you asked. Before you get rid of the old one move its iTunes Library to the new one:
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/HT4527
    "Deauthorize" the old computer too. Go to the iTunes Store menu and select "Deauthorize This Computer..."
    I hope you get a Mac this time

  • HT1694 Is there a way to have emails sent to both your ipad and desktop and then be able to delete them off of your ipad while having them stay on the computer? Two people use the same email account.

    My parents use the same email address and both want to access all the emails that come in. My mom uses the ipad and my dad using the desktop. Recently the ipad started deleting emails off of the desktop when you deleted them off the ipad. Is there a way to get the messages deleted from the ipad to stay in the inbox on the desktop? Thanks!

    Yes, that would require a POP type email account. What you describe now is the proper functioning of an IMAP type email account.
    Contact your email provider to see if they can help.

  • Do these two tools use the same algorithm?

    Do Oracle In-Memory Database(TimesTen) and Oracle Coherence use the same algorithm?
    Both of them are in-memory databases?
    If not, what is the difference?
    Edited by: qck on Aug 11, 2009 8:17 PM

    No, they are different tools and they use different algorithm.
    Oracle TimesTen In-Memory Database is a memory-resident relational database. Deployed in the application tier as an
    embedded database, Oracle TimesTen In-Memory Database operates on databases that fit entirely in physical memory using standard SQL interfaces.
    Oracle TimesTen In-Memory
    Database libraries are also embedded within applications, eliminating context switching and unnecessary network operations, further improving performance.
    Oracle TimesTen In-Memory Database (TimesTen) is designed with the knowledge that data resides in main memory and can take more direct routes to
    data, reducing the length of the code path and simplifying algorithms and structure.
    Oracle Coherence is a JCache-compliant in-memory distributed data grid solution for clustered applications and application servers. Organizations can predictably scale mission-critical applications by using Oracle Coherence to provide fast and reliable access to frequently used data. Oracle Coherence enables customers to push data closer to the application for faster access and greater resource utilization. By automatically and dynamically partitioning data in memory across multiple servers, Oracle Coherence enables continuous data availability and transactional integrity, even in the event of a server failure. Oracle Coherence is a shared infrastructure that combines data locality with local processing power to perform real-time data analysis, in-memory grid computations, and parallel transaction and event processing.
    In my opinion, Oracle Coherence is more powerful. It mostly co-located on multiple server's memories. It is not only for databases (by integrating with The Hibernate or TopLink) but also for other applications.
    Edited by: jetq on Aug 11, 2009 11:20 PM

Maybe you are looking for