FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

SimpleTableModel Refresh and Clear Values

 
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users
View previous topic :: View next topic  
Author Message
ArthurKnight



Joined: 03 Nov 2008
Posts: 19

PostPosted: Mon Dec 01, 2008 6:08 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Hi there!

I have a little problem with SimpleTableModel.

I need to delete the values previously set to the table model. I tryied with setting a empty String[][] then invoke fireTableModelChanged but it keeps the same data.

Code:
    empty = new String[0][3];
    tdDetalle = new SimpleTableModel(empty, columns);
    tdDetalle.fireTableModelChanged();


How can I clear the rows of the TableModel?

Thanks in advance for your time.

Regards,

AC Very Happy
Back to top
View user's profile Send private message
ArthurKnight



Joined: 03 Nov 2008
Posts: 19

PostPosted: Mon Dec 01, 2008 6:55 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Hi there!

I have a little problem with SimpleTableModel.

I need to delete the values previously set to the table model. I tryied with setting a empty String[][] then invoke fireTableModelChanged but it keeps the same data.

Code: empty = new String[0][3];
tdDetalle = new SimpleTableModel(empty, columns);
tdDetalle.fireTableModelChanged();

How can I clear the rows of the TableModel?

Thanks in advance for your time.

Regards,

AC
--
Ing. Arturo Caballero
address-removed ([email]address-removed[/email])
http://www.linkedin.com/in/jacaballero
Back to top
View user's profile Send private message
atom83
Posted via mailing list.





PostPosted: Wed Dec 03, 2008 10:19 am    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

hello!

i have the same problem.

actually it changes the table when I scroll the screen.

how can I make it that it changes the table right away??

thx
thomas

--
View this message in context: http://www.nabble.com/SimpleTableModel-Refresh-and-Clear-Values-tp20778181p20810211.html
Sent from the Netbeans Java Mobile Edition/ME Users (Mobility) mailing list archive at Nabble.com.
Back to top
ArthurKnight



Joined: 03 Nov 2008
Posts: 19

PostPosted: Wed Dec 03, 2008 3:22 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Hi Thomas,

I understand by the docs that the metod fireTableModelChanged of the table model will update the model and the table related will be repainted too.

Hope it helps.

Regards!



On Wed, Dec 3, 2008 at 4:19 AM, atom83 <address-removed ([email]address-removed[/email])> wrote:
Quote:

hello!

i have the same problem.

actually it changes the table when I scroll the screen.

how can I make it that it changes the table right away??

thx
thomas

--
View this message in context: http://www.nabble.com/SimpleTableModel-Refresh-and-Clear-Values-tp20778181p20810211.html
Sent from the Netbeans Java Mobile Edition/ME Users (Mobility) mailing list archive at Nabble.com.




([email]address-removed[/email])
([email]address-removed[/email])






--
Ing. Arturo Caballero
address-removed ([email]address-removed[/email])
http://www.linkedin.com/in/jacaballero
Back to top
View user's profile Send private message
atom83
Posted via mailing list.





PostPosted: Wed Dec 03, 2008 3:49 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Arturo Caballero wrote:
Quote:


the metod fireTableModelChanged of the table
model will update the model and the table related will be repainted too.



thanks for your reply!

I have tried with fireTableModelChanged. without calling this method,
changes arent affected, but with, it makes the changes but doesnt update the
screen till I scroll.
here my code:



Quote:
tableItem = new TableItem(Display.getDisplay(this), "DeviceTable")
tableModel1 = new SimpleTableModel(controlUnit.showDevices(),
new java.lang.String[]{"IP","GPS","Energy"});
tableItem.setModel (tableModel1 );
tableModel1.addTableModelListener(tableItem);


// changing the values
tableModel1.setValues(controlUnit.showDevices());
tableModel1.fireTableModelChanged();


does anyone has an idea?

thx
thomas


--
View this message in context: http://www.nabble.com/SimpleTableModel-Refresh-and-Clear-Values-tp20778181p20815533.html
Sent from the Netbeans Java Mobile Edition/ME Users (Mobility) mailing list archive at Nabble.com.
Back to top
ArthurKnight



Joined: 03 Nov 2008
Posts: 19

PostPosted: Wed Dec 03, 2008 3:57 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Have you tried refreshing the Form with some method? I think there is a hierachy, where you have to refresh first the control that encapsulates other controls.



On Wed, Dec 3, 2008 at 9:49 AM, atom83 <address-removed ([email]address-removed[/email])> wrote:
Quote:


Arturo Caballero wrote:
Quote:


the metod fireTableModelChanged of the table
model will update the model and the table related will be repainted too.




thanks for your reply!

