You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Jérôme Serré <je...@gmail.com> on 2010/10/22 10:29:32 UTC

To build a TablePane

Hello,

 

I try to build a TablePane dynamically but it doesn’t work !

As if the table had no rows and no columns.

Someone could help me to find the error.

Thanks

 

 

Trace : 

nbCol: 3

nbLigne: 4

Rows: 4

Columns: 3

i: 2

j: 1

and the error : 

java.lang.IndexOutOfBoundsException: index 1 out of bounds.

                        at
org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)

                        at
org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)

                        at
org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)

                        at
org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)

                        at
applet.Principale.buildHautDroit(Principale.java:552)

 

TablePane hautDroit = new TablePane();

int nbCol = cb.getNbColonne();

int nbLigne = cb.getNbLigne();

 

System.out.println("nbCol: " + nbCol);

System.out.println("nbLigne: " + nbLigne);

 

for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
TablePane.Column(1, true)); }

for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new TablePane.Row(1,
true)); }

 

System.out.println("Rows: " + hautDroit.getRows().getLength());

System.out.println("Columns: " + hautDroit.getColumns().getLength());

       

ImageView im;

for (int i=0; i<nbLigne; i++) {

for (int j=0; j<nbCol; j++) {

              if (cb.getCase(i, j)!=null) {

System.out.println("i: " + i);

                     System.out.println("j: " + j);

                    im = new ImageView(Image.load(cb.getCase(i,
j).getVin().getImgCouleur()));

                    im.getUserData().put(String.valueOf(i) +
String.valueOf(j), cb.getCase(i, j));

       ==è Error    hautDroit.setCellComponent(i, j, im);          

              }

       }

}

 

--

Cordialement

Jérôme Serré

 



RE: To build a TablePane

Posted by Jérôme Serré <je...@gmail.com>.
Super thanks very much

-----Message d'origine-----
De : Greg Brown [mailto:gkbrown@mac.com] 
Envoyé : vendredi 22 octobre 2010 14:37
À : user@pivot.apache.org
Objet : Re: To build a TablePane

I think I see the problem. When an instance of TablePane.Row is created, it
is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls
update() on the row, you get an IndexOutOfBounds exception because there is
no cell at that index to update.

I had actually forgotten about this method, and it should probably be
removed from the platform for this reason. The best way to construct a
TablePane dynamically is to create all of your columns, then use the add()
method to create and populate the rows:


    TablePane tablePane = new TablePane();

    // Add 3 columns
    TablePane.ColumnSequence columns = tablePane.getColumns();
    columns.add(new TablePane.Column());
    columns.add(new TablePane.Column());
    columns.add(new TablePane.Column());
    
    TablePane.RowSequence rows = tablePane.getRows();

    for (int i = 0; i < ROW_COUNT; i++) {
        TablePane.Row row = new TablePane.Row();
        rows.add(row);
        
        for (int j = 0; j < columns.getLength(); j++) {
            // Add cell for column j
        }
    }

G

On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:

> Hello,
> 
> 
> 
> I try to build a TablePane dynamically but it doesn’t work !
> 
> As if the table had no rows and no columns.
> 
> Someone could help me to find the error.
> 
> Thanks
> 
> 
> 
> 
> 
> Trace : 
> 
> nbCol: 3
> 
> nbLigne: 4
> 
> Rows: 4
> 
> Columns: 3
> 
> i: 2
> 
> j: 1
> 
> and the error : 
> 
> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
> 
>                        at
>
org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
> 
>                        at
> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
> 
>                        at
> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
> 
>                        at
> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
> 
>                        at
> applet.Principale.buildHautDroit(Principale.java:552)
> 
> 
> 
> TablePane hautDroit = new TablePane();
> 
> int nbCol = cb.getNbColonne();
> 
> int nbLigne = cb.getNbLigne();
> 
> 
> 
> System.out.println("nbCol: " + nbCol);
> 
> System.out.println("nbLigne: " + nbLigne);
> 
> 
> 
> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
> TablePane.Column(1, true)); }
> 
> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new
TablePane.Row(1,
> true)); }
> 
> 
> 
> System.out.println("Rows: " + hautDroit.getRows().getLength());
> 
> System.out.println("Columns: " + hautDroit.getColumns().getLength());
> 
> 
> 
> ImageView im;
> 
> for (int i=0; i<nbLigne; i++) {
> 
> for (int j=0; j<nbCol; j++) {
> 
>              if (cb.getCase(i, j)!=null) {
> 
> System.out.println("i: " + i);
> 
>                     System.out.println("j: " + j);
> 
>                    im = new ImageView(Image.load(cb.getCase(i,
> j).getVin().getImgCouleur()));
> 
>                    im.getUserData().put(String.valueOf(i) +
> String.valueOf(j), cb.getCase(i, j));
> 
>       ==è Error    hautDroit.setCellComponent(i, j, im);          
> 
>              }
> 
>       }
> 
> }
> 
> 
> 
> --
> 
> Cordialement
> 
> Jérôme Serré
> 
> 
> 
> 


