Java – use JTable to display the slow performance of streaming data

The code I referenced is proprietary and requires a multicast server, so I cannot publish sscce code snippets I understand that this may exclude any useful insight and trigger a viable response

I am compiling using java 7 u 9

I am currently using JTable in GUI applications to listen for multicast data and display it when it arrives When scrolling tables or resizing columns, the application responds very slowly

I thought I built my code correctly

I use a wrapper class. In its main () function, it creates an instance of itself. It handles command line parameters, creates listeners, creates jframes, and calls the class that returns JTable This is done outside the event dispatch thread

Then, on the next line, I use the invoker () method to create a thread that handles all GUI rendering It creates a JScrollPane, adds JTable to the scroll pane, sets the scroll bar, sets the viewport, sets the scroll mode, and adds JScrollPane to JFrame This is handled in the event dispatch thread

These lines usually fill fairly quickly and occasionally the screen freezes (some lines contain 30 or more lines), but the responsiveness seems acceptable However, when scrolling or resizing columns, the response is very slow

All the examples I've seen, including the swingx swinglabs demo, refer to the preloaded initial data set I need an example of using JTable and streaming data

Who can give me such an example / demonstration?

This is my main () clip

public static void main(String args[]) 
{
    final JXTrapTableGUI ttg = new JXTrapTableGUI(args);
    SwingUtilities.invokelater(new Runnable()
    {
        public void run() 
        {
            ttg.createAndShowGUI();
        }
    });
}

PS. I want to thank everyone who replied I have postponed this item until March 11, but I will review all responses by that date

Solution

I don't think JTable is suitable for streaming data at all If the tablemodel does not contain the actual list but some connections to the data flow, all the optimization techniques you mentioned (such as keeping the event scheduling thread processed) are irrelevant

If you don't see how you're trying to deal with this problem, it's hard to know exactly why it slows down But that's how I make it representative: create a listmodel that stores a list - not a streaming reference, just an ordinary list Let another thread capture multicast data from the stream, let's call it datastream collector Then start a thread running on a timer (javax. Swing. Timer) that checks the datastream collector and updates the listmodel as needed

My design assumes that UI response is more important than 100% synchronization with data flow Adjusting the timer should allow you to make trade - offs in the latest table with a responsive UI

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>