Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:14:49+00:00 2026-06-16T00:14:49+00:00

Here is my problem: I currently have a JTable containing anywhere from 5,000 to

  • 0

Here is my problem: I currently have a JTable containing anywhere from
5,000 to well over 200,000 rows. You see where I’m going with this.
The data is already loaded into memory, which isn’t a problem, but how
can I create an efficient JTable so that it only loads the rows that
are visible and that any events only act on those rows that are
visible in the viewport? Obviously scrolling is nearly impossible with
this much data, as it takes forever for the system to repaint and fire
events.

Basically I think one solution would be to determine which rows are in
the viewport, then create a new model containing those rows perhaps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:14:50+00:00Added an answer on June 16, 2026 at 12:14 am

    You might use a FixedRowsTable type design, here showing some of 200,000 rows. Though you’d want to add extra buttons << >>

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    
    class FixedRowsTable {
    
        public static void main(String[] args) {
    
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    String[] columns = {"1","2","3","4","5","6","7"};
                    Integer[][] data = new Integer[200000][columns.length];
                    for (int xx=0; xx<data.length; xx++) {
                        for (int yy=0; yy<data[0].length; yy++) {
                            data[xx][yy] = new Integer((xx+1)*(yy+1));
                        }
                    }
                    final int rows = 11;
    
                    JPanel gui = new JPanel(new BorderLayout(3,3));
    
                    final JTable table = new JTable(
                        new DefaultTableModel(data, columns));
    
                    final JScrollPane scrollPane = new JScrollPane(
                        table,
                        JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
                    Dimension d = table.getPreferredSize();
                    scrollPane.setPreferredSize(
                        new Dimension(d.width,table.getRowHeight()*rows));
    
                    JPanel navigation = new JPanel(
                        new FlowLayout(FlowLayout.CENTER));
                    JButton next = new JButton(">");
                    next.addActionListener( new ActionListener(){
                        public void actionPerformed(ActionEvent ae) {
                            int height = table.getRowHeight()*(rows-1);
                            JScrollBar bar = scrollPane.getVerticalScrollBar();
                            bar.setValue( bar.getValue()+height );
                        }
                    } );
                    JButton previous = new JButton("<");
                    previous.addActionListener( new ActionListener(){
                        public void actionPerformed(ActionEvent ae) {
                            int height = table.getRowHeight()*(rows-1);
                            JScrollBar bar = scrollPane.getVerticalScrollBar();
                            bar.setValue( bar.getValue()-height );
                        }
                    } );
    
                    navigation.add(previous);
                    navigation.add(next);
    
                    gui.add(scrollPane, BorderLayout.CENTER);
                    gui.add(navigation, BorderLayout.SOUTH);
    
                    JOptionPane.showMessageDialog(null, gui);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well guys; Here's my problem: I currently have a class extending another that will
I have a big problem with JTable . Here is how it works: a
Here is a simple Prolog program to exhibit a problem that I currently have
I currently have a problem where my program should show parameters from each class
I currently have a simple <div contenteditable=true> working, but, here's my problem. Currently, the
So here is the problem I'm having currently...I have a ASPX script that runs
Here is the problem and what I currently have, I just don't understand how
Ok So here is the problem we are facing. Currently: We have a ton
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 application
so here is the problem. I am currently creating an Android app that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.