Re: Vertical label for bar chart

Posted by Greg Brown <gk...@mac.com>.
I just added a categoryLabelRotation style to the area chart, bar chart, and line chart skins. If you build from source you can now use this style.


On Oct 22, 2010, at 5:41 PM, Shahzad Bhatti wrote:

> I found an example of vertical label (with angle) at http://left.subtree.org/2007/08/14/rotate-labels-jfreechart/. It's using axis property to change the angle, e.g.
> 
> CategoryPlot plot = (CategoryPlot)chart.getPlot();
> 37              CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
> 38              xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
> 39
> 
> 
> On Oct 22, 2010, at 11:15 AM, Greg Brown wrote:
> 
> Ah - good question. I don't think you can currently do that. However, if you can figure out how to do this via the JFreeChart API, maybe we can add a style to allow you to specify it via the chart skin.
> 
> On Oct 22, 2010, at 2:12 PM, Shahzad Bhatti wrote:
> 
> I will take a look at JFreeChart documentation, but how do I get handle to underlying JFreeChart object as it's all abstracted in the ChartView class?
> Thanks.
> 
> 
> On Oct 22, 2010, at 10:05 AM, Greg Brown wrote:
> 
> Not sure - you'll have to look at the JFreeChart docs for that.
> 
> On Oct 22, 2010, at 12:57 PM, Shahzad Bhatti wrote:
> 
> I am using pivot-chart and jfreechart to generate a bar chart, where the labels that are truncating. Is it possible to show labels vertically? Thanks.
> 
> 
> ______________________________________________
> 
> See  http://www.peak6.com/email_disclaimer.php
> for terms and conditions related to this email
> 
> 
> 
> 


Re: Vertical label for bar chart

Posted by Shahzad Bhatti <sb...@peak6.com>.
I found an example of vertical label (with angle) at http://left.subtree.org/2007/08/14/rotate-labels-jfreechart/. It's using axis property to change the angle, e.g.

CategoryPlot plot = (CategoryPlot)chart.getPlot();
37              CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
38              xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
39


On Oct 22, 2010, at 11:15 AM, Greg Brown wrote:

Ah - good question. I don't think you can currently do that. However, if you can figure out how to do this via the JFreeChart API, maybe we can add a style to allow you to specify it via the chart skin.

On Oct 22, 2010, at 2:12 PM, Shahzad Bhatti wrote:

I will take a look at JFreeChart documentation, but how do I get handle to underlying JFreeChart object as it's all abstracted in the ChartView class?
Thanks.


On Oct 22, 2010, at 10:05 AM, Greg Brown wrote:

Not sure - you'll have to look at the JFreeChart docs for that.

On Oct 22, 2010, at 12:57 PM, Shahzad Bhatti wrote:

I am using pivot-chart and jfreechart to generate a bar chart, where the labels that are truncating. Is it possible to show labels vertically? Thanks.


______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email





Re: Vertical label for bar chart

Posted by Greg Brown <gk...@mac.com>.
Ah - good question. I don't think you can currently do that. However, if you can figure out how to do this via the JFreeChart API, maybe we can add a style to allow you to specify it via the chart skin.

On Oct 22, 2010, at 2:12 PM, Shahzad Bhatti wrote:

> I will take a look at JFreeChart documentation, but how do I get handle to underlying JFreeChart object as it's all abstracted in the ChartView class?
> Thanks.
> 
> 
> On Oct 22, 2010, at 10:05 AM, Greg Brown wrote:
> 
>> Not sure - you'll have to look at the JFreeChart docs for that.
>> 
>> On Oct 22, 2010, at 12:57 PM, Shahzad Bhatti wrote:
>> 
>>> I am using pivot-chart and jfreechart to generate a bar chart, where the labels that are truncating. Is it possible to show labels vertically? Thanks.
>>> 
>>> 
>>> ______________________________________________
>>> 
>>> See  http://www.peak6.com/email_disclaimer.php
>>> for terms and conditions related to this email
>> 
> 


Re: Vertical label for bar chart

Posted by Shahzad Bhatti <sb...@peak6.com>.
I will take a look at JFreeChart documentation, but how do I get handle to underlying JFreeChart object as it's all abstracted in the ChartView class?
Thanks.


On Oct 22, 2010, at 10:05 AM, Greg Brown wrote:

