Home > > JTextArea - set specific amount of rows, or characters...

JTextArea - set specific amount of rows, or characters...

I'm working on a Applet which handles text according to given parameters. One of these parameters sets a JTextArea to the horizontal size of, lets say: 5 rows. What i want is that once this TextArea is set to a specific number of rows no text beyond those rows can be inserted. 5 rows, or a specific amount of characters are allowed.
My problem is that the TextArea wont stop allowing text vertically. The TextArea is visibly set to 5 rows, which doesnt change. But how can i stop text from being inserted beyond row 5?
We have tried a number of different approaches, from trying to set TextArea's size with invisible scrollbars to overriding invalidate()...
I never understand why people want to limit the number of rows in a JTextArea. Add the text area to a scroll pane and scroll bars will appear when the number of rows exceed the display area. The point of using a text area is to allow the user to enter data in a flexible format. If the format is not flexible then maybe you should be using another component or combination of combination of components.
Setting a maximum character size is valid if you intend to store the data on a database with a fixed size field. It is easy to do this by using a custom Document with you JTextArea. Read this section from the Swing tutorial on "General Rules for Using Text Components" for example code on how to do this:
Note, if you really want to limit the text area to 5 lines then count the number of new line characters in the document and don't allow them to enter more than 4.
Read the other 4 answers
This is the block of code that i have tried : import java.awt.GridBagConstraints; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JButton; import
Hi Experts, One of our customer wants to round the tax amount in each row of marketing documents. When searched the help of 'Document Settings:General Tab",  we found a setting field for this called 'Round tax amount in rows'. But the same is missing
What i am looking to be able to do is Export a specific set of rows from Numbers I am working with large files of information but would like to break the file up into smaller files for example I have 1 file with 40,000 rows I need to be able to expor
How can a specific number of rows be selected in a query? For example, a query retrieves 30,000 records and I want to retrieve the output by groups of 5,000. I want the query to retrieve the first 5,000 records, then the next 5,000 records etc. I tri
Hi, I would like to know how to get a specific number of rows. For example, I want to page data in my web application, so I'd like to be able to retrieve just 25 rows in my SELECT statement. I searched and I couldn't see anything under the obvious ke
hi all i want to fitch a specific number of rows in my query not all matches (SQL2000 Server ) what command in my sql query can be placed to do so thanksset rowcount nRead other 2 answers
Hi Gurus, I want to restrict my bank account to make payment only under specific amount say 5000 ETB. I have given the minimum payment and maximum payment and outlay controls in bank account. But when I am trying to create payment exceeding the Speci
I just started using Datatemplates to convert our Answers Reports over to Publisher. Basicly I am using the direct SQL to BI Server method. Copy the SQL from the advanced SQL field in BI Answers. Place new SQL in DataTemplate Construct DataStructure
I am working on a chart in pages with 7 columns. Problem has occurred with amount of rows. I have completed 999 rows and it won't allow me to continue. As I need to do approx 3000+ rows, can anyone explain to me how to add extra rows. Thanks JaneTry
Hello All, Quick question I hope... How do I request a set amount of terms and have the Oracle Agent stop, once the amount of rows has been reached. I am not looking for (example): select * from (SELECT rownum ROW_NUM, empID, empName FROM employees)
Hello, I would like an image to appear for only a specific amount of time after the user clicks a button. Is this possible? Thanks for any help!You cannot time with an advanced or shared action. Isn't a rollover image (which you can time) a valid alt
Hi All, Is there a known bug with the Customer Receivables Ageing Report and Suppliers Liabilities Ageing Report in SAP B1 v2005A PL 18? When trying to produce Backdated BP Aging report; 1. The Total amount for several BP accounts reflected on the ag
Hello, I need some help with regard to the impdp. I have table which is corrupted and the information of corrupted rows is also available with me now i need to exclude those rows in specific and import the other error free rows. Can you please let me
Hello, Using SSRS 2008, I need to create a report that populates information with a specific layout - that layout will always be the same. Just what populates it will change. In other words, I need to populate a grid but only certain rows and columns
In Captivate 5, is there a way to force a learner to view a slide for a minimum amount of time -- and to grade them on viewing for that amount of time?Let's say that you need the user to stay on a slide for a minimum 30 seconds.  Here are two ideas:
Hi, I have a table named orders which has column orderid and noofbookstoorder in addition to other columns. I want to query the orders table and depending on the value of the 'noofbookstoorder' value return that number of rows. Eg Orderid noofbooksto
As part of a school assignment, I we have output going to a textfield that is scrolled with JScrollPane. Part of it is for when it comes to 400 lines, and another line is added, that the first line of the output is erased, and the new one is added. A
I'd like to get Top-N of Amt within Name&Loc as shown below. Is there a way to reset either COUNT or ROWNUM to get this result? Name---Loc--(ROWNUM)--Amt James--abc--------1--1000 James--abc--------2---900 James--abc--------3---750 James--def--------
i'm listing all data entries in a database. for that i want to select the 1st ten entires, then the next ten and so on ordered by date_column. how can i do that? is it possible with rownum? in mysql/php i did it with limit $query = "select * from art