Removing Items from a TextArea/Pane Component
Hi All,
I have a question about text containers. Basically I'm reading Strings from a file and I'm displaying them inside a JTextArea. I'm adding new Strings to the JTextArea using it's append() method. Is there a way to limit how much stuff should the JTextArea hold ? After a while my application crashes with the following message:
java.lang.OutOfMemoryError
<<no stack trace available>>
Exception in thread "main"
This is because so much stuff got accumulated in the JTextArea that it eats up all available memory and the app crashes. My question is; is there a way I can remove items from the JTextArea ? Or is there a way to limit the size/number of Stings it can hold ? Or should I be using something else instead of the JTextArea ? Thanks in advance...
-Pete
int size = textArea.getDocument().getLength();
gives the total number of bytes in the text area. You can then use:
textArea.replaceRange("", 0, 80);
to remove 80 characters from the start of the text area. Or to remove the first line from the text area use:
int start = textArea.getLineStartOffset(0);
int end = textArea.getLineEndOffset(0);
textArea.replaceRange("", start, end);
Design your own routine to keep the text area at a reasonable size.
Similar Messages
-
Q: remove item from Notifications preference pane
I've tried than deleted a few shareware apps. However, the components they installed still appear in Notifications (i.e., the Preference pane in System Preferences, not the Notification Center that slides open from the right).
I don't see any way to remove these items; how do I get rid of them?There isn’t a way to do that easily.
And, it is completely unnecessary. The items in the list are just text in a file. They don’t do anything and don’t indicate that some part of the program still remains.
The list is likely a sqlite3 database, so you would have to figure out which file holds the database, and then figure out how to write the SQL Delete statement to remove the apps. -
JList run time errors when removing items from list
Hi there
I am having trouble removing items from a JList. For a While it was working fine and now it outputs runtime errors everytime samething gets removed from the lsit
Here is the code
//declare
public class Consumertab1gui extends JPanel implements ActionListener
public static JList conList = null;
private static DefaultListModel model = null;
// Create a list with some items
model = new DefaultListModel();
conList = new JList(model);
//set the size of cells in the list with the length of the string
conList.setPrototypeCellValue("Lenght 1234567890");
conList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
conList.addListSelectionListener(new ValueReporter());
//set a scroll onto the list
JScrollPane conScroll = new JScrollPane(conList);
add(conScroll,c);
//when the button gets pressed to drop the selected item the following code is called
private void dropConsumer()
int selItem=0;
componentsV.comVRemove(conList.getSelectedValue().toString());
selItem=conList.getSelectedIndex();
System.out.println("No:"+(model.getSize()-1));
System.out.println("S:"+selItem);
remConList(selItem);
dropCon.setEnabled(false);
//which in turns calls this
public void remConList(int pos)
model.remove(pos);
when the model.remove(pos) code is executed the following runtime errors are given:
java.lang.NullPointerException
at Consumertab1gui$ValueReporter.valueChanged(Consumertab1gui.java:197)
at javax.swing.JList.fireSelectionValueChanged(JList.java:1321)
at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1335)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:214)
at javax.swing.DefaultListSelectionModel.removeIndexInterval(DefaultListSelectionModel.java:546)
at javax.swing.plaf.basic.BasicListUI$ListDataHandler.intervalRemoved(BasicListUI.java:1561)
at javax.swing.AbstractListModel.fireIntervalRemoved(AbstractListModel.java:160)
at javax.swing.DefaultListModel.remove(DefaultListModel.java:478)
at Consumertab1gui.remConList(Consumertab1gui.java:38)
at Consumertab1gui.dropConsumer(Consumertab1gui.java:58)
at Consumertab1gui.actionPerformed(Consumertab1gui.java:46)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5100)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
can anyone spot any mistakes in the code or suggest possible resons as to why these run time errors occur?
Thanks
alexisjava.lang.NullPointerException
at Consumertab1gui$ValueReporter.valueChanged(Consumertab1gui.java:197)The NullPointerException occurs at line 197, in the valueChanged method of your ValueReporter inner class. I have looked through your post several times but I don't see where you posted that method. Anyway, that is where you should look.
PC² -
How can we remove items from the VF04 list?
We have a long list of items in VF04 that, for various reasons (some process related, some due to errors), are not to be billed. We have looked at applying filters to the list but there is nothing really suitable to hide these individual documents e.g. we could filter out some dates where none of the items on that date are to be billed but other dates have a mix of items we want to bill and others we don't.
I have done a search of this forum but didn't find a previous topic with a quick and simple method to remove items from the list .
Is there a method, other than billing them or sorting each issue individually, to permanently remove individual documents from the VF04 list?
Thanks in advance for any help.
DavidHi,
David,
Download a list of Pending delivers doc form VF04.
Paste the list in T.Code : VL09 (Delivery reversal) and reverse the delivery.
Then go to T.Code: VL06G Select the list of deliveries that has been reversed, select/delete all un- wanted deliveries.
This way you can remove all unwanted pending deliveries forn Billing due list (VF04).
Thanks & Regards,
R.Janakiraman -
How can i update/Remove Items from AR Invoice using SDK?
Hi All,
I have 1 problem with update or remove item from sales order. here is the source code of mine.
If inv.GetByKey(DocumentNumber) = True Then
inv.CardCode = cardcode
Dim ercode As Integer
Dim ind As Integer = 1
For Each drow As DataGridViewRow In gv.Rows
If gv.Rows.Count = ind Then Exit For
ercode = drow.Cells("No").Value
inv.Lines.SetCurrentLine(ercode)
'inv.Lines.ItemCode = drow.Cells("itemcode").Value
'inv.Lines.ItemDescription = drow.Cells("itemname").Value
inv.Lines.Quantity = drow.Cells("qty").Value
inv.Lines.Price = drow.Cells("price").Value
ind = ind + 1
Next
errorcode = inv.Update
If errorcode <> 0 Then
PublicVariable.oCompany.GetLastError(errorcode, errorsms)
Else
errorcode = 0
End If
Else
errorsms = "Not found Invoice Document Number"
End If
After update, it error "[INV1.Quantity][line:1],'Field cannot be updated (ODBC -1029)'"
Does anybody know about this?
Thanks
TONYHi $riniva$ Rachumallu,
This is my mistake that not test manually in application.
Thanks
TONY -
How do I remove items from the cloud without losing them permanently?
My icloud storage is almost full. How do I remove items from the cloud and not lose them?
What items?
Purchased music, movies, TV shows, apps, and books do not use up your iCloud storage.
See the link below for how to reduce the amount of storage you're using:
http://support.apple.com/kb/HT4847 -
How do you remove items from the assets panel that are duplicated?
How do you remove items from the assets panel that are duplicated?
If you add an item to a slideshow, you'll usually see 2 entries for that image in the assets panel - one represents the thumbnail, and the other represents the larger 'hero' image.
It sounds like you may have added the same image to your slideshow twice. You can select one of the hero images or thumbnail images in your slideshow and use the delete key to remove it. Then the extra 2 entries in the assets panel should disappear. -
How do you remove items from the start up disc
How do you remove items from the start up disc?
Freeing Up Space on The Hard Drive
You can remove data from your Home folder except for the /Home/Library/ folder.
Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
Also see Freeing space on your Mac OS X startup disk. -
How do I remove items from the dock?
How do I remove items from the dock ?
Single click and then drag it to the desktop. It will dissapear in a puff of smoke. You also may benefit by bookmarking and using:
Find Out How Video tutorials -
Can I remove items from the Services menu?
I think the subject line says it all: can I remove items from the Services menu? I have a number of items in the Services menu that I never use and I would like to make the menu shorter to make it easier to access the items that I do use.
There are a couple of things you could try. There's an application called Service Scrubber that is supposed to do this. But the web page says it's for 10.4, though it says it might work on 10.3
Alternatively, you can edit the Info.plist or Info-macos.plist file in each application bundle to remove its service from the Services menu. This post at Mac OS X Hints has a pretty detailed description of how to do it. I tried this on my iMac running 10.3.9 and it worked just fine.
Don't know about the Service Scrubber app, but if you edit the plist files, you'll need to log out and log back in before the changes take effect.
Also, if you decide to edit the files by hand, I'd suggest just renaming NSServices by adding an "x" to the front or something, rather than deleting the item completely. That makes the changes easier to reverse.
charlie -
How can i remove items from list that have been deleted when i click on them it keeps showing empty
how can i remove items from the list that have been deleted when i click on them it keeps showing folder empty
Actually, Reader SHOULD keep showing documents that no longer exist, I disagree. It's no big deal, and people will quickly realise why they can't open the file. They open more files, the old ones move off.
The REASON why it should not check is that checking whether a file exists can take a long time when things aren't good. For instance if a file server goes down, or a memory card is unplugged. That in turn would mean delays opening the File menu, and I've seen some software that can sit there for several minutes. That would really give people something of which to complain... -
How can I remove items from the open a recent file menue.
How can I remove items from the "Open a Recent File" menue. Many other applications allow the clearing of that file . Is this possible in Adobe Reader 10.1.2 ? If so how?
See this previous topic: http://forums.adobe.com/message/3759596
It is for Acrobat, but the registry entries are similar for Reader. -
How can I add and remove items from the bookmarks toolbar?
I want to remove items from the bookmarks toolbar and add ones that I use on a regular basis. How can I do this?
See:
*https://developer.mozilla.org/en/Chrome
*http://en.wikipedia.org/wiki/User_interface_chrome#User_interface_and_interaction_design -
Removing items from sheet doesn't change SQL
Discoverer desktop 10.1.2.1
When I create a sheet, run it, then remove items from the sheet, and then refresh it, the SQL doesn't change (items/columns that were removed remain in the select statement). They (columns) are removed from the resulting report, but it's throwing off my results (number of rows due to summary items). In other words, I had detail numbers, replace them with summary numbers, now it should be grouping by the detail items, but it's isn't. Basically, the tool isn't removing those items from the SQL.
Has anyone seen this?
Thanks in advance.I'll chime in on this one - we're seeing this same behavior as well. I can reproduce the problem at will like so:
1) Create a new sheet.
2) Pick a table, any table, that has a data point.
3) To this new sheet, add the DETAIL of the data point, and one other attribute.
4) View the results - they are good.
5) Realize you made a misteak, go to Edit Sheet, remove the DETAIL and replace it with the SUM of that same data point.
6) View the results, and become dismayed that they are not grouping at all.
7) Click on View->SQL Inspector, and observe the detail item is still in the SQL (along with the SUM) despite having removed it in the sheet editor.
8) Edit sheet - remove all items leaving absolutely everything blank (no selected items, no columns, no calculations, no sorts, nothing)
9) Click on View->SQL Inspector, and observe the detail item is still in the SQL. That's wrong!
If that's not a bug, I'm czar of all the Russias.
// Discoverer Desktop 10.1.2.1
// Discoverer Desktop Client 10.1.2.48.18
// EUL Library 10.1.2.48.18
// EUL 5.1.1.0.0.0 -
how do i delete from the startup disk? I am trying to get Mountain Lion from the App store and it says that the purchase was not complete because i need 4.06 GB space to download OS x 10.8. and to remove items from my startup disk to increase space. How?
ThanksYou can use iCloud with 10.7.5. You do not need to upgrade to Yosemite. You should provide a minimum of 15 GBs of free space or 10% of the hard drive's capacity, whichever is greater.
Freeing Up Space on The Hard Drive
1. See Lion/Mountain Lion/Mavericks' Storage Display.
2. You can remove data from your Home folder except for the /Home/Library/ folder.
3. Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
4. Also see Freeing space on your Mac OS X startup disk.
5. See Where did my Disk Space go?.
6. See The Storage Display.
You must Empty the Trash in order to recover the space they occupied on the hard drive.
You should consider replacing the drive with a larger one. Check out OWC for drives, tutorials, and toolkits.
Try using OmniDiskSweeper 1.8 or GrandPerspective to search your drive for large files and where they are located.
Maybe you are looking for
-
I am creating a document in Indesign CS4 that is to be exported as a pdf. Within this one page document, there are approximately 40 listed products, one after the other and each product has been set up to hyperlink to a specific pdf in the same direc
-
IPod Playlists Grayed out in iTunes
I used to be able to play my iPod songs through iTunes while connected to my computer via the USB. Not now. I'm figure I'm missing something obvious. I did re-authorize the computer because I bought a game. Songs are still grayed out. iPod plays fine
-
Loading Demand plan data from APO to BW
Hi Gurus, We have requirement as below. we have to extract two key figures from APO to BW system The 2key figures of APO will get data as below: First key figure has to hold Yearly snap shot and 2nd Key figure has to hold QTY snapshot. we have constr
-
Encountered an unexpected error
Hi to All, I m using jdeveloper 10.1.3.3.0.3 version. And, i m beginner for jdeveloper, currently i design Hello Page and when i run it gives error "You have encountered an unexpected error. Please contact the System Administrator for assistance. " a
-
How to clear search history in maps on iphone4'
any help?