> Not sure - you'll have to look at the JFreeChart docs for that.
> 
> On Oct 22, 2010, at 12:57 PM, Shahzad Bhatti wrote:
> 
>> I am using pivot-chart and jfreechart to generate a bar chart, where the labels that are truncating. Is it possible to show labels vertically? Thanks.
>> 
>> 
>> ______________________________________________
>> 
>> See  http://www.peak6.com/email_disclaimer.php
>> for terms and conditions related to this email
> 


Re: Vertical label for bar chart

Posted by Greg Brown <gk...@mac.com>.
Not sure - you'll have to look at the JFreeChart docs for that.

On Oct 22, 2010, at 12:57 PM, Shahzad Bhatti wrote:

> I am using pivot-chart and jfreechart to generate a bar chart, where the labels that are truncating. Is it possible to show labels vertically? Thanks.
> 
> 
> ______________________________________________
> 
> See  http://www.peak6.com/email_disclaimer.php
> for terms and conditions related to this email


Vertical label for bar chart

Posted by Shahzad Bhatti <sb...@peak6.com>.
I am using pivot-chart and jfreechart to generate a bar chart, where the labels that are truncating. Is it possible to show labels vertically? Thanks.


______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

RE: To build a TablePane

Posted by Jérôme Serré <je...@gmail.com>.
Thank you very much

-----Message d'origine-----
De : Greg Brown [mailto:gkbrown@mac.com] 
Envoyé : vendredi 22 octobre 2010 19:16
À : user@pivot.apache.org
Objet : Re: To build a TablePane

You just need to call setView() on the ScrollPane, passing your TablePane
instance. You don't need to call repaint().

On Oct 22, 2010, at 1:11 PM, Jérôme Serré wrote:

> I would like put it in the view and refresh the screen
> 
> 
> In code :
> tp = new TablePane();
> fillTablePane(tb);
> sp.add(tp);
> sp.repaint(); or window.repaint();
> ????
> 
> 
> The wtkx:
> <Window>
> ..../...
> <ScrollPane wtkx:id="sp" verticalScrollBarPolicy="fill_to_capacity"
> horizontalScrollBarPolicy="fill">
> 	<view> 
> 		[The location of the TablePane]
> 	</view>
> </ScrollPane>
> ..../....
> <Window>
> 
> 
> 
> -----Message d'origine-----
> De : Greg Brown [mailto:gkbrown@mac.com] 
> Envoyé : vendredi 22 octobre 2010 18:47
> À : user@pivot.apache.org
> Objet : Re: To build a TablePane
> 
> Can you be a little more specific?
> 
> On Oct 22, 2010, at 12:42 PM, Jérôme Serré wrote:
> 
>> The last question Greg.
>> When I create a new Component, how I do to display it in the windows.
>> 
>> Thank you
>> Jérôme
>> 
>> -----Message d'origine-----
>> De : Greg Brown [mailto:gkbrown@mac.com] 
>> Envoyé : vendredi 22 octobre 2010 14:37
>> À : user@pivot.apache.org
>> Objet : Re: To build a TablePane
>> 
>> I think I see the problem. When an instance of TablePane.Row is created,
> it
>> is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls
>> update() on the row, you get an IndexOutOfBounds exception because there
> is
>> no cell at that index to update.
>> 
>> I had actually forgotten about this method, and it should probably be
>> removed from the platform for this reason. The best way to construct a
>> TablePane dynamically is to create all of your columns, then use the
add()
>> method to create and populate the rows:
>> 
>> 
>>   TablePane tablePane = new TablePane();
>> 
>>   // Add 3 columns
>>   TablePane.ColumnSequence columns = tablePane.getColumns();
>>   columns.add(new TablePane.Column());
>>   columns.add(new TablePane.Column());
>>   columns.add(new TablePane.Column());
>> 
>>   TablePane.RowSequence rows = tablePane.getRows();
>> 
>>   for (int i = 0; i < ROW_COUNT; i++) {
>>       TablePane.Row row = new TablePane.Row();
>>       rows.add(row);
>> 
>>       for (int j = 0; j < columns.getLength(); j++) {
>>           // Add cell for column j
>>       }
>>   }
>> 
>> G
>> 
>> On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:
>> 
>>> Hello,
>>> 
>>> 
>>> 
>>> I try to build a TablePane dynamically but it doesn’t work !
>>> 
>>> As if the table had no rows and no columns.
>>> 
>>> Someone could help me to find the error.
>>> 
>>> Thanks
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Trace : 
>>> 
>>> nbCol: 3
>>> 
>>> nbLigne: 4
>>> 
>>> Rows: 4
>>> 
>>> Columns: 3
>>> 
>>> i: 2
>>> 
>>> j: 1
>>> 
>>> and the error : 
>>> 
>>> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
>>> 
>>>                      at
>>> 
>> 
>
org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
>>> 
>>>                      at
>>> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
>>> 
>>>                      at
>>> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
>>> 
>>>                      at
>>> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
>>> 
>>>                      at
>>> applet.Principale.buildHautDroit(Principale.java:552)
>>> 
>>> 
>>> 
>>> TablePane hautDroit = new TablePane();
>>> 
>>> int nbCol = cb.getNbColonne();
>>> 
>>> int nbLigne = cb.getNbLigne();
>>> 
>>> 
>>> 
>>> System.out.println("nbCol: " + nbCol);
>>> 
>>> System.out.println("nbLigne: " + nbLigne);
>>> 
>>> 
>>> 
>>> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
>>> TablePane.Column(1, true)); }
>>> 
>>> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new
>> TablePane.Row(1,
>>> true)); }
>>> 
>>> 
>>> 
>>> System.out.println("Rows: " + hautDroit.getRows().getLength());
>>> 
>>> System.out.println("Columns: " + hautDroit.getColumns().getLength());
>>> 
>>> 
>>> 
>>> ImageView im;
>>> 
>>> for (int i=0; i<nbLigne; i++) {
>>> 
>>> for (int j=0; j<nbCol; j++) {
>>> 
>>>            if (cb.getCase(i, j)!=null) {
>>> 
>>> System.out.println("i: " + i);
>>> 
>>>                   System.out.println("j: " + j);
>>> 
>>>                  im = new ImageView(Image.load(cb.getCase(i,
>>> j).getVin().getImgCouleur()));
>>> 
>>>                  im.getUserData().put(String.valueOf(i) +
>>> String.valueOf(j), cb.getCase(i, j));
>>> 
>>>     ==è Error    hautDroit.setCellComponent(i, j, im);          
>>> 
>>>            }
>>> 
>>>     }
>>> 
>>> }
>>> 
>>> 
>>> 
>>> --
>>> 
>>> Cordialement
>>> 
>>> Jérôme Serré
>>> 
>>> 
>>> 
>>> 
>> 
> 