I have tried with fireTableModelChanged. without calling this method,
changes arent affected, but with, it makes the changes but doesnt update the
screen till I scroll.
here my code:



Quote:
tableItem = new TableItem(Display.getDisplay(this), "DeviceTable")
tableModel1 = new SimpleTableModel(controlUnit.showDevices(),
new java.lang.String[]{"IP","GPS","Energy"});
tableItem.setModel (tableModel1 );
tableModel1.addTableModelListener(tableItem);


// changing the values
tableModel1.setValues(controlUnit.showDevices());
tableModel1.fireTableModelChanged();


does anyone has an idea?

thx
thomas


--
View this message in context: http://www.nabble.com/SimpleTableModel-Refresh-and-Clear-Values-tp20778181p20815533.html

Sent from the Netbeans Java Mobile Edition/ME Users (Mobility) mailing list archive at Nabble.com.



([email]address-removed[/email])
([email]address-removed[/email])






--
Ing. Arturo Caballero
address-removed ([email]address-removed[/email])
http://www.linkedin.com/in/jacaballero
Back to top
View user's profile Send private message
atom83
Posted via mailing list.





PostPosted: Wed Dec 03, 2008 4:05 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Arturo Caballero wrote:
Quote:

Have you tried refreshing the Form with some method? I think there is a
hierachy, where you have to refresh first the control that encapsulates
other controls.


I was looking for a refresh or repaint method either in the Form class or
the Display, but couldn't find some??

thx
--
View this message in context: http://www.nabble.com/SimpleTableModel-Refresh-and-Clear-Values-tp20778181p20815867.html
Sent from the Netbeans Java Mobile Edition/ME Users (Mobility) mailing list archive at Nabble.com.
Back to top
Pada



Joined: 18 Jan 2009
Posts: 6
Location: Stellenbosch, South-Africa

PostPosted: Mon Jan 19, 2009 4:14 pm    Post subject: Reply with quote

I think your problem might have been that you didn't initialize your "empty = new String[0][3];" elements! Try iterating through all its elements and set them to "" (null is not acceptible, but a blank String is though).
Another problem might be that you have 0 rows specified for your "empty" String array, try setting that to a value bigger than 0.

if you still have the original reference to the tableModel's values, then you can just iterate through all its elements and set them to "" and then do the tdDetalle.fireTableModelChanged();

eg.


Code:
String[] values = new String[2][2];
values[0][0] = "0,0";
values[0][1] = "0,1";
values[1][0] = "1,0";
values[1][1] = "1,1";
tdDetalle = new SimpleTableModel(values, columns);
// add the table model to an table item & the table item to a form
// that should display the values

// to clear the table again, iterate through the elements and clear them
values[0][0] = "";
values[0][1] = "";
values[1][0] = "";
values[1][1] = "";
tdDetalle.fireTableModelChanged();


I've now found another thread which explains why the table isn't updated by the fireTableModelChanged event: http://forums.netbeans.org/viewtopic.php?t=7649

hope this helps.
Back to top
View user's profile Send private message
ArthurKnight



Joined: 03 Nov 2008
Posts: 19

PostPosted: Mon Jan 19, 2009 4:21 pm    Post subject: SimpleTableModel Refresh and Clear Values Reply with quote

Thanks for you help.

I found the error, this same table was modified by other thread, but it was difficult to debug for me. I was experiencing problems with debugger.

Thanks again for your help.

SimpleTableModel works just fine and is easy to use.

On Mon, Jan 19, 2009 at 10:14 AM, Pada <address-removed ([email]address-removed[/email])> wrote:
Quote:
I think your problem might have been that you didn't initialize your "empty = new String[0][3];" elements! Try iterating through all its elements and set them to "" (null is not acceptible, but a blank String is though).

Another problem might be that you have 0 rows specified for your "empty" String array, try setting that to a value bigger than 0.



if you still have the original reference to the tableModel's values, then you can just iterate through all its elements and set them to "" and then do the tdDetalle.fireTableModelChanged();



eg.






Code:
String[] values = new String[2][2];

values[0][0] = "0,0";

values[0][1] = "0,1";

values[1][0] = "1,0";

values[1][1] = "1,1";

tdDetalle = new SimpleTableModel(values, columns);

// add the table model to an table item & the table item to a form

// that should display the values



// to clear the table again, iterate through the elements and clear them

values[0][0] = "";

values[0][1] = "";

values[1][0] = "";

values[1][1] = "";

tdDetalle.fireTableModelChanged();







hope this helps.






([email]address-removed[/email])
([email]address-removed[/email])




--
Ing. Arturo Caballero
address-removed ([email]address-removed[/email])
http://www.linkedin.com/in/jacaballero
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB