aspose file tools*
The moose likes Java Micro Edition and the fly likes How to add Button to J2ME Table component..? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to add Button to J2ME Table component..?" Watch "How to add Button to J2ME Table component..?" New topic
Author

How to add Button to J2ME Table component..?

lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Hi everybody,

I am using LWUIT for creating one midlet application.I am able to create table but it is displaying only string..whenevre i am trying to add any Comonent(Lable,Button etc) it is displaying like this "[Button height=0 width=0 ..]"..kindly help me if anyone solve this. I am using below code for creating table

TableModel model = new DefaultTableModel(new String[] {"Col 1", "Col 2"}, new Object[][] {
{"Row 1", new Button("Click Me")},
{"Row 2", new Button("Click me")}
}) {
public boolean isCellEditable(int row, int col) {
return col != 0;
}
};
Table table = new Table(model);
table.setScrollableX(true);

Thanks and Regards,
Lokesh Kumar Pattajoshi
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

You're confusing the Model, View, and Controller.

To put a button in a table cell, you have to add a button control to the View definition. But you're attempting to add it to the Model definition.

In MVC, the View and the Model both have trees that mirror each other's structure. Except that in the View tree, you have the control definitions and in the Model tree, you have their corresponding data values.


Customer surveys are for companies who didn't pay proper attention to begin with.
lokesh pattajoshi
Ranch Hand

Joined: Jul 29, 2009
Posts: 130
Hi Holloway,

Thanks a lot for your reply i am new to j2me so not able to identify Model,View and Architecture ..even i have tried to add Component into Table by using addComponent(1,new Button("Clickl")) method of Table class but it did not show anything to me.Kindly tell me where and how to add Component to Table..i have sent a lot of time but not getting any solutions.

Thanks and Regards,
Lokesh
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Unfortunately, this isn't something that I can explain briefly. However, there are a lot of good Computer Science books that explain how MVC works, since it's the basis of almost all modern-day GUIs.

I think I recall seeing some J2ME tutorials on the Sun website that had dropdown menu controls in table rows. Or it may have been in the regular JDK Swing tutorials.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add Button to J2ME Table component..?