Re: To build a TablePane

Posted by Greg Brown <gk...@mac.com>.
You just need to call setView() on the ScrollPane, passing your TablePane instance. You don't need to call repaint().

On Oct 22, 2010, at 1:11 PM, Jérôme Serré wrote:

> I would like put it in the view and refresh the screen
> 
> 
> In code :
> tp = new TablePane();
> fillTablePane(tb);
> sp.add(tp);
> sp.repaint(); or window.repaint();
> ????
> 
> 
> The wtkx:
> <Window>
> ..../...
> <ScrollPane wtkx:id="sp" verticalScrollBarPolicy="fill_to_capacity"
> horizontalScrollBarPolicy="fill">
> 	<view> 
> 		[The location of the TablePane]
> 	</view>
> </ScrollPane>
> ..../....
> <Window>
> 
> 
> 
> -----Message d'origine-----
> De : Greg Brown [mailto:gkbrown@mac.com] 
> Envoyé : vendredi 22 octobre 2010 18:47
> À : user@pivot.apache.org
> Objet : Re: To build a TablePane
> 
> Can you be a little more specific?
> 
> On Oct 22, 2010, at 12:42 PM, Jérôme Serré wrote:
> 
>> The last question Greg.
>> When I create a new Component, how I do to display it in the windows.
>> 
>> Thank you
>> Jérôme
>> 
>> -----Message d'origine-----
>> De : Greg Brown [mailto:gkbrown@mac.com] 
>> Envoyé : vendredi 22 octobre 2010 14:37
>> À : user@pivot.apache.org
>> Objet : Re: To build a TablePane
>> 
>> I think I see the problem. When an instance of TablePane.Row is created,
> it
>> is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls
>> update() on the row, you get an IndexOutOfBounds exception because there
> is
>> no cell at that index to update.
>> 
>> I had actually forgotten about this method, and it should probably be
>> removed from the platform for this reason. The best way to construct a
>> TablePane dynamically is to create all of your columns, then use the add()
>> method to create and populate the rows:
>> 
>> 
>>   TablePane tablePane = new TablePane();
>> 
>>   // Add 3 columns
>>   TablePane.ColumnSequence columns = tablePane.getColumns();
>>   columns.add(new TablePane.Column());
>>   columns.add(new TablePane.Column());
>>   columns.add(new TablePane.Column());
>> 
>>   TablePane.RowSequence rows = tablePane.getRows();
>> 
>>   for (int i = 0; i < ROW_COUNT; i++) {
>>       TablePane.Row row = new TablePane.Row();
>>       rows.add(row);
>> 
>>       for (int j = 0; j < columns.getLength(); j++) {
>>           // Add cell for column j
>>       }
>>   }
>> 
>> G
>> 
>> On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:
>> 
>>> Hello,
>>> 
>>> 
>>> 
>>> I try to build a TablePane dynamically but it doesn’t work !
>>> 
>>> As if the table had no rows and no columns.
>>> 
>>> Someone could help me to find the error.
>>> 
>>> Thanks
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Trace : 
>>> 
>>> nbCol: 3
>>> 
>>> nbLigne: 4
>>> 
>>> Rows: 4
>>> 
>>> Columns: 3
>>> 
>>> i: 2
>>> 
>>> j: 1
>>> 
>>> and the error : 
>>> 
>>> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
>>> 
>>>                      at
>>> 
>> 
> org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
>>> 
>>>                      at
>>> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
>>> 
>>>                      at
>>> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
>>> 
>>>                      at
>>> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
>>> 
>>>                      at
>>> applet.Principale.buildHautDroit(Principale.java:552)
>>> 
>>> 
>>> 
>>> TablePane hautDroit = new TablePane();
>>> 
>>> int nbCol = cb.getNbColonne();
>>> 
>>> int nbLigne = cb.getNbLigne();
>>> 
>>> 
>>> 
>>> System.out.println("nbCol: " + nbCol);
>>> 
>>> System.out.println("nbLigne: " + nbLigne);
>>> 
>>> 
>>> 
>>> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
>>> TablePane.Column(1, true)); }
>>> 
>>> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new
>> TablePane.Row(1,
>>> true)); }
>>> 
>>> 
>>> 
>>> System.out.println("Rows: " + hautDroit.getRows().getLength());
>>> 
>>> System.out.println("Columns: " + hautDroit.getColumns().getLength());
>>> 
>>> 
>>> 
>>> ImageView im;
>>> 
>>> for (int i=0; i<nbLigne; i++) {
>>> 
>>> for (int j=0; j<nbCol; j++) {
>>> 
>>>            if (cb.getCase(i, j)!=null) {
>>> 
>>> System.out.println("i: " + i);
>>> 
>>>                   System.out.println("j: " + j);
>>> 
>>>                  im = new ImageView(Image.load(cb.getCase(i,
>>> j).getVin().getImgCouleur()));
>>> 
>>>                  im.getUserData().put(String.valueOf(i) +
>>> String.valueOf(j), cb.getCase(i, j));
>>> 
>>>     ==è Error    hautDroit.setCellComponent(i, j, im);          
>>> 
>>>            }
>>> 
>>>     }
>>> 
>>> }
>>> 
>>> 
>>> 
>>> --
>>> 
>>> Cordialement
>>> 
>>> Jérôme Serré
>>> 
>>> 
>>> 
>>> 
>> 
> 


