Line limit for JTextArea - Urgent

Hi All,
I would like to have 80 character limit for each line displayed in JTextArea. The linewrap along with wordwrap have been enabled for JTextArea but that solves a part of the problem. The no. of characters that can be entered per line depends on the width of the component and the font size. For this component there is no upper limit for the total no. charaters that can be entered. Basically, it supports text editing feature(cut, copy, paste). One way it could have been done by fixing the width of component so that it could accomodate only 80 characters, but again the factors like screen resolution, font's advance width keeps changing. I tried with overriding insertString() of PlainDocument class, but didn't know how to wrap the characters after 80 position to next line if text is inserted in the middle of a line. At the same time the whole text needs a reformatiing. Same behavior is desirable while doing cut/paste operations.
A hint or sample code will be highly appreciated as it has been a long time I am looking to solve this problem.
Thanks
Ritwick.

You are correct it is not easy to override the default behaviour of the JTextArea. So my suggestion is to use a monospaced font. The code would then be:
JTextArea.textArea = new JTextArea( "some text", 10, 80 );
textArea.setFont( new Font("monospaced", Font.PLAIN, 12) );
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane( textArea );
scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );If using a monospaced font is not possible, then please explain why wrapping at exactly 80 characters is so important, maybe there is a different approach to take.

