Split Text by Rows.

Hello,
I want so split a text into single text fields, every row for a new text field. Is there a function to make this possible?

Tables - make a text box, insert a table - assign your rows there.

Similar Messages

  • Splitting text column into sections

    (Using Oracle 9i SQL)
    I need to be able to split text which may be from 0 to 2000 bytes into sections of no more than 10 characters and assign a sequence to each. As usual, example is the best way to illustrate.
    The following presents the "raw" data:
    with src as (
    select     'A100000'     part_no,
         'Short'          descr
    from     dual
    UNION ALL
    select 'A100001','two words' from dual
    UNION ALL
    select 'A100002','Should be two lines' from dual
    UNION ALL
    select 'A100003','This is going to be 3' from dual
    UNION ALL
    select 'A100004','Oneverylongword' from dual
    UNION ALL
    select 'A100005','Perfectfit' from dual
    UNION ALL
    select 'A100006','' from dual
    UNION ALL
    select 'A100007','A Perfectfit but 3 lines' from dual
    UNION ALL
    select 'A100008','Toolongforone' from dual
    UNION ALL
    select 'A100009','Toolongforone too' from dual
    select     part_no,
         descr
    from     src
    PART_NO DESCR
    A100000 Short
    A100001 two words
    A100002 Should be two lines
    A100003 This is going to be 3
    A100004 Oneverylongword
    A100005 Perfectfit
    A100006
    A100007 A Perfectfit but 3 lines
    A100008 Toolongforone
    A100009 Toolongforone too
    10 rows selected.What I want is this kind of thing:
    PART_NO DESCR                           SEQ TEXT
    A100000 Short                             1 Short
    A100001 two words                         1 two words
    A100002 Should be two lines               1 Should be
    A100002 Should be two lines               2 two lines
    A100003 This is going to be 3             1 This is
    A100003 This is going to be 3             2 going to
    A100003 This is going to be 3             3 be 3
    A100004 Oneverylongword                   1 Oneverylon
    A100004 Oneverylongword                   2 gword
    A100005 Perfectfit                        1 Perfectfit
    A100006                                   0
    A100007 A Perfectfit but 4 lines          1 A
    A100007 A Perfectfit but 4 lines          2 Perfectfit
    A100007 A Perfectfit but 4 lines          3 but 4
    A100007 A Perfectfit but 4 lines          4 ines
    A100008 Toolongforone                     1 Toolongfor
    A100008 Toolongforone                     2 one
    A100009 Toolongforone too                 1 Toolongfor
    A100009 Toolongforone too                 2 one too

    Thanks although there is a bug when the text is too big:
    with src as (
    select     'Alen0000'     id,
         'Short'          str
    from     dual
    UNION ALL
    select 'Alen0001','two words' from dual
    UNION ALL
    select 'Alen0002','Should be two lines' from dual
    UNION ALL
    select 'Alen0003','This is going to be 3' from dual
    UNION ALL
    select 'Alen0004','Oneverylongword' from dual
    UNION ALL
    select 'Alen0005','Perfectfit' from dual
    UNION ALL
    select 'Alen0006','' from dual
    UNION ALL
    select 'Alen0007','A Perfectfit but 3 lines' from dual
    UNION ALL
    select 'Alen0008','Toolongforone' from dual
    UNION ALL
    select 'Alen0009','Toolongforone too' from dual
    SELECT
         ID, STRING
    FROM
         (SELECT    
              ID, LEVEL level#,
              SUBSTR (str, INSTR (str, base, 1, LEVEL) + len,
                   INSTR (SUBSTR (str, INSTR (str, base, 1, LEVEL) + len, limit# + 1),
                        base, -1) -1) STRING,
            INSTR (str, base, 1, LEVEL) + len - 1 start#,
            INSTR (SUBSTR (str, INSTR (str, base, 1, LEVEL) + len, limit# + 1), base, -1)
                   + INSTR (str, base, 1, LEVEL) + len - 1 end#
         FROM
              (SELECT
                   ROWNUM ID, ' ' base, ' ' || str || ' ' str, LENGTH (' ') len, 10 limit#
              FROM src
         CONNECT BY LEVEL <= (length (str) - length (REPLACE (str, base))) / len - 1
    START WITH start# = 1
    CONNECT BY PRIOR end# = start# and prior ID=ID
      GROUP BY ID, level#, STRING
    /ERROR at line 4:
    ORA-01436: CONNECT BY loop in user data
    yet is I change limit from 10 to 15 it is OK

  • Alv output splitting into two rows when converting into excel sheet.

    Hi frends,
    I have alv report with 60 fields . The report output is coming currently .  But when i am exporting into excel sheet from the option local file--> speadsheet  each row is splitting into two rows including header in excel sheet.
    Please provide your valuable suggestions to avoid this.
    Regards,
    Ramu .
    Edited by: Ramu.K on Sep 8, 2009 5:59 PM

    Hi,
    Please use the grid option and with the Spreadsheet button (CntrShiftF7). Do  "Save as" and save it as excel. It should work.
    Regards,
    Pradyumna

  • Text in Rows - Report Painter

    Hi Gurus,
    I´m making a FI report using report painter tool. I´ve a issue with text in rows. In this report, I´ve to show all values when Trading Partner is filling and when is empty.
    I´ve created a set of Trading Partner values, but in this i can´t enter blank values and therefore if I use on report this set, I can´t see values when Trading Parnter is empty. In this case I´ve been seeing Trading Partner text.
    By other hand, if I deselect this set and I select to see all Trading Partner values, including Trading Partner empty values, I can´t see Trading Partner text. For example: If my Trading Partner is XX and my Text YY, in my rows I should be:
    XX   YY
    But in my report I´m saying
    XX   XX
    And I can´t see text of Trading Parnter characteristic.
    Any of you know how can I obtain text in report painter rows?
    Kr

    Never heard of this. Particularly interesting is that this happens after a few days? Weird. But let's trow SP1 at this and see:
    https://smpdl.sap-ag.de/~sapidp/012002523100006007872008E/crvs05sp1.exe
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup

  • Splitting text file

    I have the below clas for splitting text files, but I am getting an error. Could someone please help? Thanks
    public void splitFile(String file) {
              try {
                   BufferedReader in = new BufferedReader(new FileReader(file));
                   final int numOutputFiles = constants.getNUM_PRINTERS();
                   int loopCounter=0;
                   Object currentOutputFile = null;
                   String sourceFile = in.readLine();
                   PrintWriter out0 = new PrintWriter(new FileOutputStream(constants.getPRINTER1_FILENAME()));
                   PrintWriter out1 = new PrintWriter(new FileOutputStream(constants.getPRINTER2_FILENAME()));
                   PrintWriter out2 = new PrintWriter(new FileOutputStream(constants.getPRINTER3_FILENAME()));
                   PrintWriter [] fileHandles = {out0, out1, out2};
                   while (sourceFile != null) {
                        loopCounter++;
                        if (loopCounter == numOutputFiles) {
                             loopCounter=1;
                        ERROR-->currentOutputFile = fileHandles[loopCounter-1].println(sourceFile); <--ERROR
                        //currentOutputFile.write(sourceFile);          
                   out0.close();
                   out1.close();
                   out2.close();
              } catch (Exception ex) {
                   logger.error(EXCEPTION_MESSAGE,"Error splitting file: "+ex.getMessage());
                   ex.printStackTrace();
         }The error I get is on the line above in bold, "Type mismatch: cannot convert to void from Object" .
    Thanks!!

    also, how can I get the PrintWriter file names to be dynamic instead of declaring 3 of them like I have it now? Lets say I need 5 files now, but in the future, I may need 2 files. So the "out" variable would have the out1 and out2 only.

  • Format result-set of join (split parent/child rows)

    Hi,
    I have the need to do a simple join however instead of returning all the columns from both the joined tables in 1 row, we need to have them split into multiple rows (i.e. parent record info on 1 row and child record info on the next)
    e.g. If we have the following data:
    table_1
    id    parent_id
    101    null
    102    null
    103    null
    104    101
    105    101
    106    102
    I need the data as follows:
    id    parent_id    record_type
    101    null        'parent'
    104    101        'child'
    105    101        'child'
    102    null        'parent'
    106    102        'child'
    (note: since 103 did not have any children, it was not returned (as expected & as desired) - also, dont worry about order of results for now)
    This can be achieved this by using the following:
    ;with temp
    as
    select [id],parent_id,[header_1],'parent' as type
    from table1
    temp2 as
    select [id],parent_id,[header_1],'child' as type
    from table1
    select distinct A.*
    from temp A
    join temp2 B on B.parent_id = A.id
    union
    select distinct B.*
    from temp A
    join temp2 B on B.parent_id = A.id
    However, is there any better/more efficient way to get this?
    Appreciate any help on this.

    For future reference, I'll point out that you ask 2 very different questions.  When you ask about "better", you need to define how you measure that quality.  "Better", like "pretty", has no universal measure.  
    Next, you ask about "more efficient".  Well, your example is very simplistic - perhaps to the point of being unreasonably so.  You measure efficiency by examining the query plan - and that requires an actual populated table, with indexes,
    constraints, and data that accurately reflects your data  in both size and distribution of values. If you simplify things too much, you may find that your attempts to improve things lead you down the wrong path.  
    Also, be careful what you assume about your data.  You have conveniently created a set of rows that have a rather natural order.  If you care about the order of your resultset - and generally someone somewhere does - then you need to develop a
    solution that works for all situations and does not implicitly rely on assumptions.  And that requires that you put some thought into choosing your sample/test data.  With that said, below is yet another alternative:
    if object_id('table_1') is not null
    drop table table_1;
    go
    create table table_1 (id int not null constraint pkx primary key, parent_id int null);
    alter table table_1 add constraint fkx foreign key (parent_id) references table_1 (id);
    go
    insert table_1(id, parent_id)
    values (101, null), (102, null), (103, null), (104, 101), (105, 101), (106, 102), (5, 102);
    with cte as (select * from table_1 as src
    where parent_id is not null or
    (parent_id is null and exists (select * from table_1 as chld where chld.parent_id = src.id)))
    select *, case when parent_id is null then 'parent' else 'child' end as record_type from cte
    order by isnull(parent_id, id), case when parent_id is null then 0 else 1 end, id;
    go
    Notice the additional row of data I added where id = 5.   I will also add that you should use "union all" and not "union".  There is no need to force the engine to do work that is not needed.   

  • No CATS record exists for the long text in row 4

    Hi,
    When we are tyring to upload the time sheets of tha employees in se38 usinga  customized program, from Non sap to sap,  for a few employees we are getting an erro like No CATS record exists for the long text in row 4,  where are we supposed to verifiy, what causes this error.
    Please assist.
    Thanks,
    Shilpa.

    Your first step should be in your input file.  What is on the fourth line?
    Look into the Blueprint Specifications of your Custom Program for the parameters of that input file.

  • Split up multiple row payload

    Hi guys,
    I have the following problem and I am in serious need for some help.
    I use JDeveloper 11g and is building a SOA Composite application. The composite uses AQ and I dequeue a message with the following structure:
    <payload>
    "Test", "Test_2", "20120101", 0
    "Test", "Test_3", "20120102", 0
    "Test", "Test_4", "20120103", 0
    </payload
    I.e. every row is comma separated and it could be multiple (n) rows in the payload.
    What I want to do with this data is send it to a web service. The trick is that the web service need the separetead values and one row should be send each iteration of the loop.
    I.e. the web service want "Test" "Test_2" "20120101" 0 as separate objects on the first iteration and then the next row etc.
    My problem is that I do not know how to both loop and split the objects in BPEL (or I do not know how to do any of them).
    I would really appreciate some good help, if you suggest any kind of xslt mapping solution - please explain "for dummies" :)

    I dont quite understand what you mean by the web service not accepting the request.
    I will try to illustrate with an example:
    Lets say that the web service that I want to access is http://www.webservicex.net/stockquote.asmx?op=GetQuote. That service only takes one parameter which is the symbol.
    Then, lets say that the payload I receive is
    <payload>
    "GOOG"
    "BAC"
    "G"
    </payload>
    I cant send the whole payload at once, hence I need to
    1) select the first row
    2) send that message
    loop back
    3) select the second row
    4) send that message
    etc..
    The concept of the above example is what I want to do. (But in my case I have more than one object on each line.) So I would like to know how to single out the objects and send them to the web service and then loop back and do it all again.
    Also, for that transform operation. Does that mean that I basically can connect my payload object to that transformation or how is it done?
    Edit:
    I tried the xsl transformation without success, for some reason I was not able to get to the content of the payload node. Howver, for a more realistic example - this is the object that I will receive:
    <?xml version="1.0" encoding="UTF-8" ?>
    <?xml-stylesheet type="text/xsl" href="carrierobjectschema.xsl"?> <OBJ_CARRIER_OBJECT>
    <SYSTEM xmlns="">xxx</SYSTEM>
    <INTERFACENAME xmlns="">yyy</INTERFACENAME>
    <INTERFACEOPERATION xmlns="">zzz</INTERFACEOPERATION>
    <INTERFACEVERSION xmlns="">1</INTERFACEVERSION>
    <PAYLOAD>"111", "222", "333", 0
    "112", "223", "334", 0</PAYLOAD>
    </OBJ_CARRIER_OBJECT>
    And the result I would like (or something similar) is: Note that I am only interested in the payload node.
    <obj>
    <1>111</1>
    <2>222</2>
    <3>333</3>
    <4>0</4>
    </obj>
    <obj>
    <1>112</1>
    <2>223</2>
    <3>334</3>
    <4>0</4>
    </obj>
    Edited by: 964338 on Oct 10, 2012 5:28 AM
    Edited by: 964338 on Oct 10, 2012 5:32 AM

  • Custom report region (Conditionaly Split over two rows)

    I have a request, to take an existing report that displays data like this:
    Pool Performing vs
    Non-Performing Current Balance Low Value High Value Value Cumulative Cumulative
    WA Low WA High Loss Low Loss High
    AA Performing $XXX,XXX,XXX $XXX,XXX,XXX $XXX,XXX,XXX XX.XX% XX.XX% XX.XX% XX.XX%
    Non-Performing $XXX,XXX,XXX $XXX,XXX,XXX $XXX,XXX,XXX XX.XX% XX.XX% XX.XX% XX.XX%
    Sub-Total $XXX,XXX,XXX $XXX,XXX,XXX $XXX,XXX,XXX XX.XX% XX.XX% XX.XX% XX.XX%
    and to have it instead display like this:
    AA
    Performing $XXX,XXX,XXX $XXX,XXX,XXX $XXX,XXX,XXX XX.XX% XX.XX% XX.XX% XX.XX%
    Non-Performing $XXX,XXX,XXX $XXX,XXX,XXX $XXX,XXX,XXX XX.XX% XX.XX% XX.XX% XX.XX%
    Sub-Total $XXX,XXX,XXX $XXX,XXX,XXX $XXX,XXX,XXX XX.XX% XX.XX% XX.XX% XX.XX%
    I tried building a custom Named Column (row template), but ran into the issue that ALL ROWS being offset, not just the ones with value for the Pool..
    Is it possible to make a conditional row template that will allow for a row to be split ONLY if there is a value in the column?
    Thank you,
    Tony Miller
    Dallas, TX

    TexasApexDeveloper wrote:
    Paul,
    SO glad to hear from you again.... Here is the query that I am using:
    SELECT ASET_CAT_POOL_FST_TXT Pool,
    DECODE(Display_Order, 0, ASET_PERF_STAT_TXT, 1, 'Sub-Total', 2, 'Grand Total') AS Perf_Non_Perf,
    DECODE(Display_Order, 0, 'Normal', 1, 'Bold', 2, 'Bold') AS Css_Tag,
    CurrBal,
    LowVal,
    HighVal,
    LowPercent,
    HighPercent,
    LossHighPercent,
    LossLowPercent,
    Display_Order
    FROM
    SELECT Grouping(ASET_CAT_POOL_FST_TXT) + Grouping(ASET_PERF_STAT_TXT) AS Display_Order
    , ASET_CAT_POOL_FST_TXT
    , ASET_PERF_STAT_TXT
    , Round(Sum(ASET_CUR_BAL_AMT), 2)  AS CurrBal
    , Round(Sum(ASET_LW_VAL_AMT),       2)  AS LowVal
    , Round(Sum(ASET_HIGH_VAL_AMT),      2)  AS HighVal
    , Round(100 * DECODE(Sum(ASET_CUR_BAL_AMT),0, 0, (Sum(ASET_LW_VAL_AMT) / Sum(ASET_CUR_BAL_AMT))), 2) AS LowPercent
    , Round(100 * DECODE(Sum(ASET_CUR_BAL_AMT),0, 0, (Sum(ASET_HIGH_VAL_AMT)                / Sum(ASET_CUR_BAL_AMT))), 2) AS HighPercent
    , Round(100 * DECODE(Sum(ASET_CUR_BAL_CALC_CUM_LOS_AMT), 0, 0, (Sum(ASET_CALC_CUM_LOS_HIGH_AMT) / Sum(ASET_CUR_BAL_CALC_CUM_LOS_AMT))), 2) AS LossHighPercent
    , Round(100 * DECODE(Sum(ASET_CUR_BAL_CALC_CUM_LOS_AMT), 0, 0, (Sum(ASET_CALC_CUM_LOS_LW_AMT)  / Sum(ASET_CUR_BAL_CALC_CUM_LOS_AMT))), 2) AS LossLowPercent
    FROM ASET_VLTN_RVW_INSTSMRY
    WHERE USR_RPT_PBLSH_IND = 'Y' AND Etl_Src_File_Typ_Ind = 'C'
    GROUP BY ROLLUP (ASET_CAT_POOL_FST_TXT, ASET_PERF_STAT_TXT)
    ORDER BY POOL,
    Display_Order,
    Perf_Non_Perf DESCAs you can see I am doing a roll-up to get my sub-totaling.. Wouldn't anticipate any problems in going with a conditional named column template with that.
    In the report I am using a standard report, with breaks on Columns 1 & 2 (Pool,Perf_Non_Perf). Have you tried using the inscrutable Break Formatting options in the report attributes? Something like:
    Break Columns: First and Second Columns
    Break Column Style: Repeat Headings on Break
    For repeat heading breaks use this format, use #COLUMN_VALUE# subs
    <tbody><tr><th colspan="9" class="t17ReportHeader" align="left">#COLUMN_VALUE# #COLUMN_VALUE#</th></tr>(Match up the <tt>colspan</tt> and </tt>class</tt> with your displayed columns and theme.)
    Posting data MIGHT be an issue since it is proprietary data, I can try posting bogus data to my hosted area on Oracle's site though..That and access to the workspace would help, or post a <tt>CREATE TABLE</tt> script for <tt>ASET_VLTN_RVW_INSTSMRY</tt> and some inserts for the bogus data here.

  • Wrapping of text in rows of Query in a Web Template

    Hello experts,
    implementing the coding in OSS Note 1292696 - Analysis modification: Fixed column width and line break
    helped in an Masterdata Query using several Attributes to have text wrapping in the header line.
    But the wrapping is needed for the output part of the query, too. How can this be done?
    At the moment - due to working with fixed columnwith - the text in the rows will not be wrapped
    Thank you for you help!
    Angie

    Please give a try with one of the following options..
    A similar post is also available at
    Newline in WDTextView
    <u>Option 1</u>
    1.Set the layout property of the UI element container to be GridLayout or MatrixLayout.
    2.Enable the "wrapping" property of Label or TextView to "true"
    3.Set the "width" property of the UI Element's(label/TV) Layout data to <integer>px [eg: 100px]
    3.Build and Deploy
    <u>Option 2</u>
    This option is only applicable for Labels. But for any Layout.
    1.Set the "width" property of the UI Element(label/TV) to <integer>px [eg: 100px]
    2.Enable the "wrapping" property of Label or TextView to "true"
    3.Build and Deploy
    Thanks and Regards,
    Sam Mathew

  • How to split text according to the textfield size

    Hi, its very urgent if anybody can help me out..... i am
    working on an e-learning course where all the text is coming
    through XML. Client is very specific about not to use scrollbar.
    They want to use more and back buttons to show the rest of the text
    (they dont want the text to be scrolled either). For that I created
    a function to part the text according to the textfield height in an
    array. (one important point is that user can change font type, font
    size anytime in between the course). Here is a bit of code
    This code is working fine, but it gives undesired output if
    we use html tags in helpText
    please help me out..... please

    Thanks FlashTastic,
    I am sorry for not being able to convey my problem....
    actually problem is not that code is not recognizing the tags but
    the problem is.... let me explain, suppose there is a tag <b>
    and </b> in xml..... code split the text so it split
    <b> and </b> too and stored it in an array.... then it
    adds the text i.e. This is a <b> sample </b> text.....
    til the textheight of the textfield is less than the ._height of
    hte textfield and finally i have a string that fits in the
    textfield perfectly and when the parted text is assigned to the
    textfield it recognize the tag and make that bunch of words or
    sentence bold and that creates the problem.... i hope that this
    time it is more clearer....
    Thanks again.....

  • Splitting text form file

    Hello,
    This is the problem, I have a text file with mobile messages, here's an example of these messages.
    25 100
    SEND 2228161 Hello Pete
    RECEIVE 2228161 Hello Chris, how are you?
    SEND 2227765 I hate text speak
    RECEIVE 2228876 wot u on bout
    SEND 2227975 The quick brown fox jumped over the lazy dog
    SEND 2328161 Simple Simon met a pieman going to the fair
    SEND 2226543 Mary had a little lamb, its fleece was white as snow
    SEND 2226543 And everywhere that Mary went the lamb was sure to go
    I have to read the text file, for which the code I have succeeded in doing, the first line of the text file are integers, which I have to assign to to variables say sizeOfMessage and limitOfBox. The code I've written so far reconizes the SEND and RECEIVE messages, using if (line.startsWith("SEND")), this I've tested it works. Now here is where I am pulling my hair out, I need to read the line, evaluate the size of the message excluding the SEND and telephone number, if it is greater than the sizeOfMessage value, split the the message up, then store the fragmented message including the SEND and telephone message into an array. Here is the code so far:-
    tokens = new StringTokenizer(line, "");
                    while (tokens.hasMoreTokens())
                        //get next token
                         System.out.println(tokens.nextToken());
                        // split on the white space with eiher RECEIVE or SEND before it
                        String[] storeTokens = line.split("(SEND|RECEIVE)\\s");
                        if (line.startsWith("SEND"))
                            System.out.println("SEND message");
                            if ((storeTokens[1].length()) > 25)
                                String[] tempTokens = line.split("(?<=SEND)\\s");
                       }         How do I achieve this?
    Any help would be appreciated
    Thanks

    Here's a quick example. Hope this helps.
    /** testfile.txt **********************************
    25 100
    SEND 2228161 Hello Pete
    RECEIVE 2228161 Hello Chris, how are you?
    SEND 2227765 I hate text speak
    RECEIVE 2228876 wot u on bout
    SEND 2227975 The quick brown fox jumped over the lazy dog
    SEND 2328161 Simple Simon met a pieman going to the fair
    SEND 2226543 Mary had a little lamb, its fleece was white as snow
    SEND 2226543 And everywhere that Mary went the lamb was sure to go
    SEND 2226543 There was a labyrinth in the forest where the lamb was lost
    import java.util.*;
    import java.util.regex.*;
    import java.io.*;
    public class MindGames{
      int sizeOfMessage, limitOfBox;
      ArrayList<String> inputLines;
      ArrayList<ArrayList<String>> messages;
      public MindGames(String infilename){
        String line = null;
        inputLines = new ArrayList<String>();
        messages = new ArrayList<ArrayList<String>>();
        try{
          BufferedReader br = new BufferedReader(new FileReader(infilename));
          while ((line = br.readLine()) != null){
            inputLines.add(line);
        catch (Exception e){
          e.printStackTrace();
        String[] temp = (inputLines.remove(0)).split("\\s+"); //remove first line
        sizeOfMessage = Integer.parseInt(temp[0]);
        limitOfBox = Integer.parseInt(temp[0]);
        inputLines = gather(inputLines);
      public void reformatLines(){
        ArrayList<String> aline;
        for (String s : inputLines){
          String[] elements = s.split("\\s+", 3);
          aline = new ArrayList<String>();
          String[] folded = makeFold(elements);
          for (String m : folded){
            aline.add(m);
          messages.add(aline);
      /* gather msgs for same number */
      ArrayList<String> gather(ArrayList<String> lines){
        ArrayList<String> retval = new ArrayList<String>();
        int i = 0;
        String[] current, next;
        String[] dummy = {"", "", ""};
        while (i < lines.size()){
          current = lines.get(i++).split("\\s+", 3);
          if (i < lines.size()){
            next = lines.get(i++).split("\\s+", 3);
          else{
            next = dummy;
          while (next[1].equals(current[1]) && next[0].equals(current[0])){
            current[2] = current[2] + " " + next[2];
            if (i < lines.size()){
              next = lines.get(i++).split("\\s+", 3);
            else{
              next = dummy;
          retval.add(current[0] + " " + current[1] + " " + current[2]);
          if (! next.equals(dummy)){
            --i;
        return retval;
      /* the regex for this version honors word boundary and spaces btw them */
      String[] makeFold(String[] rawSplit){
        ArrayList<String> foldedMsg = new ArrayList<String>();
        String msg = rawSplit[2];
        // short msg | can fold at word boundary | extraordinary long word
        String regex
          = "^.{0," + sizeOfMessage + "}$|.{1," + sizeOfMessage
          + "}(?=\\s|$)|[^\\s]{1," + sizeOfMessage + "}";
        String s;
        Pattern pat = Pattern.compile(regex);
        Matcher mat = pat.matcher(msg);
        while (mat.find()){
          s = mat.group();
          foldedMsg.add(rawSplit[0] + " " + rawSplit[1] + " " + s);
        return foldedMsg.toArray(new String[1]);
      public void testOutput(){
        for (ArrayList<String> as : messages){
          for (String str : as){
            System.out.println(str);
      public static void main(String[] args){
        MindGames mg = new MindGames("testfile.txt");
        mg.reformatLines();
        mg.testOutput();
    /*** output for inputting testfile.txt ***************
    SEND 2228161 Hello Pete
    RECEIVE 2228161 Hello Chris, how are you?
    SEND 2227765 I hate text speak
    RECEIVE 2228876 wot u on bout
    SEND 2227975 The quick brown fox
    SEND 2227975  jumped over the lazy dog
    SEND 2328161 Simple Simon met a pieman
    SEND 2328161  going to the fair
    SEND 2226543 Mary had a little lamb,
    SEND 2226543  its fleece was white as
    SEND 2226543  snow And everywhere that
    SEND 2226543  Mary went the lamb was
    SEND 2226543  sure to go There was a
    SEND 2226543  labyrinth in the forest
    SEND 2226543  where the lamb was lost
    *********************************************************/

  • Blackberry won't receive all split text messages

    I have a blackberry pearl 8130 and its character length for text messages is 140 characters. so when someone sends me a message that is over this length my phone splits it into 2 separate messages. The problem is sometimes I will only receive 1/2 to messages or 2/2 (bot not 1/2). Does anyone know if this is a problem with my phone or with my service provider (I am with vrigin mobile)? also there is only one person that sends me such long messages so could it be a problem with her phone?
    Thanks 

    This issue lies at operators end. You better check with them and try to know what policy they maintain on multi-part SMS.
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

  • JTable header : text = two-rows, onClick action = sorting

    Hi guys.
    I want to create a JTable where the user can have the data sorted by clicking upon a column's header. The code below shows the table I describe (you can click upon a column and sorting is performed).
    import javax.swing.JFrame;
    import java.awt.HeadlessException;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.util.Vector;
    import javax.swing.table.DefaultTableModel;
    //--------- TableSorter ----------
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    //---------- Table Height - Column Width
    import javax.swing.table.TableColumn;
    import java.awt.FontMetrics;
    import javax.swing.JTable;
    import java.awt.Dimension;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2006</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Test extends JFrame {
      JPanel jPanel1 = new JPanel();
      JPanel jPanel2 = new JPanel();
      JButton jButton1 = new JButton();
      FlowLayout flowLayout1 = new FlowLayout();
      BorderLayout borderLayout1 = new BorderLayout();
      BorderLayout borderLayout2 = new BorderLayout();
      //------------- MY VARIABLES -------------
      String[] columnNames_objectArr = new String[] {
          "Col1",
          "Column 2",
          "Column 3",
          "C4",
          "Col5",
          "Col 6",
      Vector columnNames_vector = new Vector();
      private Vector data_vector = new Vector();
      private Object[][] data_objectArr;
      public TableHeight_ColumnWidth tcw;
      private int totalTableWidth = 0, totalTableHeight = 0;
      private JComboBox jcmbxData = new JComboBox(
          new String[] {"Not Configured", "Switch", "Modem"});
      private int maxVisibleRows = 51;
      TableSorter model;
      private JTable table;
      JScrollPane jScrollPane1;
      public Test(String[] args) throws HeadlessException {
        try {
          jbInit();
          setupGUI();
          launchGUI();
        catch(Exception e) {
          e.printStackTrace();
      private void jbtnClose_actionPerformed(ActionEvent e) {
        dispose();
      private void launchGUI() {
        pack();
        setVisible(true);
        setResizable(false);
      private void setupGUI() {
        columnNames_vector.addElement("Col1");
        columnNames_vector.addElement("Column 2");
        columnNames_vector.addElement("Column 3");
        columnNames_vector.addElement("C4");
        columnNames_vector.addElement("Col5");
        columnNames_vector.addElement("Col 6");
        Vector row_data1 = new Vector();
        Vector row_data2 = new Vector();
        Vector row_data3 = new Vector();
        Vector row_data4 = new Vector();
        Vector row_data5 = new Vector();
        Vector row_data6 = new Vector();
        row_data1.add("Mary");
        row_data1.add("Campioneato");
        row_data1.add("Snowboarding");
        row_data1.add(new Integer(578987899));
        row_data1.add(new Boolean(false));
        row_data1.add("Not Configured");
        row_data2.add("Alison");
        row_data2.add("Huml");
        row_data2.add("Rowing");
        row_data2.add(new Integer(3));
        row_data2.add(new Boolean(true));
        row_data2.add("Switch");
        row_data3.add("Ka");
        row_data3.add("Walrath");
        row_data3.add("Knitting");
        row_data3.add(new Integer(2));
        row_data3.add(new Boolean(false));
        row_data3.add("Modem");
        row_data4.add("Sharon");
        row_data4.add("Zakhouras");
        row_data4.add("Speed reading");
        row_data4.add(new Integer(20));
        row_data4.add(new Boolean(true));
        row_data4.add("Switch");
        row_data5.add("Philip");
        row_data5.add("Milner");
        row_data5.add("Pool");
        row_data5.add(new Integer(10));
        row_data5.add(new Boolean(false));
        row_data5.add("Not Configured");
        data_vector.add(row_data1);
        data_vector.add(row_data2);
        data_vector.add(row_data3);
        data_vector.add(row_data4);
        data_vector.add(row_data5);
        model = new TableSorter(new SortTableModel(data_vector, columnNames_vector));
        table = new JTable(model);
        tcw = new TableHeight_ColumnWidth(model, table);
        jScrollPane1 = new JScrollPane(table);
        model.setTableHeader(table.getTableHeader());
        jPanel1.add(jScrollPane1, BorderLayout.CENTER);
        //Add a JComboBox as a cellEditor...
        DefaultCellEditor dce = new DefaultCellEditor(jcmbxData);
        table.getColumnModel().getColumn(5).setCellEditor(dce);
        //..... add the IPJPanel as cellEditor.....
        tcw.fixTableLook(maxVisibleRows);
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout2);
        jPanel1.setLayout(borderLayout1);
        jPanel2.setLayout(flowLayout1);
        jButton1.setText("Close");
        jPanel1.setBorder(BorderFactory.createRaisedBevelBorder());
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
        jPanel2.add(jButton1, null);
        jButton1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jbtnClose_actionPerformed(e);
      public static void main( String[] args ) {
        new Test(args);
      public boolean getScrollableTracksViewportHeight() {
        Component parent = getParent();
        if (parent instanceof JViewport) {
          return parent.getHeight() > getPreferredSize().height;
        return false;
      //------------------ MY TABLE MODEL ------------------
      public class SortTableModel extends DefaultTableModel {
        private boolean DEBUG = false;
        public SortTableModel(Object[][] data, String[] columnNames) {
          super(data, columnNames);
        public SortTableModel(Vector data, Vector columnNames) {
          super(data, columnNames);
      //------------------ TABLE SORTER -----------------------
      public class TableSorter extends AbstractTableModel {
          protected TableModel tableModel;
          public static final int DESCENDING = -1;
          public static final int NOT_SORTED = 0;
          public static final int ASCENDING = 1;
          private Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
          public final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
              public int compare(Object o1, Object o2) {
                  return ((Comparable) o1).compareTo(o2);
          public final Comparator LEXICAL_COMPARATOR = new Comparator() {
              public int compare(Object o1, Object o2) {
                  return o1.toString().compareTo(o2.toString());
          private Row[] viewToModel;
          private int[] modelToView;
          private JTableHeader tableHeader;
          private MouseListener mouseListener;
          private TableModelListener tableModelListener;
          private Map columnComparators = new HashMap();
          private List sortingColumns = new ArrayList();
          public TableSorter() {
              this.mouseListener = new MouseHandler();
              this.tableModelListener = new TableModelHandler();
          public TableSorter(TableModel tableModel) {
              this();
              setTableModel(tableModel);
          public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
              this();
              setTableHeader(tableHeader);
              setTableModel(tableModel);
          private void clearSortingState() {
              viewToModel = null;
              modelToView = null;
          public TableModel getTableModel() {
              return tableModel;
          public void setTableModel(TableModel tableModel) {
              if (this.tableModel != null) {
                  this.tableModel.removeTableModelListener(tableModelListener);
              this.tableModel = tableModel;
              if (this.tableModel != null) {
                  this.tableModel.addTableModelListener(tableModelListener);
              clearSortingState();
              fireTableStructureChanged();
          public JTableHeader getTableHeader() {
              return tableHeader;
          public void setTableHeader(JTableHeader tableHeader) {
              if (this.tableHeader != null) {
                  this.tableHeader.removeMouseListener(mouseListener);
                  TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
                  if (defaultRenderer instanceof SortableHeaderRenderer) {
                      this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
              this.tableHeader = tableHeader;
              if (this.tableHeader != null) {
                  this.tableHeader.addMouseListener(mouseListener);
                  this.tableHeader.setDefaultRenderer(
                          new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
          public boolean isSorting() {
              return sortingColumns.size() != 0;
          private Directive getDirective(int column) {
              for (int i = 0; i < sortingColumns.size(); i++) {
                  Directive directive = (Directive)sortingColumns.get(i);
                  if (directive.column == column) {
                      return directive;
              return EMPTY_DIRECTIVE;
          public int getSortingStatus(int column) {
              return getDirective(column).direction;
          private void sortingStatusChanged() {
              clearSortingState();
              fireTableDataChanged();
              if (tableHeader != null) {
                  tableHeader.repaint();
          public void setSortingStatus(int column, int status) {
              Directive directive = getDirective(column);
              if (directive != EMPTY_DIRECTIVE) {
                  sortingColumns.remove(directive);
              if (status != NOT_SORTED) {
                  sortingColumns.add(new Directive(column, status));
              sortingStatusChanged();
          protected Icon getHeaderRendererIcon(int column, int size) {
              Directive directive = getDirective(column);
              if (directive == EMPTY_DIRECTIVE) {
                  return null;
              return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
          private void cancelSorting() {
              sortingColumns.clear();
              sortingStatusChanged();
          public void setColumnComparator(Class type, Comparator comparator) {
              if (comparator == null) {
                  columnComparators.remove(type);
              } else {
                  columnComparators.put(type, comparator);
          protected Comparator getComparator(int column) {
              Class columnType = tableModel.getColumnClass(column);
              Comparator comparator = (Comparator) columnComparators.get(columnType);
              if (comparator != null) {
                  return comparator;
              if (Comparable.class.isAssignableFrom(columnType)) {
                  return COMPARABLE_COMAPRATOR;
              return LEXICAL_COMPARATOR;
          private Row[] getViewToModel() {
              if (viewToModel == null) {
                  int tableModelRowCount = tableModel.getRowCount();
                  viewToModel = new Row[tableModelRowCount];
                  for (int row = 0; row < tableModelRowCount; row++) {
                      viewToModel[row] = new Row(row);
                  if (isSorting()) {
                      Arrays.sort(viewToModel);
              return viewToModel;
          public int modelIndex(int viewIndex) {
              return getViewToModel()[viewIndex].modelIndex;
          private int[] getModelToView() {
              if (modelToView == null) {
                  int n = getViewToModel().length;
                  modelToView = new int[n];
                  for (int i = 0; i < n; i++) {
                      modelToView[modelIndex(i)] = i;
              return modelToView;
          // TableModel interface methods
          public int getRowCount() {
              return (tableModel == null) ? 0 : tableModel.getRowCount();
          public int getColumnCount() {
              return (tableModel == null) ? 0 : tableModel.getColumnCount();
          public String getColumnName(int column) {
              return tableModel.getColumnName(column);
          public Class getColumnClass(int column) {
              return tableModel.getColumnClass(column);
          public boolean isCellEditable(int row, int column) {
              return tableModel.isCellEditable(modelIndex(row), column);
          public Object getValueAt(int row, int column) {
              return tableModel.getValueAt(modelIndex(row), column);
          public void setValueAt(Object aValue, int row, int column) {
              tableModel.setValueAt(aValue, modelIndex(row), column);
          // Helper classes
          private class Row implements Comparable {
              private int modelIndex;
              public Row(int index) {
                  this.modelIndex = index;
              public int compareTo(Object o) {
                  int row1 = modelIndex;
                  int row2 = ((Row) o).modelIndex;
                  for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
                      Directive directive = (Directive) it.next();
                      int column = directive.column;
                      Object o1 = tableModel.getValueAt(row1, column);
                      Object o2 = tableModel.getValueAt(row2, column);
                      int comparison = 0;
                      // Define null less than everything, except null.
                      if (o1 == null && o2 == null) {
                          comparison = 0;
                      } else if (o1 == null) {
                          comparison = -1;
                      } else if (o2 == null) {
                          comparison = 1;
                      } else {
                          comparison = getComparator(column).compare(o1, o2);
                      if (comparison != 0) {
                          return directive.direction == DESCENDING ? -comparison : comparison;
                  return 0;
          private class TableModelHandler implements TableModelListener {
              public void tableChanged(TableModelEvent e) {
                  // If we're not sorting by anything, just pass the event along.
                  if (!isSorting()) {
                      clearSortingState();
                      fireTableChanged(e);
                      return;
                  // If the table structure has changed, cancel the sorting; the
                  // sorting columns may have been either moved or deleted from
                  // the model.
                  if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                      cancelSorting();
                      fireTableChanged(e);
                      return;
                  // We can map a cell event through to the view without widening
                  // when the following conditions apply:
                  // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
                  // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
                  // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
                  // d) a reverse lookup will not trigger a sort (modelToView != null)
                  // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
                  // The last check, for (modelToView != null) is to see if modelToView
                  // is already allocated. If we don't do this check; sorting can become
                  // a performance bottleneck for applications where cells
                  // change rapidly in different parts of the table. If cells
                  // change alternately in the sorting column and then outside of
                  // it this class can end up re-sorting on alternate cell updates -
                  // which can be a performance problem for large tables. The last
                  // clause avoids this problem.
                  int column = e.getColumn();
                  if (e.getFirstRow() == e.getLastRow()
                          && column != TableModelEvent.ALL_COLUMNS
                          && getSortingStatus(column) == NOT_SORTED
                          && modelToView != null) {
                      int viewIndex = getModelToView()[e.getFirstRow()];
                      fireTableChanged(new TableModelEvent(TableSorter.this,
                                                           viewIndex, viewIndex,
                                                           column, e.getType()));
                      return;
                  // Something has happened to the data that may have invalidated the row order.
                  clearSortingState();
                  fireTableDataChanged();
                  return;
          private class MouseHandler extends MouseAdapter {
              public void mouseClicked(MouseEvent e) {
                  JTableHeader h = (JTableHeader) e.getSource();
                  TableColumnModel columnModel = h.getColumnModel();
                  int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                  int column = columnModel.getColumn(viewColumn).getModelIndex();
                  if (column != -1) {
                      int status = getSortingStatus(column);
                      if (!e.isControlDown()) {
                          cancelSorting();
                      // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                      // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                      status = status + (e.isShiftDown() ? -1 : 1);
                      status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                      setSortingStatus(column, status);
          private class Arrow implements Icon {
              private boolean descending;
              private int size;
              private int priority;
              public Arrow(boolean descending, int size, int priority) {
                  this.descending = descending;
                  this.size = size;
                  this.priority = priority;
              public void paintIcon(Component c, Graphics g, int x, int y) {
                  Color color = c == null ? Color.GRAY : c.getBackground();
                  // In a compound sort, make each succesive triangle 20%
                  // smaller than the previous one.
                  int dx = (int)(size/2*Math.pow(0.8, priority));
                  int dy = descending ? dx : -dx;
                  // Align icon (roughly) with font baseline.
                  y = y + 5*size/6 + (descending ? -dy : 0);
                  int shift = descending ? 1 : -1;
                  g.translate(x, y);
                  // Right diagonal.
                  g.setColor(color.darker());
                  g.drawLine(dx / 2, dy, 0, 0);
                  g.drawLine(dx / 2, dy + shift, 0, shift);
                  // Left diagonal.
                  g.setColor(color.brighter());
                  g.drawLine(dx / 2, dy, dx, 0);
                  g.drawLine(dx / 2, dy + shift, dx, shift);
                  // Horizontal line.
                  if (descending) {
                      g.setColor(color.darker().darker());
                  } else {
                      g.setColor(color.brighter().brighter());
                  g.drawLine(dx, 0, 0, 0);
                  g.setColor(color);
                  g.translate(-x, -y);
              public int getIconWidth() {
                  return size;
              public int getIconHeight() {
                  return size;
          private class SortableHeaderRenderer implements TableCellRenderer {
              private TableCellRenderer tableCellRenderer;
              public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
                  this.tableCellRenderer = tableCellRenderer;
              public Component getTableCellRendererComponent(JTable table,
                                                             Object value,
                                                             boolean isSelected,
                                                             boolean hasFocus,
                                                             int row,
                                                             int column) {
                  Component c = tableCellRenderer.getTableCellRendererComponent(table,
                          value, isSelected, hasFocus, row, column);
                  if (c instanceof JLabel) {
                      JLabel l = (JLabel) c;
                      l.setHorizontalTextPosition(JLabel.LEFT);
                      int modelColumn = table.convertColumnIndexToModel(column);
                      l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
                  return c;
          private class Directive {
              private int column;
              private int direction;
              public Directive(int column, int direction) {
                  this.column = column;
                  this.direction = direction;
      //-------------- FIX TABLE'S HEIGHT & COLUMN WIDTH ---------
      public class TableHeight_ColumnWidth {
        private TableSorter sorter;
        private FontMetrics fm;
        private JTable table;
        private int numOfRows = 0, totalTableHeight = 0, totalTableWidth = 0;
         * Constructor --- it needs the model as well the JTable as parameters
         * @param sorter - the model
         * @param table - the JTable created based on the model
        public TableHeight_ColumnWidth(TableSorter sorter, JTable table) {
          this.sorter = sorter;
          this.table = table;
          this.fm = table.getFontMetrics(table.getFont());
          this.numOfRows = table.getRowCount();
         * Calculates the width of each column according to the String it contains
         * @param col = the desired column
         * @param fm = the FontMetrics of this column
         * @return - the width of the single column
        public int determineColumnWidth(TableColumn col, FontMetrics fm) {
          int headerWidth = fm.stringWidth((String)col.getHeaderValue());
          int columnNumber = col.getModelIndex();
          int max = headerWidth;
          int columnWidth = 0;
          String cell = "";
          Integer cell_int = new Integer(0);
          Short cell_short = new Short((short)0);
          for (int i = 0; i != sorter.getRowCount(); i++) {
            Object obj = (Object) sorter.getValueAt(i, columnNumber);
            if (obj instanceof String) {
              cell = (String)sorter.getValueAt(i, columnNumber);
            else if (obj instanceof Integer) {
              cell_int = (Integer)sorter.getValueAt(i, columnNumber);
              cell = String.valueOf(cell_int.intValue());
            else if (obj instanceof Short) {
              cell_short = (Short) sorter.getValueAt(i, columnNumber);
              cell = String.valueOf(cell_short.shortValue());
            columnWidth = fm.stringWidth(cell) + 5;
            if (columnWidth > max) {
              max = columnWidth;
          return max + 5;
         * Calculates the total width of the table according to the width of each
         * column.
         * @return - totalTableWidth
        private int fixColumnWidth () {
          int totalTableWidth = 0;
          TableColumn c = null;
          int cw = 0;
          for (int i = 0; i < table.getColumnCount(); i++) {
            c = table.getColumn(table.getColumnName(i));
            cw = this.determineColumnWidth(c, fm);
            c.setPreferredWidth(cw);
            totalTableWidth = totalTableWidth + cw;
            c.setMinWidth(cw);
          return totalTableWidth;
         * Calculates the height of the table according to the height of each row
         * multiplied by 51 (by default) or by the totalRowsCount.
         * @return - totalTableHeight
        private int fixTableHeight(int maxVisibleRows) {
          int rowHeight = table.getRowHeight();
          //Show maxVisibleRows rows maximum
          if (numOfRows > maxVisibleRows) {
            totalTableHeight = rowHeight * maxVisibleRows;
          else {
            totalTableHeight = rowHeight * numOfRows;
          return totalTableHeight;
         * Sets up the table according to the totalTableWidth and totalTableHeight
        public void fixTableLook(int maxVisibleRows) {
          table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
          totalTableWidth = this.fixColumnWidth();
          totalTableHeight = this.fixTableHeight(maxVisibleRows);
          table.setPreferredScrollableViewportSize(new Dimension(totalTableWidth, totalTableHeight));
    }Also, I want some column headers to display their text in two-rows. But by using the HTML technique look at the result in comparison with the previous table I had!
    import javax.swing.JFrame;
    import java.awt.HeadlessException;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.util.Vector;
    import javax.swing.table.DefaultTableModel;
    //--------- TableSorter ----------
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    //---------- Table Height - Column Width
    import javax.swing.table.TableColumn;
    import java.awt.FontMetrics;
    import javax.swing.JTable;
    import java.awt.Dimension;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2006</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class Test extends JFrame {
      JPanel jPanel1 = new JPanel();
      JPanel jPanel2 = new JPanel();
      JButton jButton1 = new JButton();
      FlowLayout flowLayout1 = new FlowLayout();
      BorderLayout borderLayout1 = new BorderLayout();
      BorderLayout borderLayout2 = new BorderLayout();
      //------------- MY VARIABLES -------------
      String[] columnNames_objectArr = new String[] {
          "Col1",
          "Column 2",
          "Column 3",
          "C4",
          "Col5",
          "Col 6",
      Vector columnNames_vector = new Vector();
      private Vector data_vector = new Vector();
      private Object[][] data_objectArr;
      public TableHeight_ColumnWidth tcw;
      private int totalTableWidth = 0, totalTableHeight = 0;
      private JComboBox jcmbxData = new JComboBox(
          new String[] {"Not Configured", "Switch", "Modem"});
      private int maxVisibleRows = 51;
      TableSorter model;
      private JTable table;
      JScrollPane jScrollPane1;
      public Test(String[] args) throws HeadlessException {
        try {
          jbInit();
          setupGUI();
          launchGUI();
        catch(Exception e) {
          e.printStackTrace();
      private void jbtnClose_actionPerformed(ActionEvent e) {
        dispose();
      private void launchGUI() {
        pack();
        setVisible(true);
        setResizable(false);
      private void setupGUI() {
        columnNames_vector.addElement("<html>Col1</html>");
        columnNames_vector.addElement("<html>Column 2</html>");
        columnNames_vector.addElement("<html>Column 3<br>Second Row</html>");
        columnNames_vector.addElement("<html>C4</html>");
        columnNames_vector.addElement("<html>Col5</html>");
        columnNames_vector.addElement("<html>Col 6</html>");
        Vector row_data1 = new Vector();
        Vector row_data2 = new Vector();
        Vector row_data3 = new Vector();
        Vector row_data4 = new Vector();
        Vector row_data5 = new Vector();
        Vector row_data6 = new Vector();
        row_data1.add("Mary");
        row_data1.add("Campioneato");
        row_data1.add("Snowboarding");
        row_data1.add(new Integer(578987899));
        row_data1.add(new Boolean(false));
        row_data1.add("Not Configured");
        row_data2.add("Alison");
        row_data2.add("Huml");
        row_data2.add("Rowing");
        row_data2.add(new Integer(3));
        row_data2.add(new Boolean(true));
        row_data2.add("Switch");
        row_data3.add("Ka");
        row_data3.add("Walrath");
        row_data3.add("Knitting");
        row_data3.add(new Integer(2));
        row_data3.add(new Boolean(false));
        row_data3.add("Modem");
        row_data4.add("Sharon");
        row_data4.add("Zakhouras");
        row_data4.add("Speed reading");
        row_data4.add(new Integer(20));
        row_data4.add(new Boolean(true));
        row_data4.add("Switch");
        row_data5.add("Philip");
        row_data5.add("Milner");
        row_data5.add("Pool");
        row_data5.add(new Integer(10));
        row_data5.add(new Boolean(false));
        row_data5.add("Not Configured");
        data_vector.add(row_data1);
        data_vector.add(row_data2);
        data_vector.add(row_data3);
        data_vector.add(row_data4);
        data_vector.add(row_data5);
        model = new TableSorter(new SortTableModel(data_vector, columnNames_vector));
        table = new JTable(model);
        tcw = new TableHeight_ColumnWidth(model, table);
        jScrollPane1 = new JScrollPane(table);
        model.setTableHeader(table.getTableHeader());
        jPanel1.add(jScrollPane1, BorderLayout.CENTER);
        //Add a JComboBox as a cellEditor...
        DefaultCellEditor dce = new DefaultCellEditor(jcmbxData);
        table.getColumnModel().getColumn(5).setCellEditor(dce);
        //..... add the IPJPanel as cellEditor.....
        tcw.fixTableLook(maxVisibleRows);
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout2);
        jPanel1.setLayout(borderLayout1);
        jPanel2.setLayout(flowLayout1);
        jButton1.setText("Close");
        jPanel1.setBorder(BorderFactory.createRaisedBevelBorder());
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        this.getContentPane().add(jPanel2, BorderLayout.SOUTH);
        jPanel2.add(jButton1, null);
        jButton1.addActionListener(new ActionListener() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

    First of all I found out that when I set the column's header like this:
    columnNames_vector.addElement("<html>Column 3<br>Second Row</html>"); //In the setupGUI() methodthe TableHeight_ColumnWidth.determineColumnWidth(TableColumn col, FontMetrics fm) method calculates the column's width by counting <html>, </html>, <br> characters as well. So I added a check to reject these characters and not count them for the column's width.
    As for the header's height:
    I found that when the first column's header is set to display two-lines, then the height of the rest columns headers is set to display two-lines as well. In other words, the height of the first column's header affects the height of the whole JTableHeader.
    I found that the BasicTableHeaderUI.getHeaderHeight() method is called, within which there are these comments:
              // If the header value is empty (== "") in the
              // first column (and this column is set up
              // to use the default renderer) we will
              // return zero from this routine and the header
              // will disappear altogether. Avoiding the calculation
              // of the preferred size is such a performance win for
              // most applications that we will continue to
              // use this cheaper calculation, handling these
              // issues as `edge cases'. Should I override a class and if so which one? I am so confused! If anyone has any idea about how to set the header's height according to the cell's height that is the maximum among all, please let me know.

  • How to split columns into rows

    Hi All,
    Below is my table structure:=
    SQL> create table split(id number,value varchar2(200));
    Table created.
    SQL> insert into split values(1,'X,Y,Z');
    1 row created.
    SQL> insert into split values(2,'A,B,C');
    1 row created.
    SQL> commit;
    Commit complete.
    Expected Output
    ID Value
    1 X
    1 Y
    1 Z
    2 A
    2 B
    3 C
    I know the feature of converting rows into columns by listagg in Oracle 11g, but is there any feature to convert rows into columns based on a delemiter..."," in my case.
    Please help....
    Thanks
    Arijit

    >
    is there any feature to convert rows into columns based on a delemiter
    >
    Here is one way
    VAR csv VARCHAR2(100)EXEC :csv := 'abc,de,fg,hij,klmn,o,pq,rst,uvw,xyz';
    The query:
    WITH data AS( SELECT SUBSTR(csv, INSTR(csv,',',1,LEVEL)+1,                     INSTR(csv,',',1,LEVEL+1) - INSTR(csv,',',1,LEVEL)-1 ) token    FROM ( SELECT ','||:csv||',' csv FROM SYS.DUAL ) CONNECT BY LEVEL < LENGTH(:csv)-LENGTH(REPLACE(:csv,',',''))+2 )SELECT token  FROM data;See http://projectwownow.blogspot.com/2010/02/oracle-convert-csv-string-into-rows.html

Maybe you are looking for

  • Office Web Apps Server Antivirus Exclusions

    Hello, Are there any guidelines for Antivirus exclusions with respect to Office Web Apps server like we have for Exchange, Lync and SharePoint servers. I would highly appreciate if any help in this regard. We have office web apps server that we are u

  • Corrupt CR2 RAW files

    Has anyone found a fix for CR2 RAW files being corrupted? I have read all the thread postings I could google on various forums and can not seem to find any solid fix to the problem. I purchased the Canon 400D for my trip to Asia and shot over 1500 ph

  • Question regarding PO approval

    Hi All, I have a question regarding PO approval. I know we can do the delegate at the application level, but if I grant a read-only access of my outlook inbox to person1 and person1 accept a notification, is there a way, at the application level, to

  • VAT Report using XL Reporter

    Dear all,         If any body having VAT Return format for tamilnadu state plz send it to me Regards, guru

  • IPhone - OSX 10.5.6 internet sharing via wifi has packet loss

    I try to access the web on the iPhone (for testing purposes) via the bult-in internet sharing capability of my MacBookPro via WiFi. I get very slow connections and high packet loss on distances of less than a foot. If I activate Internet sharing (eth