RE: To build a TablePane

Posted by Jérôme Serré <je...@gmail.com>.
I would like put it in the view and refresh the screen


In code :
tp = new TablePane();
fillTablePane(tb);
sp.add(tp);
sp.repaint(); or window.repaint();
????


The wtkx:
<Window>
..../...
<ScrollPane wtkx:id="sp" verticalScrollBarPolicy="fill_to_capacity"
horizontalScrollBarPolicy="fill">
	<view> 
		[The location of the TablePane]
	</view>
</ScrollPane>
..../....
<Window>



-----Message d'origine-----
De : Greg Brown [mailto:gkbrown@mac.com] 
Envoyé : vendredi 22 octobre 2010 18:47
À : user@pivot.apache.org
Objet : Re: To build a TablePane

Can you be a little more specific?

On Oct 22, 2010, at 12:42 PM, Jérôme Serré wrote:

> The last question Greg.
> When I create a new Component, how I do to display it in the windows.
> 
> Thank you
> Jérôme
> 
> -----Message d'origine-----
> De : Greg Brown [mailto:gkbrown@mac.com] 
> Envoyé : vendredi 22 octobre 2010 14:37
> À : user@pivot.apache.org
> Objet : Re: To build a TablePane
> 
> I think I see the problem. When an instance of TablePane.Row is created,
it
> is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls
> update() on the row, you get an IndexOutOfBounds exception because there
is
> no cell at that index to update.
> 
> I had actually forgotten about this method, and it should probably be
> removed from the platform for this reason. The best way to construct a
> TablePane dynamically is to create all of your columns, then use the add()
> method to create and populate the rows:
> 
> 
>    TablePane tablePane = new TablePane();
> 
>    // Add 3 columns
>    TablePane.ColumnSequence columns = tablePane.getColumns();
>    columns.add(new TablePane.Column());
>    columns.add(new TablePane.Column());
>    columns.add(new TablePane.Column());
> 
>    TablePane.RowSequence rows = tablePane.getRows();
> 
>    for (int i = 0; i < ROW_COUNT; i++) {
>        TablePane.Row row = new TablePane.Row();
>        rows.add(row);
> 
>        for (int j = 0; j < columns.getLength(); j++) {
>            // Add cell for column j
>        }
>    }
> 
> G
> 
> On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:
> 
>> Hello,
>> 
>> 
>> 
>> I try to build a TablePane dynamically but it doesn’t work !
>> 
>> As if the table had no rows and no columns.
>> 
>> Someone could help me to find the error.
>> 
>> Thanks
>> 
>> 
>> 
>> 
>> 
>> Trace : 
>> 
>> nbCol: 3
>> 
>> nbLigne: 4
>> 
>> Rows: 4
>> 
>> Columns: 3
>> 
>> i: 2
>> 
>> j: 1
>> 
>> and the error : 
>> 
>> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
>> 
>>                       at
>> 
>
org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
>> 
>>                       at
>> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
>> 
>>                       at
>> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
>> 
>>                       at
>> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
>> 
>>                       at
>> applet.Principale.buildHautDroit(Principale.java:552)
>> 
>> 
>> 
>> TablePane hautDroit = new TablePane();
>> 
>> int nbCol = cb.getNbColonne();
>> 
>> int nbLigne = cb.getNbLigne();
>> 
>> 
>> 
>> System.out.println("nbCol: " + nbCol);
>> 
>> System.out.println("nbLigne: " + nbLigne);
>> 
>> 
>> 
>> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
>> TablePane.Column(1, true)); }
>> 
>> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new
> TablePane.Row(1,
>> true)); }
>> 
>> 
>> 
>> System.out.println("Rows: " + hautDroit.getRows().getLength());
>> 
>> System.out.println("Columns: " + hautDroit.getColumns().getLength());
>> 
>> 
>> 
>> ImageView im;
>> 
>> for (int i=0; i<nbLigne; i++) {
>> 
>> for (int j=0; j<nbCol; j++) {
>> 
>>             if (cb.getCase(i, j)!=null) {
>> 
>> System.out.println("i: " + i);
>> 
>>                    System.out.println("j: " + j);
>> 
>>                   im = new ImageView(Image.load(cb.getCase(i,
>> j).getVin().getImgCouleur()));
>> 
>>                   im.getUserData().put(String.valueOf(i) +
>> String.valueOf(j), cb.getCase(i, j));
>> 
>>      ==è Error    hautDroit.setCellComponent(i, j, im);          
>> 
>>             }
>> 
>>      }
>> 
>> }
>> 
>> 
>> 
>> --
>> 
>> Cordialement
>> 
>> Jérôme Serré
>> 
>> 
>> 
>> 
> 


