Swings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    Swings

    hi,
    can any one please say me the equivalent for "\n" in Swings.
    because i'm having the data in JTable like
    For Example

    Apple Mango orange

    i need the output format like
    Apple
    mango
    orange
    please help me out..

    -Thanks & Regards,
    Hamsa
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by gaya3
    hi,
    can any one please say me the equivalent for "\n" in Swings.
    because i'm having the data in JTable like
    For Example

    Apple Mango orange

    i need the output format like
    Apple
    mango
    orange
    please help me out..

    -Thanks & Regards,
    Hamsa

    In Windows "\n" is not working?
    If you want to make the "\n" independent then you can do ...
    System.getPrope rty("line.separ ator");

    Debasis Jana

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by gaya3
      hi,
      can any one please say me the equivalent for "\n" in Swings.
      because i'm having the data in JTable like
      For Example

      Apple Mango orange

      i need the output format like
      Apple
      mango
      orange
      please help me out..

      -Thanks & Regards,
      Hamsa
      Try using an HTML break tag

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by gaya3
        hi,
        can any one please say me the equivalent for "\n" in Swings.
        because i'm having the data in JTable like
        For Example

        Apple Mango orange

        i need the output format like
        Apple
        mango
        orange
        please help me out..

        -Thanks & Regards,
        Hamsa
        Do I understand you correctly? You have one row with three columns and you
        want the transposed of it, i.e. three rows with one column each?

        kind regards,

        Jos

        Comment

        • gaya3
          New Member
          • Aug 2007
          • 184

          #5
          Originally posted by JosAH
          Do I understand you correctly? You have one row with three columns and you
          want the transposed of it, i.e. three rows with one column each?

          kind regards,

          Jos

          yes Jos,you have understood rite..
          I have created JTable as follows..
          String fields[] = {"column 1", "column 2","column 3"};
          int i=0;

          ResultSet rs = preparedStmt.ex ecuteQuery();

          while(rs.next() )
          {
          for(int j=0;j<3;j++)
          {
          data[i][j] = rs.getString(j+ 1);
          i++;
          }
          }

          In data[n][1] where 'n' may be any value ..
          i'm having value as "Apple Orange Mango" but i want as
          Apple
          Orange
          Mango
          JTable jt = new JTable( data, fields );
          where 'fields' represents columns.
          please help me out.

          -Thanks & Regards,
          Hamsa

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            But what do you want if you have n > 1 rows with three columns each? Do you
            want n columns and just three rows?

            kind regards,

            Jos

            Comment

            • gaya3
              New Member
              • Aug 2007
              • 184

              #7
              Originally posted by JosAH
              But what do you want if you have n > 1 rows with three columns each? Do you
              want n columns and just three rows?

              kind regards,

              Jos
              'n' it denotes the number of rows in resultset... it varies..

              -Thanks & Regards,
              Hamsa

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by gaya3
                'n' it denotes the number of rows in resultset... it varies..

                -Thanks & Regards,
                Hamsa
                Yes, that's what I wrote but what is the answer to my question?

                kind regards,

                Jos

                Comment

                • gaya3
                  New Member
                  • Aug 2007
                  • 184

                  #9
                  Originally posted by JosAH
                  Yes, that's what I wrote but what is the answer to my question?

                  kind regards,

                  Jos

                  yes Jos, I need for n>1 with three columns..

                  -Thanks & Regards,
                  Hamsa

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by gaya3
                    yes Jos, I need for n>1 with three columns..

                    -Thanks & Regards,
                    Hamsa
                    That is not what I mean, suppose you have the following rows:

                    f1 f2 f3
                    f3 f5 f6

                    Dou you want a JTable as:

                    f1 f4
                    f2 f5
                    f3 f6

                    ?

                    that is: if you have n rows with three columns each, do you want a JTable with
                    three rows having n columns?

                    kind regards,

                    Jos

                    Comment

                    • gaya3
                      New Member
                      • Aug 2007
                      • 184

                      #11
                      Originally posted by JosAH
                      That is not what I mean, suppose you have the following rows:

                      f1 f2 f3
                      f3 f5 f6

                      Dou you want a JTable as:

                      f1 f4
                      f2 f5
                      f3 f6

                      ?

                      that is: if you have n rows with three columns each, do you want a JTable with
                      three rows having n columns?

                      kind regards,

                      Jos

                      jos, u dont confuse with transpose concept.
                      In one column in Jtable i'm having as follow

                      column 1 column2
                      c1 c2 c3 ....

                      what i need is

                      column 1
                      c1
                      c2
                      c3

                      now u got it? where i'm getting value for that column1 from resultSet

                      -Thanks & Regards
                      Hamsa

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #12
                        Originally posted by gaya3
                        jos, u dont confuse with transpose concept.
                        In one column in Jtable i'm having as follow

                        column 1 column2
                        c1 c2 c3 ....

                        what i need is

                        column 1
                        c1
                        c2
                        c3

                        now u got it? where i'm getting value for that column1 from resultSet

                        -Thanks & Regards
                        Hamsa
                        No I still don't get it; see my previous reply; show me how you want to display the
                        values f1, f2, ... f6
                        Those 6 values are two rows of three columns each in your database. How do
                        you want to display them in your JTable?

                        kind regards,

                        Jos

                        Comment

                        • gaya3
                          New Member
                          • Aug 2007
                          • 184

                          #13
                          Originally posted by JosAH
                          No I still don't get it; see my previous reply; show me how you want to display the
                          values f1, f2, ... f6
                          Those 6 values are two rows of three columns each in your database. How do
                          you want to display them in your JTable?

                          kind regards,

                          Jos

                          Jos, in my DB, i 'm having values like

                          create table order_table(ord er_num varchar(10),cus tomer_name varchar(50) fruits varchar(100))

                          In the above table i'm having entry like {'111','AAAA',' Apple Orange Mango'}

                          In front end, i;m executing the query as
                          "select fruits from order_table where ordernum=111".
                          From the resultSet i'm getting as

                          while(rs.next() )
                          {
                          temp[i][0] = rs.getString(1) ; //here i'm getting as 'Apple orange Mango'
                          i++; i need as one by one(how to format it store in
                          array)
                          }


                          hope now u got it..

                          -Thanks & Regards,
                          Hamsa

                          Comment

                          • JosAH
                            Recognized Expert MVP
                            • Mar 2007
                            • 11453

                            #14
                            Originally posted by gaya3
                            Jos, in my DB, i 'm having values like

                            create table order_table(ord er_num varchar(10),cus tomer_name varchar(50) fruits varchar(100))

                            In the above table i'm having entry like {'111','AAAA',' Apple Orange Mango'}

                            In front end, i;m executing the query as
                            "select fruits from order_table where ordernum=111".
                            From the resultSet i'm getting as

                            while(rs.next() )
                            {
                            temp[i][0] = rs.getString(1) ; //here i'm getting as 'Apple orange Mango'
                            i++; i need as one by one(how to format it store in
                            array)
                            }


                            hope now u got it..

                            -Thanks & Regards,
                            Hamsa
                            Ah, ok, now I get it: you have three 'things' in one column of your database (that
                            is considered very ugly). You need to use some String methods like split() and
                            do a little programming; that's all. Use a List to store those columns and feed
                            that List to your single column JTable.

                            kind regards,

                            Jos

                            Comment

                            • gaya3
                              New Member
                              • Aug 2007
                              • 184

                              #15
                              Originally posted by JosAH
                              Ah, ok, now I get it: you have three 'things' in one column of your database (that
                              is considered very ugly). You need to use some String methods like split() and
                              do a little programming; that's all. Use a List to store those columns and feed
                              that List to your single column JTable.

                              kind regards,

                              Jos

                              Jos, i tried with String buffer concept as follows..
                              StringBuffer strbuff = new StringBuffer();
                              String fields[] = {"Fruits"};
                              while //loop
                              {
                              strbuff .append(String_ from_resultset) ; ---------> I tokenized from the resultset
                              strbuff.append( "/n");
                              data[i][1] = strbuff.toStrin g();
                              }
                              JTable jtable = new JTable(data,fie lds);
                              still facing the same problem Jos..:-(

                              -Thanks & Regards,
                              Hamsa

                              Comment

                              Working...