JTextArea & Counter of line

I have to build a JTextArea with a LineCounter.
How do I do ?

Don't [url http://forum.java.sun.com/thread.jsp?forum=57&thread=512263]crosspost.

Similar Messages

  • How to count Command-Line Arguments ?

    How do you count Command-Line Arguments ?
    For example,
    java program argument1 arguement2
    I would like to be able to count how many arguements the user inputed
    It should result as 2 for the bold line above
    Thank you for your help

    public static void main(String[] args) {
        int numArgs = args.length; // args holds argument1 and argument2
    }

  • HasMoreTokens detecting and counting empty line

    Hi programmers!
    how can i count empty line in a text file which has the data?
    suppose the text file with data is as follows:
    =====================
    c 500
    c 2100
    // <== empty line
    p 550
    c 5950
    c 3000
    =====================
    I want to display "Invalid record" when that empty line comes
    I tried following to execute "IO.print("Invalid record") line
    if(str.equals(" "))  / / also/  if (str.nextToken == false) /also / if (string.hasMoreTokens())
                   IO.print("Invalid record");
             }

    If (line.equals(""))
    or
    if (line.trim().length() == 0)

  • Custom code - count of lines

    Hi,
    How can I obtain the count of lines of code in all the custom objects such as z programs, z functions, z methods, user exits etc?
    THank you,
    Mike

    check fm RPY_FUNCTIONMODULE_READ
    Check how it reads the source code and returns it.
    Use a describe statement to the return table
    or try this syntax
    itab must hold a field of char72.
    READ REPORT 'Y123'  INTO ITAB.
    lines_r = lines( itab ).
    also check in se37 for rpy*
    Also check the f1 for read report, there are many other options

  • How to Count schedule lines in IDoc ORDERS05 using XSLT Mapping

    Hi Experts,
    In a Scenario where we are sending Purchase order (ORDERS05) to SAP SNC using XSLT Mapping,
    where in we need to count the no. of schedule lines against the Purchase Order line.
    As in Schedule line segment there is no such provision, so it needs to be handle in XSLT mapping to count the schedule lines.
    Can you all please guide me how to go about the same.
    Regards,
    Nitin P

    Hi Satish,
    Thank you very much for the reply,
    as there is only Quantity and other information is maintained against schedule lines how we can count the schedule line repeatation against PO line ? Is that very simple as you suggested or some other consideration also needs to be taken.
    Please clarify the same and let me also know if there are some standard documents also for the same.
    Regards,
    Nitin P

  • Pls Help about counting the lines of the file in java

    private int GrepPBArequestLog(String STRexpression) throws IOException
    int totalnum = 0;
    try {
    String[] cmd = {"grep", "-ic", STRexpression, src};
    System.out.println("grep, cmd " STRexpression" "+src);
    Process grepProc = Runtime.getRuntime().exec(cmd);
    String line = "";
    BufferedReader br = new BufferedReader(new InputStreamReader(grepProc.getInputStream()));
    line = br.readLine();
    System.out.println("read: "+line);
    while (line != null)
    System.out.println("Line: "+line);
    line = line.substring(line.indexOf(":") + 1, line.length());
    System.out.println("Substring: "+line);
    try
    int temp = Integer.parseInt(line);
    totalnum = totalnum + temp;
    catch(NumberFormatException e)
    System.out.println("String: "+line);
    System.out.println("NumberFormatException Occured"+e.getMessage());
    }//end while
    the output is:
    service No: 209
    Wapdate: 07/Jul/2003
    Went inside: GrepPBArequestLog
    grep cmd .*07/Jul/2003.*GET.*209.* /var/log/httpd/access_log*
    Line:
    read: null
    totalnum: 0
    wap 07/Jul/2003:
    wap 209:
    total hits 209: 0
    +++++++++++++++++++++++++++++++++
    the read: should not be null because there is a number of lines and
    totalnum shouldn't be 0.

    You don't want to simply:
    import java.io.*;
    public class CountEm {
      private static BufferedReader br;
      private static int count;
      private static String fileName, record;
      public static void main(String[] argv) {
        switch(argv.length) {
          case 1:  { fileName = argv[0]; break; }
          default: { System.out.println("Usage: java CountEm [filename]"); System.exit(-1); }
        try { countEm(); }
        catch(IOException ioe) { System.out.println("ERROR doing countEm()\n"+ioe); }
        finally { System.out.println("Count: "+count); }
      public static void countEm()  throws IOException {
        br = new BufferedReader(new FileReader(fileName));
        while ( ( record = br.readLine() ) != null ) { count++; }
    }~Bill

  • How to increment counter for line items.

    Hi,
    Please see the code below:
    LOOP AT T_MAT INTO W_MAT.
              perform bdc_dynpro      using 'SAPMM07M' '0421'.
              perform bdc_field       using 'BDC_CURSOR'
                                            'MSEG-ERFMG(i)'.
              perform bdc_field       using 'BDC_OKCODE'
                                            '/00'.
              perform bdc_field       using 'MSEG-MATNR(i)'
                                            W_MAT-MATNR.
              perform bdc_field       using 'MSEG-ERFMG(i)'
                                            W_MAT-ERFMG.
              i = i+1.
          ENDLOOP.
    In the above code I'm updating the line items thru BDC. Here I'm having a counter ' i '. I'm incrementing it for every loop cycle. When I run the BDC I get the error "Field MSEG-ERFMG does not exist in the screen"
    Please help.
    regards,
    Sriram

    Hi Sriram,
    you code as to be changed slightly:
    DATA l_counter(2) TYPE n.
    DATA l_fieldname  TYPE string.
    loop at t_mat into w_mat.
      MOVE i TO counter.
      CONCATENATE 'MSEG-ERFMG('  counter  ')'  INTO l_fieldname.
      PERFORM bdc_field USING 'BDC_CURSOR'
                              l_fieldname.
      i = i+1.
    ENDLOOP.data l_counter(2) type n.
    Regards
    REA
    Edited by: Ramy EL-ARNAOUTY on Jul 28, 2009 10:29 AM

  • Counting Requirement (Counting PO line items wrt PO No)

    Hi All,
    We have a requirement here . Suppose there are 2 Purchase orders Y & Z . "Y" purchase order has  5 line items as 10,20,30,40,50 . "Z" purchase order has 7 line items as 10,20,30,40,50,60,70 . now i want to count the number of purchase orders & no of line items . I.e output should be , for a particular month there are 2 purchase orders & 12 line items .
    Point will be awarded .
    Thanks,
    Deadlocks

    Hi Priya,
    thnx for the reply, just a small thing i wanted to ask,
    inside those two CKFs should i create a formula variable on PO header & PO item no ?
    Before this what i did was i created a CKF with constant 1 in it and then i applied exception aggregation as "total" and refrence characteristic as "PO header" & and "PO item".
    so instead of bringing item count as 12 it is bring 7 .
    Regards,
    Deadlocks

  • Record Count of Lines in the Reciever Txt file

    Hi,
    I am Working with File to Idoc Scenarion. Where I have field "Record Count in the reciever. Where the total number of lines in the reciever file has to mapped with the field and the file to be recieved to the destination.
    eg:Each Idoc that we receive, 2 lines are written out, one starts with BATHDR, the other is SECPTY.
    There is also then 1 extra line, the header line.  I looked at a bunch of iFiles,  and it seems to be if we knew the total  # of idocs for a given payment run, the total # of lines we would output is:
         ( ( #ofIDOCS * 2) + 1).
    With this observation can you advise on the action to be taken for the out put.
    Thanks ,
    Manoj

    Hi,
    I am Working with Idoc to File Scenarion. Where I have field "Record Count in the reciever. Where the total number of lines in the reciever file has to mapped with the field and the file to be recieved to the destination.
    eg:Each Idoc that we receive, 2 lines are written out, one starts with BATHDR, the other is SECPTY.
    There is also then 1 extra line, the header line. I looked at a bunch of iFiles, and it seems to be if we knew the total # of idocs for a given payment run, the total # of lines we would output is:
    ( ( #ofIDOCS * 2) + 1).
    With this observation can you advise on the action to be taken for the out put.
    Thanks ,
    Manoj

  • Group by and count of line items

    Hi
    I have a requirement to implement group by part # and count of the line items
    I was able to do group by at the node level and how to do the count
    Thanks
    New BIP

    Hi Alex
    sorry did not check until now glad some one came out to help me
    Can i send you the template, xml and output to your email please
    Thanks
    NewBIP

  • Counting words, lines and char

    i want a program which counts the number of lines,words and characters in a file.....................
    please help me

    One thread is enough.Continue there, please.
    [http://forums.sun.com/thread.jspa?threadID=5367866]
    I'm locking this one.

  • Disconnect counter output line

    Hello,
    I have a question that has been bothering me for awhile.  I'm using an M-series DAQ card which allows the ctr0 output to be placed on any PFI line.  Is there any way to disconnect the ctr0 output from all the PFI lines?  I'm only using the ctr0InternalOutput and I don't want it routed to an external pin.
    The reason I ask is because the ctr0InternalOutput was being used as timing for several acquisitions, but the output was also appearing on it's default output pin.  However, this DIO/PFI line was being used as a digital output for relay control and every time the counter was used, the relay would switch.  I "fixed" it by routing the counter output to an unused PFI line, but I would like it not to appear externally at all.
    Thank you for your help,
    Jon

    Thanks, I will give that a try.  Seems so obvious now...
    Jon

  • Read Counter/Position Line or Volume Counter

    I have the iPod Nano 4 GB.
    Serial # YM538AJCTK3
    It used to show the read counter or position line that shows at which point on the song/podcast I'm on; or the.
    Now, it's not showing it. Instead it's showing 5 small circles that doesn't indicate the position of the song/podcast nor the volume counter.
    I can't seem to change this setting back.
    Please help.

    Sometimes, if you don't allow the screen to refresh before pressing another button, it gets stuck.
    See this for help.
    iPod "stuck" on the artwork or rating screen.
    As you will see, updating the software can cure this.

  • HOW TO COUNT BLANK LINES

    I wants to count number of blank lines in a java program using io package. Please give your logic or code.
    regards
    YOGESH

    I think this class will help you:
    http://www.cs.arizona.edu/people/reges/teachers/TextReader.html
    This class has methods to readLine(), which reads a line until it gets to a "\n" (end line character). If you want to do, what I thought you want to do, you could readLine(), which returns a string, then say
    String line = (input.readLine()).trim();
    if(line.equals(""))
    blankLines ++;
    Anyway, I hope this helps, and another thing that would probably help you too, is if I actually showed you where to get the TextReader class :-) , so... here is where to get it:
    http://www.cs.arizona.edu/people/reges/
    then just click on TextReader which will be on the frame to your left. From there you can download the source and use it.
    good luck

  • Where in the JTextArea code is line/word wrapping handled?

    Hi all--
    I was making a custom renderer using a JTextArea, and was looking in the source code for JTextArea trying to figure out how it determines when to break a line given it's width and the current font...but I can't find it anywhere. I can find this function:
    public void setLineWrap(boolean wrap) {
            boolean old = this.wrap;
            this.wrap = wrap;
            firePropertyChange("lineWrap", old, wrap);
        }but it appears to simply set a private boolean called "wrap" that isn't in its superclass JTextComponent. So one can only imagine that it must somehow calculate where to wrap its text. But this code is no where to be found in JTextArea. In fact, the only thing I can find is that it fires this "lineWrap" property change, but I cannot find in either JTextArea or JTextComponent where this event is handled to recalculate where to draw the string and when to wrap it to a new line.
    Mostly I'm just curious how it's done more than anything else. Anyone know where the missing code is to handle this?

    Yeah, this stuff gets pretty twisted. The main entry point is the getViewFactory() method in the RootView member class of BasicTextUI. (RootView is just what it sounds like: the root of whatever View hierarchy finally gets built.) It first tries to get a ViewFactory from the EditorKit, and if that doesn't work, it returns the enclosing BasicTextUI object. If the component being constructed is a JTextPane or JEditorPane, the EditorKit will be a StyledEditorKit or a subclass thereof, which will provide a ViewFactory that can vary with the kind of document being displayed/edited. But in the case of JTextArea, it will be a DefaultEditorKit, which returns null from its getViewFactory() method, meaning the BasicTextUI object is expected to serve as the ViewFactory. BasicTextUI provides only a dummy implementation of the ViewFactory interface, but its subclass, BasicTextAreaUI, implements create(Element) to return either a PlainView or a WrappedPlainView, depending on the relevant setting the the JTextArea.

Maybe you are looking for