Re: To build a TablePane

Posted by Greg Brown <gk...@mac.com>.
Can you be a little more specific?

On Oct 22, 2010, at 12:42 PM, Jérôme Serré wrote:

> The last question Greg.
> When I create a new Component, how I do to display it in the windows.
> 
> Thank you
> Jérôme
> 
> -----Message d'origine-----
> De : Greg Brown [mailto:gkbrown@mac.com] 
> Envoyé : vendredi 22 octobre 2010 14:37
> À : user@pivot.apache.org
> Objet : Re: To build a TablePane
> 
> I think I see the problem. When an instance of TablePane.Row is created, it
> is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls
> update() on the row, you get an IndexOutOfBounds exception because there is
> no cell at that index to update.
> 
> I had actually forgotten about this method, and it should probably be
> removed from the platform for this reason. The best way to construct a
> TablePane dynamically is to create all of your columns, then use the add()
> method to create and populate the rows:
> 
> 
>    TablePane tablePane = new TablePane();
> 
>    // Add 3 columns
>    TablePane.ColumnSequence columns = tablePane.getColumns();
>    columns.add(new TablePane.Column());
>    columns.add(new TablePane.Column());
>    columns.add(new TablePane.Column());
> 
>    TablePane.RowSequence rows = tablePane.getRows();
> 
>    for (int i = 0; i < ROW_COUNT; i++) {
>        TablePane.Row row = new TablePane.Row();
>        rows.add(row);
> 
>        for (int j = 0; j < columns.getLength(); j++) {
>            // Add cell for column j
>        }
>    }
> 
> G
> 
> On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:
> 
>> Hello,
>> 
>> 
>> 
>> I try to build a TablePane dynamically but it doesn’t work !
>> 
>> As if the table had no rows and no columns.
>> 
>> Someone could help me to find the error.
>> 
>> Thanks
>> 
>> 
>> 
>> 
>> 
>> Trace : 
>> 
>> nbCol: 3
>> 
>> nbLigne: 4
>> 
>> Rows: 4
>> 
>> Columns: 3
>> 
>> i: 2
>> 
>> j: 1
>> 
>> and the error : 
>> 
>> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
>> 
>>                       at
>> 
> org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
>> 
>>                       at
>> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
>> 
>>                       at
>> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
>> 
>>                       at
>> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
>> 
>>                       at
>> applet.Principale.buildHautDroit(Principale.java:552)
>> 
>> 
>> 
>> TablePane hautDroit = new TablePane();
>> 
>> int nbCol = cb.getNbColonne();
>> 
>> int nbLigne = cb.getNbLigne();
>> 
>> 
>> 
>> System.out.println("nbCol: " + nbCol);
>> 
>> System.out.println("nbLigne: " + nbLigne);
>> 
>> 
>> 
>> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
>> TablePane.Column(1, true)); }
>> 
>> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new
> TablePane.Row(1,
>> true)); }
>> 
>> 
>> 
>> System.out.println("Rows: " + hautDroit.getRows().getLength());
>> 
>> System.out.println("Columns: " + hautDroit.getColumns().getLength());
>> 
>> 
>> 
>> ImageView im;
>> 
>> for (int i=0; i<nbLigne; i++) {
>> 
>> for (int j=0; j<nbCol; j++) {
>> 
>>             if (cb.getCase(i, j)!=null) {
>> 
>> System.out.println("i: " + i);
>> 
>>                    System.out.println("j: " + j);
>> 
>>                   im = new ImageView(Image.load(cb.getCase(i,
>> j).getVin().getImgCouleur()));
>> 
>>                   im.getUserData().put(String.valueOf(i) +
>> String.valueOf(j), cb.getCase(i, j));
>> 
>>      ==è Error    hautDroit.setCellComponent(i, j, im);          
>> 
>>             }
>> 
>>      }
>> 
>> }
>> 
>> 
>> 
>> --
>> 
>> Cordialement
>> 
>> Jérôme Serré
>> 
>> 
>> 
>> 
> 


