Too much data for JTextArea

Howdy people, I've been stuck on this problem for a while now. I writing a povvy hex-editor, and it works (yay!), but when I open largish files (>= 20kB) it really chokes on it. Not on the conversion from bytes to hex string, but (you guessed it) displaying it in the JTextArea. I've tried a couple of things. Make it a Thread (so it can update a pretty progress bar), I tried appending the data in sections, instead of one giant setText().... No go.
Here's what I have so far:
import javax.swing.JTextArea;
public class DisplayThread extends Thread
    private static final int BUFSIZE = 100000;
    private FileEditor parent;
    private JTextArea textArea;
    private StringBuffer data;
    private ProgressDialog pd;
    public DisplayThread(FileEditor p, JTextArea jta, StringBuffer s, ProgressDialog pr)
        parent = p;
        textArea = jta;
        data = s;
        pd = pr;
    public void run()
        System.out.println("starting DisplayThread");
        long time = System.currentTimeMillis();
        textArea.setText("");
        int len = data.length();
        for(int i=0;i<len;i+=BUFSIZE)
            int n = (i+BUFSIZE<len)?i+BUFSIZE:len;
            textArea.append(data.substring(i,n));
            pd.setProgress(i, len);
        System.out.println("It took " + (System.currentTimeMillis() - time) + "ms by buffering");
        time = System.currentTimeMillis();
        textArea.setText(data.toString());
        System.out.println("It took " + (System.currentTimeMillis() - time) + "ms directly");
        textArea.setEditable(true);
        pd.setVisible(false);
        System.out.println("finishing DisplayThread");
}At the moment I've got both the "bit-by-bit" display method, and the "one-shot-setText()" methods going to compare times, but check out these times for a 900k file...
It took 673439ms by buffering
It took 137628ms directly
For the first one, that's over 11 mins!!!!
Anyway, I did searches on what to do in this scenario, one answer was Don't!, the other was "only display what's necessary".
So...
I've tried to create a "BufferedJTextArea", and only set the text according to what will be visible in the scrollpane/scrollbar, but it's not working (all sorts of complications with adding a scrollbar to a JTextArea, or adding a JTextArea to a scrollPane....)
Also, even after it loads all the data into the JTextArea, it takes it's sweet time to repaint...
Any ideas on how to make it faster? Continue with the "BufferedJTextArea" (if that's the case, that'll be the next question)?
Or give up and warn ppl not to load files larger than about 15k?
Thanks ppl,
Radish21

But with a JList, you can only have one column, right? That'd mean I have to break up the String with \n all over the place.
I did look at JTable first, and even tried to use one, but I've never used them before, and now I know why. Too damn difficult.
I'm getting closer now, but still having hiccups (or is it hiccoughs? :)
I had to make the class a JPanel itself, that adds a BufferedTextArea to a JScrollPane... it works, so why fix it? ;)
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import java.awt.event.AdjustmentListener;
import java.awt.event.AdjustmentEvent;
public class BufferedJTextArea extends JPanel
    protected BJTextArea textArea;
    protected JScrollPane scrollPane;
    public BufferedJTextArea()
        textArea = new BJTextArea();
        scrollPane = new JScrollPane(textArea);
        scrollPane.getVerticalScrollBar().addAdjustmentListener(textArea);
        setVisible(true);
        setLayout(new java.awt.BorderLayout());
        add(scrollPane, "Center");
    public void setText(String s)
        textArea.setText(s);
    private class BJTextArea extends JTextArea implements AdjustmentListener
        protected static final int BUF_SIZE = 4096; // display 4kB at a time
        protected String data;
        protected int len, startIndex = 0, endIndex = 0;
        private java.awt.FontMetrics fontMetrics;
        private int val = 0;
        public BJTextArea()
            super();
            setLineWrap(true);
            setVisible(true);
            fontMetrics = getFontMetrics(getFont());
        public void adjustmentValueChanged(AdjustmentEvent e)
            val = e.getValue();
            adjustView();
        public void setText(String s)
            data = s;
            len = data.length();
            startIndex = 0;
            if(len <= BUF_SIZE)
                endIndex = len;
                super.setText(data);
            else
                endIndex = -1;
                val = 0;
                adjustView();
        protected void adjustView()
            if(endIndex == -1 && startIndex == 0)
                endIndex = java.lang.Math.min(len, BUF_SIZE);
                super.setText(data.substring(startIndex, endIndex));
                return;
            if(len <= BUF_SIZE)
                return;
            int startLine = scrollPane.getVerticalScrollBar().getValue() / getRowHeight();
            int linesVisible = // haven't worked out what goes here yet
            // Some way to work out whether I need to adjust things.
}Anyway, thanks for the tips, but I think you're right, I'll stick with the BufferedJTextArea....
If you have any ideas about checking for if the view is about to get out of range, let me know. Also, I've tried setting the vertical scrollbar's maximum value, but it ignores me (because I need it to be reflect the entire data string, not just the segment displayed). If you have any ideas, they'd be greatly appreciated.
Cheers,
Radish21