Similar Messages

  • Urgent: Setting character limit for JTextArea

    Hi, I am newbie to java swing and I have a question.
    I need to set a limit of 2000 characters that can be typed in a text box(JTextArea). How do I do that?
    Thanks for the help.

    Here is the sample code to do this using KeyListener. This is crude way but is an easy way for newbie's. Using documents is more sophisticated way.
    <code>
    public class LimitedCharsTest extends JFrame {
    private JTextArea limitedCharTextArea = new JTextArea();
    public static final int MAX_CHARS = 10;
    public LimitedCharsTest() {
    JScrollPane scrollPane = new JScrollPane(limitedCharTextArea);
    this.getContentPane().add(scrollPane);
    this.setSize(200,200);
    limitedCharTextArea.addKeyListener(new TextAreaKeyListener());
    this.setVisible(true);
    public static void main(String[] args) {
    LimitedCharsTest limitedCharsTest1 = new LimitedCharsTest();
    private class TextAreaKeyListener extends KeyAdapter {
    public void keyTyped(KeyEvent ke) {
    String taContent = limitedCharTextArea.getText();
    if(taContent != null && taContent.length() >= MAX_CHARS)
    ke.consume();
    </code>

  • Maintain separate line item for discount-Urgent response will be appreciate

    Hi SD Gurus,
    I need to apply a separate credit line item on a invoice to reduce the net amount billed against that invoice.The scenarios is Engineer-To-Order.The billing document is order relevant only.So pls help me on this.whether I have to create new material for discount or what can i do ?
    Thanks
    Hari Challa.

    Hi,
    Can you explain the scenario with a suitable example ?
    Regards,
    Amrish Purohit

  • FBL1N - Limit display line itens for some vendors

    Hi All,
    I have a request from business to limit the access for some vendors in FBL1N.
    The idea is to limit the users to do not see the line itens for some vendors.
    Is there some standard configuration? Any suggestion?

    Ricardo,
    My suggestion is to involve a Basis person for this. You need to check the authorization object attached to Vendor line item display transaction FBL1N.
    Then explain to the Basis person the conditions in which certain line items should not be displayed. I am sure this exercise would be of help.
    Regards,
    Vishal.

  • Price limit for material -- very urgent requirement

    hi gurus,
    i m facing a prob., actually we want to assign a certain amount for a material and we ask our users to procure that material from any vendor, But they can not exceed that limit which we had defined  while creating the info-record and Purchase order.
    how could i do that.
    useful answer will be awarded..
    please reply soon.. its very very urgent.
    Thanks:
    piyush singh

    hi gurus,
    I m telling you my problem in more clear way:
    while creating a PO the value get updated from info-record, this value should be under certain limit so that the End-user can not exceed the material price after a certain limit in PO.
    if the End-user changes the info-record or creat the info-record with price exceeding that limit ,the syatem will pop-up a message and can't allow the end-user to save, and even if they get it saved.. then the system will not allow end-user to save the PO with that exceeding price.
    the scenario is as follows:
    we fixed a price limit some-where for material Xand ask our end-user that you can buy the material X
    from any of the vendors. they whether then go to creat new info-record or change the existing info-record.
    THEN,
    the system can only save or change the price in info-record under the defined limit, if exceeding the system will not get saved the info-record.
    OR
    If he succedeed to save the info-record with the exceeded value, Then this changed price will get pop-up while creating PO , but if the value of the PO foe material X exceed the limit which we had defined for that material X the system can't save the PO.
    Where will i set this Limit for Material X.
    Thanks:
    Piyush Singh

  • Is there a count limit for the AP invoice distribution line?

    Dear All,
    I'm tring to load a invoice file from a legacy system to oracle. Is there a count limit for the AP invoice distribution line?
    Thanks & Warm Regards!
    Jerome

    Hi Jerome,
    Which version of oracle apps you are working on?
    --Manpreet                                                                                                                                                                                   

  • I want to set dynamic customer credit limit for a customer

    Hi,
    I want to set a dynamic credit limit for a customer which should trigger during the time of Sales Order Creation.
    Can anyone please let me know the settings one has to do to implement this process in the system ?

    Hi Below is the whole process for confign.
    1. Transaction OB38
       Check which credit control area is assigned to the company code.
       Company code:
       Credit control area:
    2. Transaction OVFL
       Check which credit control area is assigned to the sales area.
       Sales area:
       Credit control area:
    3. Transaction XD02 or VD02
       Check which credit control area is assigned to the payer.
       Payer:
       Credit control area:
    4. Transaction SE37
       Is user exit EXIT_SAPV45K_001 being used?
    5. Transaction OBZK
       For the settings under items 2 - 4, field "All company codes" must be marked in Transaction
       OB45, or the credit control area must be entered under the relevant company code in table
       T001CM of the credit control areas allowed.
       Company code:
       Credit control areas allowed:
    6. Settings for the credit checks
    7. Transaction OVAK
       Which settings do exist for the sales document type used?
       Sales document:
       Check credit:
       Credit group:
    8. Transaction OVAD
       Which settings do exist for the delivery type used?
       Delivery type:
       Credit group for delivery:
       Credit group for goods issue:
    9. Transaction OB01
       Credit management/Change risk category
       Definition of the risk category for each credit control area. This risk category can be
       assigned to a credit account by using Transaction FD32.
    10. Transaction OVA8
        Here, the individual credit checks for key fields
        o credit control area
        o risk category
        o credit group are set. Take these key fields from the above settings and go to the detail
          screen. In particular, check whether fields "Reaction" and "Status/block" are set
          correctly. To carry out follow-up actions in case of a credit block, the credit check
          status must be set (field "Status/block").
    11. Transaction FD32
        Credit master data for the payer of the relevant document.
        Credit account:
        Credit limit:
        Risk category:
        Currency:
    12. Settings for updating the credit values Update of the credit values is required for the limit
        check (static or dynamic credit limit check).
    13. Transaction OVA7
        Update of the credit value is active for the corresponding item type if the check box is marked. This field corresponds to 
        field "Active receivable" in Transaction VOV7.
        Item type: 
        Active receivable:
    14. Transaction V/08, Pricing
        In the pricing procedure used for pricing, subtotal "A" must be entered in a line for
        determining the credit value (mark the pricing procedure and doubleclick on "Control").
        Usually, the net value plus taxes is used. This way the system is determined to use this
        subtotal for credit pricing. The credit price is stored in field VBAP-CMPRE and used for
        update and credit check.
        You can find the used pricing procedure of the order under "Item -> Condition -> Analysis".
        Pricing procedure:
        Line with subtotal = 'A':
    15. Transaction OB45
        Which update group (field "Update") do you use in the relevant credit control area? The
        default setting is "12". If you use another update group, check whether this is fine with
        you. If you open an OSS message, please tell us the alternative update group.
        Credit control area:
        Update:
    16. Transaction OMO1
        Which kind of update did you choose for structure S066? 
         In any case, "Synchronous update (1)" has to be chosen as the kind of update. 
         All other settings will lead to errors.
    Regds
    MM

  • Why am I getting a "Adobe Creative Cloud Membership has reached its limit for hosted sites" message?

    I just tried to push my FIRST "free" Creative Cloud site live and got the message "Your Adobe Creative Cloud Membership has reached its limit for hosted sites. To push this site live you will need to purchase an additional hosting plan." I thought CC membership was supposed to give you 5 free hosted web basics sites?
    I am a premium BC partner and so far have my partner site and a paid Webcommerce site . In addition to the site I'm trying to put live I have 2 other trial sites (think they are designated as WebMarketing sites) of which one is expired. So where does the limit come in as this is so far my only WebBasics site?
    Please help as I need this live urgently (without additional expense).

    Hi Judy
    Appologies for this un-answered post, if any related issue is still active please reach out to our support directly.

  • Finding the end of a line in a JTextArea and inserting a comma

    Hi,
    At the moment I am reading in a comma delimited file into a JTextArea.
    This part is ok I can see the file in the window correctly.
    The problem that I am having now is that I want to add a comma to the end of each line in the JTextArea.
    Does anyone know how to do this?
    Thank you

    Well you have to get the String value of the JTextField.
    String text = YourJTextField.getText()
    Then you have to make a loop and check each single character if it equals '\n', that means "RETURN" or "NEW LINE".
    That is the direction I would go. Inform yourself about String manipulations first, like how to look for character, how to compare them and how to add them.

  • Tolerance limit for invoice

    Hi all,
    We have a requirement where we need to put tolerance limit for invoice both at the line item level and header level of the invoice. Also both % and absolute tolerance limits.i.e. if the invoice is 25 EUR or 3% more than the suggested price, it should be blocked. It is true both at line item and header level independently.
    I tried in test systems and at line item level, we could achieve it thru configuring PP tolerance key.
    Also at the header level, BD helps in achieving the Absolute tolerance.
    But how can we configure at header level, % value of tolerance limit?
    Appreciate the help.
    Thanks,

    I don't think there will be separate tolerance limit for header level in invoicing, it will not allow you to post with diff values in item and header.
    Just check and let me know, if this wrong.
    Regards
    TGB

  • Size limit for Word documents?

    I have used a Palm Tungsten T3 before a Nokia. With the Nokia E90 I was faced with a problem that E90 was not able to open our pricelist file. Is there a maximum size for files that Nokia E90 can handle?

    dear
    i dont think that there is size limit for word documents but plz check macro setting on ur pc
    Amit Chaudhari M. E. Civil Pune - Motorola (double line Display) - Samsung X-600 (Flap) - 3315 - Sony J5 - 2850 - 2100 - 3100 - Samsung C 100 - Moto C350 - Moto C650 - Moto E 365 - 3220 - 1100- Palm Treo PDA (B&W) - 6681Silver - Moto C650 - 2865 - Samsung Ultraslim V9 - 6681 Black - Spice D88 (Dual Sim) - Samsung D900i - Samsung E250 - E50 - E51
    CDMA - Moto Basic - 2112 - Samsung Hero - Telson TWC 1150 (Watch Mobile)

  • Help to overcome 32K XML limit for Anychart  Map

    Hello,
    Apex version 4.2.0.00.27
    I am creating a heat map using the Anychart maps and have chosen to use the "Use custom XML" option in the Map Attributes to control the map being generated. However, I have hit a 32K limit for 'Custom XML' that is being passed to the Map.
    A sample of the XML is:
    <?xml version="1.0" encoding="UTF-8"?>
    <anychart>
    <charts>
    <chart plot_type="Map">
    <b>&P_MAPXML.</b>
    <palettes>
    </palettes>
    </chart>
    </charts>
    </anychart>
    I am using a procedure to generate the required XML and have created an Application Item (P_MAPXML) to hold the data. When P_MAPXML along with the enclosing XML is less than 32K then map dispalys correctly. If the XML generated is more than 32K then an error occurs as it truncates P_MAPXML and the Custom XML is no longer well formed.
    There is a workaound via an old thread AnyChart gantt with custom xml and more then 32k but I was wondering is there a more upto date solution.
    Edited by: user11899724 on 15-Apr-2013 04:45

    Thanks Hiliary,
    I soldiered on before I saw your reply.
    I basically wanted an example of the minimum necessary to display an Anychart Map via the javascript method as there seemed to be issues with the examples that were on the forums not least assuming that every step was understood.
    Anyway below I have put steps together just to display an Anychart Map and then along with your example above or the others from the Forum it can be customized to display dynamic data.
    1. Create a new page within Apex
    i) Under Application choose Create Page -> Blank Page -> Page Alias - (type: WorldMap) -> Name (type: World Map) -> ->Finish
    2) Click Edit Page
    3) Right Click on Region , Choose Create -> Click PL/Sql Dynamic Content ->Title (type: World Map) ->
    Under Pl/SQL Source cut and paste the following:
    <pre>
    htp.prn('<textarea cols="500" rows="100" id="rowData" style="display:none">');
    htp.prn('<anychart>
    <charts>
    <chart plot_type="Map">
    <chart_settings>
    <title enabled="true"><text>World Map</text></title>
    <chart_background enabled="false"/>
    <data_plot_background enabled="false"/>               
    </chart_settings>
    <data_plot_settings>
    <map_series source="world/world.amap">
    <projection type="Mercator" centroid_x="10.4515266418457" centroid_y="51.1656913757324"/>
    <undefined_map_region>
         <tooltip_settings enabled="true">
                   <format>{%REGION_NAME}</format>
              </tooltip_settings>          
              <label_settings enabled="true">
                   <format>{%REGION_NAME}</format>
              </label_settings>          
         </undefined_map_region>
         </map_series>
    </data_plot_settings>                    
    <data>
    </data>
    </chart>
    </charts>
    </anychart>');
    htp.prn('</textarea>');
    -- Line below seems to be coming out blank, should be:"<!-- htp.prn('<div id="chartMap"></div>'); " -->
    htp.prn('<div id="chartMap"></div>');
    htp.prn('<script type="text/javascript" language="javascript" src="/i/flashchart/js/AnyChart.js"></script>
    <script type="text/javascript" language="javascript">
    AnyChart.swfFile = ''/i/flashchart/swf/AnyChart.swf'';
    var chart = new AnyChart();
    chart.width = "800";
    chart.height = "400";
    var data = document.getElementById("rowData").value.toString();
    chart.setData(data);
    chart.write("chartMap");
    // alert(data);
    </script>');
    </pre>
    Click Create Region
    4) Run the Page.
    If all is well it shoulld display the World Map, just be careful with the div tag line as that will need to added manually.
    As said previously, there's lots of help on the forums about creating the dynamic content but this should be a good place to start, having a map that will display using that method.

  • Getting the visible lines from a JTextArea

    I'm using a JTextArea with a fixed size. I've used the setLineWrap(true) and setWrapStyleWord(true) methods on this JTextArea, so when the user types in some text longer than the visible width, it will wrap into the next line. I need to get each visible line from the JTextArea to create a String array of text lines.
    I mean visible text lines (lines visibly separated in the JTextArea), not real text lines separated by a line break character as "\n".
    How can I do this?

    This information is supposed to be contained in the View information of the component. But as far as I can tell it doesn't work for a JTextArea.
    So if you can use a JTextPane then check out the "getWrappedLines" method in this posting:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=608220
    Basically, a View exists for each line in the Document and then each line may have multiple views if the line needs to wrap. So the basic code just count the number of views within each line but you can change the code to get each view separately. Once you have each view you can get the start and end of the text from the document that this View represents.
    Or if you need to use a JTextArea then you can calculate the starting offset of each each line with respect to the model. You can use the viewToModel(..) method to get the starting offset of each line. We know that each line in a text area is a fixed height, so the starting offset of the first line would be modelToView(0, 0); If the line height is 16, then the starting offset of the second line would be modelToView(0, 16), etc. Once you know the starting offset of each line you can subString out the text for each line.

  • Maximum no of Line items for sales order,delivery document and billing docu

    Dear friends,
    How many line items we can enter for the following,
    1) a Sales order
    2) a Delivery document
    3) a Billing Document
    Thanks in advance.
    Regards,
    Shrikant

    Hello,
    the maximum limit of line items are as follows
    order-9999
    for delivery and invocie , it is restricted to 999 accouitng line items. since the tranfer to accounting can handle only 999 items , the restriction on delivery and invocie
    ex if there are excise postings, for a single line , there might be 5/6 lines genetrated for each line in invocie , therfore as per this the line in invocie get restricted
    you have a sap note , which offers suggestions to partially over come this
    hope this helps
    Thanks
    akasha

  • The administrative limit for this request was exceeded.

    Hi,
    Am getting below error while adding machine to domain
    C:\>netdom join W2K12R2-DC-161  /domain:winvm.com /userd:Administrator /passwordd:cvm@123 /REBOOT 
    The administrative limit for this request was exceeded.
    The command failed to complete successfully.
    Even while trying to delete  some entries from registry gives below error
    ADSIEdit
    Operation failed. Error code: 0x2024
    The administrative limit for this request was exceeded.
    00002024: SvcErr: DSID-0215030C, problem 5008 (ADMIN_LIMIT_EXCEEDED), data -1069
    OK   
    Please help me urgently
    I have searched on below links but could not get the correct workaround steps
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/83087f21-ba51-414d-9202-badea56ba83b/administrative-limit-was-exceeded
    https://social.technet.microsoft.com/Forums/en-US/fea67c92-8dab-4711-8579-baaee4bca3f7/the-administrative-limit-for-this-request-was-exceeded?forum=identitylifecyclemanager
    Nilesh Savant

    Hi Nilesh,
    Before going further, are we using domain admin account to use netdom and adsiedit.msc? Whether it is true or not, please try another admin account to check if the issue persists. Besides, to use netdom, we must run the
    netdom command from an elevated command prompt. If the issue persists, please try to join the machine to the domain from the machine itself to see if it can be successful.
    Best regards,
    Frank Shen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

Maybe you are looking for

  • How to use two ipads with icloud on one computer

    Can you use two iPads on one computer with  iCloud so that they are still separate?

  • Mini displayport it's compatible with thunderbolt?

    Hey people, please help with this little problem

  • Character Level Authorization

    HI All, I am giving authorization to a user for a particularly country data which is for example India.Other countries are US,UK. I want to give authorization only India related data to the user. Maintained the authorization variable for my country I

  • Restrict Frames display in report

    Hi all, I am using 10g 10.1.2 dev suit. I have a report with 6 frames (6 queries) each page is on different page. The parameter is customer no... some time only 1 frame is populated and other 5 pages printed without any data. I want to restrict this

  • Toplink QueryException with a constructor expression

    Hello together, I have a Spring 2.5 web application with JPA and JSF running on Glassfish and a PostgreSql database. Everything is running perfect on localhost but on an other machine, on enterprise Glassfish Server I'm getting the following error: j