RE: To build a TablePane

Posted by Jérôme Serré <je...@gmail.com>.
The last question Greg.
When I create a new Component, how I do to display it in the windows.

Thank you
Jérôme

-----Message d'origine-----
De : Greg Brown [mailto:gkbrown@mac.com] 
Envoyé : vendredi 22 octobre 2010 14:37
À : user@pivot.apache.org
Objet : Re: To build a TablePane

I think I see the problem. When an instance of TablePane.Row is created, it
is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls
update() on the row, you get an IndexOutOfBounds exception because there is
no cell at that index to update.

I had actually forgotten about this method, and it should probably be
removed from the platform for this reason. The best way to construct a
TablePane dynamically is to create all of your columns, then use the add()
method to create and populate the rows:


    TablePane tablePane = new TablePane();

    // Add 3 columns
    TablePane.ColumnSequence columns = tablePane.getColumns();
    columns.add(new TablePane.Column());
    columns.add(new TablePane.Column());
    columns.add(new TablePane.Column());
    
    TablePane.RowSequence rows = tablePane.getRows();

    for (int i = 0; i < ROW_COUNT; i++) {
        TablePane.Row row = new TablePane.Row();
        rows.add(row);
        
        for (int j = 0; j < columns.getLength(); j++) {
            // Add cell for column j
        }
    }

G

On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:

> Hello,
> 
> 
> 
> I try to build a TablePane dynamically but it doesn’t work !
> 
> As if the table had no rows and no columns.
> 
> Someone could help me to find the error.
> 
> Thanks
> 
> 
> 
> 
> 
> Trace : 
> 
> nbCol: 3
> 
> nbLigne: 4
> 
> Rows: 4
> 
> Columns: 3
> 
> i: 2
> 
> j: 1
> 
> and the error : 
> 
> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
> 
>                        at
>
org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
> 
>                        at
> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
> 
>                        at
> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
> 
>                        at
> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
> 
>                        at
> applet.Principale.buildHautDroit(Principale.java:552)
> 
> 
> 
> TablePane hautDroit = new TablePane();
> 
> int nbCol = cb.getNbColonne();
> 
> int nbLigne = cb.getNbLigne();
> 
> 
> 
> System.out.println("nbCol: " + nbCol);
> 
> System.out.println("nbLigne: " + nbLigne);
> 
> 
> 
> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
> TablePane.Column(1, true)); }
> 
> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new
TablePane.Row(1,
> true)); }
> 
> 
> 
> System.out.println("Rows: " + hautDroit.getRows().getLength());
> 
> System.out.println("Columns: " + hautDroit.getColumns().getLength());
> 
> 
> 
> ImageView im;
> 
> for (int i=0; i<nbLigne; i++) {
> 
> for (int j=0; j<nbCol; j++) {
> 
>              if (cb.getCase(i, j)!=null) {
> 
> System.out.println("i: " + i);
> 
>                     System.out.println("j: " + j);
> 
>                    im = new ImageView(Image.load(cb.getCase(i,
> j).getVin().getImgCouleur()));
> 
>                    im.getUserData().put(String.valueOf(i) +
> String.valueOf(j), cb.getCase(i, j));
> 
>       ==è Error    hautDroit.setCellComponent(i, j, im);          
> 
>              }
> 
>       }
> 
> }
> 
> 
> 
> --
> 
> Cordialement
> 
> Jérôme Serré
> 
> 
> 
> 