Similar Messages

  • I have been recently trying to get the update for the new iOS 7.1 and it keeps coming up as too much data for update. It says to check your storage and or usage and edit it them, but when I go check I have over 7.8GB of messages "saved" on my phone.  why?

    I went to my data after this message kept coming up and unlike the rest of the usage data you cannot delete your "saved" message data. I tried deleting some photos (which I don't have a lot to begin with; now I only have 40) still nothing. I then went to to my local apple store in the mall and the two guys I talked to didn't help. They said to delete the threads which I did, then delete the pictures which I also did and that should help. They were wrong they I'd say however to reset your phone if all else fails and that will deffinelty do it. But I don't want to lose all of my data so I am trying to save my things on iCloud and it won't let me do to my storage. There have been similar situations like mine on here but the backup bot isn't working on my computer. At this point I am just so lost and confused I don't know what to do. Someone please help

    Snowden has already commented on this. Messages are stored on Apple devices until they are uploaded for screening to the NSA. Apple holds these messages on your device and on the cloud service. Once the information has been uploaded to NSA, the messages then delete off your device. In order to not arouse suspecion, the device will always show you some amount to data as space being occupied on your device. Theorecically this data could be over written and not protected if they were on hidden sectors of your memory. The information stored on this "messages" partition is actually more than messages, thats why this space commitment can easily reach 3 gigs. Any computer science specialist will tell you that ASCII characters only use minimal kilobytes of data. Apple complies with this request to upload your personal data as outlined in the Patriot Act. The only way to delete this "messages" data hold is by doing a complete wipe of your device and not conducting a restore. It will clear the space off your device, but NSA actually has the information from the cloud service regardless.

  • Adobe encoder too much data for the media how to adjust within encoder

    I am trying to export a project to encore/ bluray via mpeg format from premiere 3 encoder. This project is 2hrs 20 mins long and at medium quality I get 26 gigs how to i bring the data amount down to facillatate burning in encore. All my chapters are set to be menued within encore.
    The second part is which is best route to encode the mpeg or the h264
    Thanks
    Joan

    Joan,
    The only way to decrease space is by lowering bitrates at the cost of quality.
    Use this calculator: http://dvd-hq.info/bitrate_calculator.php to get the best bitrate for your material.

  • Since upgrading my phone to 6.0.1, I'm using way too much data. I believe it's the podcast app that's not loading shows while I'm connected to wifi. I have the 3g turned off for podcasts??? also after a phone call or an alert it starts playing a podcast?

    since upgrading my phone to 6.0.1, I'm using way too much data. I believe it's the podcast app that's not loading shows while I'm connected to wifi. I have the 3g turned off for podcasts??? also after a phone call or an alert it starts playing a podcast?

    I've also had the same issues, after upgrading to IOS 6.0, the apps in my iPhone 4 were crashing and the battery life run out very fast.
    The only solution worked for me was to remove all mail accounts (Exchange/Gmail) from my iPhone (in settings) and then add them back.
    The crashing were stopped! also the battery was back to normal.
    I found the solution by first looking at the crash logs (in IOS 6). you can find them at Settings -> General -> About (at the bottom of the About menu you will find the option that opens the logs).
    There i saw many logs about Low Memory crash. 99% of the logs were pointed that the largest process (use the most memory) during the crashes is "dataaccessd".
    I search in the web and found that this process is a deamon process that reponsible the Mail accounts (like Exchange/Gmail) and contancts list.
    I've installed the app "System Status - activity monitor" which shows important system info like CPU usage, Memory usage and running processes.
    Before apply my solution (deleting the mail accounts) i saw that the CPU usage was very high which consume the battery very fast. Also i saw that the memory (RAM) was run out.. which probably what cause the crashing..
    After deleting the mail accounts (at Settings -> Mail, Contacts, Calendars) i check again with the System Status app, and saw that the memory and CPU were back to normal.
    Adding the mail accounts back, still everything work ok
    Hope this solution will help you too,
    Enjoy!

  • Is there a way to have internet access for my laptop through Verizon?  I have a smartphone, but I don't want to rack up too much data.

    Is there a way to have internet access for my laptop through Verizon?  I have a smartphone, but I don't want to rack up too much data.  How would the laptop connect to the  4G? network?  Thanks for any info:)

    Rcshnoor nailed it, everything will depend on how they manage their data connection once the laptop is connected.  It is perfectly feasible that they will have no issues with this new connection.  However, there is nothing stopping the user from going above and beyond the data usage cap currently sufficient for the phone by itself.  We cannot presume that any estimations on new usage will be accurate either.
    Users should always be aware of the reality that revolves around data usage and the devices that consume them.  Its no different than installing a 2nd waterline/hose on your house.  Sure the hose will be fine if you remember to turn it off when you are done, but no one is going to stop you from letting it run all night if you forget.

  • Applications are using too much data

    my iphone 5 fatching too much data on every application like facebook , whats app etc...

    Thanks for sharing.  I'll share something with you.  My Sony TV has a great picture.

  • Suddenly using too much data?

    Hi everyone,
    I have had my iphone 5 for over a year. For the first couple of months I had problems with using too much data but eventually learned it was my email causing the issues (it was updating automatically). Fast forward this past Christmas. I got an iPad 2, and ONLY use it at home when it's connected to WiFi. To be completely honest, I am not even 100% sure if it supports cellular data at all, although I don't believe it does as there's nothing mentioned of cell data in Settings. Now for the past 2 months, I have been using too much data and having to pay extra on our cell bill and I have no idea what has changed besides updating the iPad and my phone (I just updated my phone a couple days ago) to iOS 7.0.6. The charges aren't enormous or anything, I think it was around $8 extra last month but still, I don't know what has changed. I have already gotten a text from my provider (Telus - Canadian company) today saying that I am now paying for my data usage, because we (my husband and I combined) have used our data alotment for the month. I know the problem is my phone because I used about double the amount of data as he did on our last bill. I tried calling my provider, but I was on hold for ages so I will give it another go tomorrow if I can't get something figured out in the meantime.
    So my questions are: 1) Could it be the iPad using data? I do have it set so that it backs up to iCloud when plugged in (I believe, my sister in law set it up for me), and it syncs my photos from iphone to the ipad. As you can probably tell, I am just slightly technologically illiterate here. I also did get a new keyboard case for it last month that uses bluetooth.
    2) If it's not the ipad, any ideas of where the data could be going? I use my phone mainly for texts and calls, Facebook, email, some internet browsing, but it is set to WiFi. I mostly use it at home where there is a WiFi connection. Although my young kids do play Angry Birds and watch some videos when we are driving. I don't believe the amount of games they play and videos they watch have changed though, that has been an ongoing thing.
    Thanks for any advice, I would like to nip this in the bud before something gets out of control.

    Update: I got my bill today, and as suspected I have used way more than half of our shared data plan (which is 1GB - I used 1760Mb). I have had my cellular data either completely turned off, OR turned on but not allow any apps to use it (I noticed that I was having some issues with not being able to send/receive texts if my data was compeltely turned off... Not sure why, but that's another post I guess)  since I started this post. I called Telus and she wasn't able to tell me where any of my data was going, she just kept saying "well you've only spend $3.69 in data for last month" and asked me if I was completely closing out apps, which I do every other day or so. She just recommended that I download an app called My Data Manager to set a limit on how much cellular data I am using, however the app doesn't tell me WHERE the data is going which is my concern. So I'm kind of back at square one. I'm not sure if I should allow my kids to play their games and do as I normally do on the phone until the data gets racked up and then I can try to figure out where it's going, or what. My billing cycle started on March 18 and since then I have used 1MB (approx.) of data, but I was in the US for 4 of those days and had the data turned off completely, so again not sure where that 1MB went. One thing I have started doing that is new, is playing downloaded music (music that I have on iTunes, and put onto my phone) in the car. I thought since it is music that I have put onto the phone (not streaming music) it wouldn't be using any data, but on March 19 (the day before we left for the US), I was playing music in the car with my data turned off, and when a song ended and I tried to play another one it said that the cellular data was turned off and I needed to turn it on. I didn't turn it on, but I did put the phone into airplane mode and was able to play my music that way. Could that be using cellular data? If so, then I know where it has been going!

  • My messages app won't open, after I sent a large iMessage. I think it just has too much data on it. What can I do other then reset my iPhone?

    My messages app won't open, after I sent a large iMessage. I think it just has too much data on it. What can I do other then reset my iPhone?

    Hi everyone, I had this problem but none of the solutions above worked. What happened with me, and with others in other forums, is that a particular thread or message was causing the problem. I'd go to open the message and all I'd get was a white screen with the blue bar at the top. So, I went into contacts, pressed 'send message' to a contact whose message wasn't causing the problem, then I pressed back to messages. You then swipe to the left on the thread that's causing the problem, and delete it. Sadly this means you will lose all that person's messages, but you can try opening it from there and deleting it on the thread. Didn't work for me though. Hope that helps! It was the only thing that worked for me after about three days of total frustration and resetting!

  • My daughter has sent me over 100 photos via 8 messages and can't see them as message crashes every time I try to open, probably too much data but what do I do?

    My daughter has sent me photos to my iPad mini, when I go to messages it crashes, probably too much data, what can I do?

    My daughter has sent me photos to my iPad mini, when I go to messages it crashes, probably too much data, what can I do?

  • Bought i phone 6 64 GB just 3 days before performance is very bad.Couldn't even open app store it takes too much time for opening a web page.

    bought i phone 6 64 GB just 3 days before performance is very bad.Couldn't even open app store it takes too much time for opening a web page.

    You may need to reset your network settings, making sure the network you're accessing is stable: tap Settings > General > Reset > Reset Network Settings.
    If your iPhone still can't connect to App Store, tap Settings > iTunes & App Store > tap the Apple ID and sign out > later, sign in with your Apple ID.

  • I bought a new 13 macbook pro with 4gb and would like to get aperture 3.4.3.  Will it require too much ram for my computer?  Thanks

    I just bought a macbook pro 13" with 4gb and would like to get aperture on it.  Will aperture require too much ram for my computer?  Thanks for any support.

    I just bought a macbook pro 13" with 4gb
    I have been using Aperture on such a system, and it was o.k. with Snowleopard and moderately sized images. After I upgraded to Lion and started to user larger image files - 30 MB tiffs, I saw the occasional beachball spinning. You should be prepared to quit other applications that will hog the RAM (like Safari), when working with Aperture on Lion or Mt. Lion with only 4 GB. If you can, follow Frank Caggiano's recommendation and upgrade to 8GB. It will make a large difference.
    Regards
    Léonie

  • Wrvs4400n file transfer connection trouble "Too Much Data"

    Hi when connecting trying to do file transfers over IRC in mirc, when some people try to send me files, they get a "Too much data recieved" Error, only happens with this router (i have a wag200g and that works perfect)
    this is while trying to establish connection and only seems to effect one port (443) thou i only have 3 ports to test, the other 2 work fine
    any ideas?
    Message Edited by Nirces on 08-09-2007 10:00 AM

    try reducing MTU to 1365 on the router, also try reflashing the firmware...check whether it makes any difference or not.

  • I have too much music for one ipod.  What's the easiest way to sync half of my library on to one ipod and the other half to another?

    I have too much music for one ipod.  What's the easiest way to sync half of you library on to one ipod and the other half on to another?

    Make playlists and choose whatever playlists you want to sync

  • HT1695 Recently my iphone is consuming too much data, I have installed a data monitoring app and I found that - although I turned off all notifications and push email - push services is using around a 1mega/hour from cellular data (even if I am using wi-f

    Recently my iphone is consuming too much data, I have installed a data monitoring app and I found that - although I turned off all notifications and push email - push services is using around a 1mega/hour from cellular data (even if I am using wi-fi) !!!

    cpupower frequency-info
    analyzing CPU 0:
    driver: acpi-cpufreq
    CPUs which run at the same hardware frequency: 0 1 2 3
    CPUs which need to have their frequency coordinated by software: 0
    maximum transition latency: 10.0 us.
    hardware limits: 800 MHz - 2.30 GHz
    available frequency steps: 2.30 GHz, 2.30 GHz, 1.80 GHz, 1.60 GHz, 1.40 GHz, 1.20 GHz, 1000 MHz, 800 MHz
    available cpufreq governors: conservative, powersave, ondemand, performance
    current policy: frequency should be within 800 MHz and 2.30 GHz.
    The governor "conservative" may decide which speed to use
    within this range.
    current CPU frequency is 800 MHz.
    cpufreq stats: 2.30 GHz:0,02%, 2.30 GHz:0,05%, 1.80 GHz:0,05%, 1.60 GHz:0,03%, 1.40 GHz:0,01%, 1.20 GHz:0,16%, 1000 MHz:0,38%, 800 MHz:99,29% (1017)
    boost state support:
    Supported: yes
    Active: yes
    25500 MHz max turbo 4 active cores
    25500 MHz max turbo 3 active cores
    25500 MHz max turbo 2 active cores
    25500 MHz max turbo 1 active cores
    Thax

  • My iphone5 using too much data

    ANyone know why im using so much data on my iphone 5 ive never down loaded music films or any thing and used up 1gb in 17days

    Your probably using alot of facebook and twitter and the internet. All use alot of data.The Iphone 5 just uses data for everything either use WIFI whenever you can or upgrade your phone plan to the most data possible. Make sure you close down the apps too when your not using them. Sneaky phone services probably charge you for that.
    GL

Maybe you are looking for

  • Multiple Apps using same security system -  Attn: Frank

    Hi Frank: Based on what you suggested for a scenario with different apps/databases using one "application_users", "application_roles" tables and one "system-jazn-data.xml" file, does the following setup sound right? (1) APPLICATION_ROLES table Add an

  • DVD burn error

    I've recently been having drive problems - the player sometimes refuses to play a dvd movie several times before finally loading and playing. But the big problem is that I can't burn dvds. I put in a blank Magnavox DVD-R, icon appears on the desktop,

  • Nokia 6700C copy and paste function

    Hi does anyone know how to use this function on the above phone, i cannot seem to find it

  • Urgent: problem with getting itresource parameters

    Hi all experts, I have problem getting it resource parameter, for ex, I have ADITResource, now i want to get details like administrator id, password, ssl etc for this i am using this code ConfigurationClient.ComplexSetting config = ConfigurationClien

  • Is there any possibility to protect number file with pas word ?

    Good morning, As many people may use my Ipad, I would like to prevent somebody having acces to confidential file created with numbers. As it exist with Excel, is there any possibilty to protect files with password ? Thanks for your help.