Re: To build a TablePane

Posted by Greg Brown <gk...@mac.com>.
I think I see the problem. When an instance of TablePane.Row is created, it is empty (i.e. it has length 0). Since TablePane#setCellComponent() calls update() on the row, you get an IndexOutOfBounds exception because there is no cell at that index to update.

I had actually forgotten about this method, and it should probably be removed from the platform for this reason. The best way to construct a TablePane dynamically is to create all of your columns, then use the add() method to create and populate the rows:

    TablePane tablePane = new TablePane();

    // Add 3 columns
    TablePane.ColumnSequence columns = tablePane.getColumns();
    columns.add(new TablePane.Column());
    columns.add(new TablePane.Column());
    columns.add(new TablePane.Column());
    
    TablePane.RowSequence rows = tablePane.getRows();

    for (int i = 0; i < ROW_COUNT; i++) {
        TablePane.Row row = new TablePane.Row();
        rows.add(row);
        
        for (int j = 0; j < columns.getLength(); j++) {
            // Add cell for column j
        }
    }

G

On Oct 22, 2010, at 4:29 AM, Jérôme Serré wrote:

> Hello,
> 
> 
> 
> I try to build a TablePane dynamically but it doesn’t work !
> 
> As if the table had no rows and no columns.
> 
> Someone could help me to find the error.
> 
> Thanks
> 
> 
> 
> 
> 
> Trace : 
> 
> nbCol: 3
> 
> nbLigne: 4
> 
> Rows: 4
> 
> Columns: 3
> 
> i: 2
> 
> j: 1
> 
> and the error : 
> 
> java.lang.IndexOutOfBoundsException: index 1 out of bounds.
> 
>                        at
> org.apache.pivot.collections.ArrayList.verifyIndexBounds(ArrayList.java:577)
> 
>                        at
> org.apache.pivot.collections.ArrayList.get(ArrayList.java:346)
> 
>                        at
> org.apache.pivot.wtk.TablePane$Row.update(TablePane.java:221)
> 
>                        at
> org.apache.pivot.wtk.TablePane.setCellComponent(TablePane.java:914)
> 
>                        at
> applet.Principale.buildHautDroit(Principale.java:552)
> 
> 
> 
> TablePane hautDroit = new TablePane();
> 
> int nbCol = cb.getNbColonne();
> 
> int nbLigne = cb.getNbLigne();
> 
> 
> 
> System.out.println("nbCol: " + nbCol);
> 
> System.out.println("nbLigne: " + nbLigne);
> 
> 
> 
> for (int j=0; j<nbCol; j++) { hautDroit.getColumns().add(new
> TablePane.Column(1, true)); }
> 
> for (int i=0; i<nbLigne; i++) { hautDroit.getRows().add(new TablePane.Row(1,
> true)); }
> 
> 
> 
> System.out.println("Rows: " + hautDroit.getRows().getLength());
> 
> System.out.println("Columns: " + hautDroit.getColumns().getLength());
> 
> 
> 
> ImageView im;
> 
> for (int i=0; i<nbLigne; i++) {
> 
> for (int j=0; j<nbCol; j++) {
> 
>              if (cb.getCase(i, j)!=null) {
> 
> System.out.println("i: " + i);
> 
>                     System.out.println("j: " + j);
> 
>                    im = new ImageView(Image.load(cb.getCase(i,
> j).getVin().getImgCouleur()));
> 
>                    im.getUserData().put(String.valueOf(i) +
> String.valueOf(j), cb.getCase(i, j));
> 
>       ==è Error    hautDroit.setCellComponent(i, j, im);          
> 
>              }
> 
>       }
> 
> }
> 
> 
> 
> --
> 
> Cordialement
> 
> Jérôme Serré
> 
> 
> 
>