The Source for Java Technology Collaboration
Webmaster Alert: Posting to Jive Forums is currently not working. Estimated time for fix is unknown.

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: Scrolling in different containers

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 17 - Last Post: Nov 26, 2009 4:36 AM by: Chen Fishbein Threads: [ Previous | Next ]
danjose

Posts: 32
Scrolling in different containers
Posted: Nov 16, 2009 8:57 AM
  Click to reply to this thread Reply

Hi,
Here is an issue which I think might be resolved easily with the help of LWUIT experts. I have a form with a borderlayout container, with NORTH set to a header label(Basically a label with column names of a tabular data) , now I have created a Tablelayout container , with the data and attached that to the CENTER of the border layout. Everything looks fine expect the scroll which is a problem I wanted to solve. What I wanted to do is, to make the scroll work on Y direction inside the tableLayout container and if I try to scroll on the X direction, I wanted the parent Container to scroll on X so that the whole header data is visible. I know scroll in LWUIT is based on focus , my Y scroll is working but, irespective of I set the scroll for the parent container it wont scroll in the X direction. Is there a way I can make it scroll on X, without breaking the scroll on Y inside the tablelayout??

One more thing with the TableLayout, it always keep some padding on the rightside of the layout, irrespective of what I set for the padding. Is it by the design??
Thanks

Message was edited by: danjose

danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 17, 2009 6:22 AM   in response to: danjose
  Click to reply to this thread Reply

Anybody can give me some clues on this please.. I'm gonna try a different approach, like creating a TableModel which will use my custom tablelayout .

vprise

Posts: 476
Re: Scrolling in different containers
Posted: Nov 19, 2009 12:44 AM   in response to: danjose
  Click to reply to this thread Reply

I'm not exactly clear on the problem so I'm guessing. Try setting the form to scrollable false then set the table layout container to scorllable on both X and Y axis's. Nested scrolling with different axis might be problematic.

danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 19, 2009 9:10 AM   in response to: vprise
  Click to reply to this thread Reply

Thanks VPrise,
but it still not working. I set the scrollable false for the form and set scrollable true for the table layout container, but what I can see is the text ends up as doted lines towards the right edge of the screen and start scrolls once I selected it. The problem is I have an image (a status display icon) at the end of the text and this is just out of the screen , what I want it to scroll the entire row in x axis so that the user can see all the columns in that and also be able to scroll on the Y direction. I just check out the latest code from SVN to test it but that didnt do much help
here is my code for the table container which is added to the CENTER of the form's borderlayout.
thanks,


private Container createformList(TimeCard[] personInfo,int rows, int cols, int colsize )
{
tableContainer = new Container();
TableLayout layout = new TableLayout(rows, 1);

tableContainer.setLayout(layout);
tableContainer.setUIID("ListGrid");

TableLayout.Constraint titlerowConstraint = null;
TableLayout.Constraint datarowConstraint = null;
Image statusImage = null;
try {
Resources images = TLTimeBerryMIDlet.getResource("images");
statusImage = images.getImage("checkmark.png");
} catch (IOException ex) {
ex.printStackTrace();
}

tableContainer.setFocusable(true);
tableContainer.setScrollable(true);
tableContainer.setSmoothScrolling(true);
final ButtonActionListener bAListner = new ButtonActionListener();
tableContainer.setIsScrollVisible(true);
...contd....

Message was edited by: danjose

danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 19, 2009 9:44 AM   in response to: danjose
  Click to reply to this thread Reply

...contd.....
for(int i = 0; i < personInfo.length ; i++)
{
TimeCard person = personInfo (i);
if(person.getIsTitle() == true)
{
titlerowConstraint = layout.createConstraint();
titlerowConstraint.setHorizontalSpan(1);
titlerowConstraint.setWidthPercentage(100);
Label header = new Label(person.getOrgUnitName());
header.setUIID("LabelHighLight");
header.setAlignment(Label.CENTER);
header.setTextPosition(Label.LEFT);
header.setFocusable(false);
header.setPreferredH(header.getStyle().getFont().getHeight()+2);
tableContainer.addComponent(titlerowConstraint,header);
}
final Button data = new Button();
data.setUIID("TextBeforeRead");
data.getStyle().setBgTransparency(0);
data.setAlignment(Label.LEFT);
data.setTextPosition(Label.LEFT);
data.setFocusable(true);
data.setFocusPainted(true);
data.addActionListener(bAListner);
data.addFocusListener(new

FocusListener( ) {
public void focusGained(Component cmp) {
curfocus = data;
}
public void focusLost(Component cmp) {
curfocus = null;
}
});
datarowConstraint = layout.createConstraint();
datarowConstraint.setHorizontalSpan(1);

String padedText = person.getColumnTextwithPadding(data, person.getTimePeriod(), colsize);
padedText += person.getColumnTextwithPadding(data, person.getName(), colsize);
data.setPreferredH(data.getStyle().getFont().getHeight());
boolean status = person.getIsChecked();
if(status == true)
{
data.setIcon(statusImage);
data.setGap(20);
}
data.setText(padedText);

tableContainer.addComponent(data);
listDataHndlr.put(data, person);

}
tableContainer.setFocus(true);
return tableContainer;
}

danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 20, 2009 9:41 AM   in response to: danjose
  Click to reply to this thread Reply

Someone can help me please.... I did all that's possible to make LWUIT scroll or horizontal axis. I change the top code container to simple box layout with Y axis and added all the buttons and labels to that container with long texts(text size may be more than the screen width) but LUWIT wont scroll on X , once its inside the container where I placed the buttons and labels, as soon as I open the screen and do the scroll , it first scroll to the end (in x direction), after that any key I pressed(even left or right arrows) , the simulator always scroll up and down on the form!!. i disable scrolling,disable end iwth dotted endpoints and disable focus on the main containers and main form, where my list kind of form is attached. All I can see is the list kind of form(boxlayout Y axis) dont have the scroll bar on x and it's not scrolling... Please help!!
thanks

vprise

Posts: 476
Re: Scrolling in different containers
Posted: Nov 21, 2009 10:01 PM   in response to: danjose
  Click to reply to this thread Reply

You are making the container focusable (which doesn't make sense for your use case) and your code is huge making it completely unreadable. I suggest you start small without invoking every possible method within LWUIT.

danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 23, 2009 6:26 AM   in response to: vprise
  Click to reply to this thread Reply

Lets forget about that code , I tried a simple thing and it didn't work. All I want to know is is it possible to scroll on LWUIT in X direction if the component width pass beyond the screen width?? A simple example is , create a container on BoxLayout with Y axis Layout and put 2 labels inside it. If those labels width goes pass beyond the screen width, can I scroll the container to X direction to see content of those labels???? . I know that, the text will scroll (ticker) on the x direction if it's out of the screen size, but what if there a image after the text?? This case is so common if, I'm displaying a table of data, which can have more columns, than the screen width. The option of text tickering wont work because the user cannot see the column names on the right side , if the columns are more than what fits in to the screen. If this possible, can you show me a simple example of how to do this?? I'm working on this since last 2 weeks, and if there is no option to do this in LWUIT, I have to think of another framework.
Thanks

Chen Fishbein
Re: Scrolling in different containers
Posted: Nov 23, 2009 10:05 AM   in response to: danjose
  Click to reply to this thread Reply

Hi,
If you use BoxLayout on Y axis the Container cannot scroll on X axis.
Try adding inside "the BoxLayout on Y" a scrollable x Container with a
few focusable Components

Container c1 = new Container(new BoxLayout(BoxLayout.Y_AXIS));
c1.addComponent(new Button("item1"));
c1.addComponent(new Button("item2"));
...
Container c2 = new Container(new BoxLayout(BoxLayout.X_AXIS));
c2.setScrollable(true);
c2.addComponent(new Button("item1"));
c2.addComponent(new Button("item2"));
c2.addComponent(new Button("item3"));
...
c1.addComponent(c2);

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> Lets forget about that code , I tried a simple thing and it didn't work. All I want to know is is it possible to scroll on LWUIT in X direction if the component width pass beyond the screen width?? A simple example is , create a container on BoxLayout with Y axis Layout and put 2 labels inside it. If those labels width goes pass beyond the screen width, can I scroll the container to X direction to see content of those labels???? . I know that, the text will scroll (ticker) on the x direction if it's out of the screen size, but what if there a image after the text?? This case is so common if, I'm displaying a table of data, which can have more columns, than the screen width. The option of text tickering wont work because the user cannot see the column names on the right side , if the columns are more than what fits in to the screen. If this possible, can you show me a simple example of how to do this?? I'm working on this since last 2 weeks, and if there is no option to do this in LWUIT, I have to think of another framework.
> Thanks
> [Message sent by forum member 'danjose' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=372965
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net


danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 23, 2009 11:01 AM   in response to: Chen Fishbein
  Click to reply to this thread Reply

Hi Chen,
Great to see your response !!!! thanks a lot for the example too. I'm afraid you didn't get what I exactly want to do. I wanted a table like arrangement of row/columns(1 row and n columns), and I want the container to be scrollable on both X axis and Y axis. So I think , I cannot use a X border layout since, it wont arrange my buttons(one button is an entire row , I space out items according to the space designated for each column) as rows. So basically, it is a header label with column names and under that single row buttons which contains data exactly positioned under each column. The problem is once the width of the text goes far beyond the display width, my buttons and the header is getting clipped by the right side of the screen.The question is how do we make it scroll on both directions, not at the same time, but like LEFT<->RIGHT and UP<->DOWN. I tired almost every container, list and layout in LWUIT now and none worked as expected. All of them scroll on Y, but if Y scroll is there, they wont Scroll on X. If I make the parent container scrollable on X, the first time I get it scrolling, the screen shifted a little on the X direction , after that it only scrolls on Y.
Any help will be greatly appreciated guys..
Thanks,
danjose

Chen Fishbein
Re: Scrolling in different containers
Posted: Nov 24, 2009 3:11 AM   in response to: danjose
  Click to reply to this thread Reply

Hi,
I don't think I completely understand what you are trying to achieve, if
all you want is to show a data table use the Table Layout.
It can scroll on both axises.

example:
Form f = new Form("hello");
f.setLayout(new TableLayout(20, 20));
f.setScrollable(true);
for (int i = 0; i < 400; i++) {
f.addComponent(new Button("item"+i));
}
f.show();

lwuit-users@mobileandembedded.org wrote:
> Hi Chen,
> Great to see your response !!!! thanks a lot for the example too. I'm afraid you didn't get what I exactly want to do. I wanted a table like arrangement of row/columns(1 row and n columns), and I want the container to be scrollable on both X axis and Y axis. So I think , I cannot use a X border layout since, it wont arrange my buttons(one button is an entire row , I space out items according to the space designated for each column) as rows. So basically, it is a header label with column names and under that single row buttons which contains data exactly positioned under each column. The problem is once the width of the text goes far beyond the display width, my buttons and the header is getting clipped by the right side of the screen.The question is how do we make it scroll on both directions, not at the same time, but like LEFT<->RIGHT and UP<->DOWN. I tired almost every container, list and layout in LWUIT now and none worked as expected. All of them scroll on Y, but if Y scroll is there, they wont Scroll on X. If I make the parent container scrollable on X, the first time I get it scrolling, the screen shifted a little on the X direction , after that it only scrolls on Y.
> Any help will be greatly appreciated guys..
> Thanks,
> danjose
> [Message sent by forum member 'danjose' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=373033
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net


danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 24, 2009 7:23 AM   in response to: Chen Fishbein
  Click to reply to this thread Reply

Hi Chen,
Then I think there is a bug in LWUIT. I just tried your code and it gives wired results. try to do this
Form f = new Form("hello");
f.setLayout(new TableLayout(20, 1));
f.setScrollable(true);
for (int i = 0; i < 20; i++) {
f.addComponent(new Button("item-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-item"+i));
}
f.show();
if there is only 1 column and the text is too long, the scroll wont work properly. There are 2 issues,
as soon as you start scrolling in any direction the horizontal scroll shift to the right edge of the screen, now you cannot scroll back horizontally.

The vertical scroll is working, but I have seen that if the data is too long(I think longer than the display width) it gets clipped at the width. The button wont show the entire data, instead it starts tickering or get clipped at the edge if tickering turned off.

I use BB simulator 8220 and I have the latest code of LWUIT
Can you please check this , I hope it will get fixed or there is some work around, I'm stuck on this issue since all my screens use tables like above
Thanks

Chen Fishbein
Re: Scrolling in different containers
Posted: Nov 24, 2009 9:41 AM   in response to: danjose
  Click to reply to this thread Reply

Hi,
Ok, now I see your issue.
Try to update the code from svn and check again, I just added the
ability to scroll the Container by pixels(if the Component is larger
then the Container).

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> Hi Chen,
> Then I think there is a bug in LWUIT. I just tried your code and it gives wired results. try to do this
> Form f = new Form("hello");
> f.setLayout(new TableLayout(20, 1));
> f.setScrollable(true);
> for (int i = 0; i < 20; i++) {
> f.addComponent(new Button("item-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-item"+i));
> }
> f.show();
> if there is only 1 column and the text is too long, the scroll wont work properly. There are 2 issues,
> as soon as you start scrolling in any direction the horizontal scroll shift to the right edge of the screen, now you cannot scroll back horizontally.
>
> The vertical scroll is working, but I have seen that if the data is too long(I think longer than the display width) it gets clipped at the width. The button wont show the entire data, instead it starts tickering or get clipped at the edge if tickering turned off.
>
> I use BB simulator 8220 and I have the latest code of LWUIT
> Can you please check this , I hope it will get fixed or there is some work around, I'm stuck on this issue since all my screens use tables like above
> Thanks
> [Message sent by forum member 'danjose' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=373123
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net


danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 24, 2009 11:18 AM   in response to: Chen Fishbein
  Click to reply to this thread Reply

Hi Chen,
You saved my project!!!!!!! thanks a lot!!!!! it works like a charm now.. the scrolling is smooth and now I can scroll the entire table left and right.. appreciate your quick response...
Thanks

danjose

Posts: 32
Re: Scrolling in different containers
Posted: Nov 25, 2009 6:11 AM   in response to: Chen Fishbein
  Click to reply to this thread Reply

Hi Chen,
There is one more minor issue on the fix. If I have less items in the table(number of rows is lesser than what needs to bring up vertical scroll bar) , a scroll on Y-Direction will make the X-axis scroll on each item . if you press down or up scroll, the entries will scroll down, but when the each component got the focus, it auto scroll on that entry in X-direction. This only happen if the vertical scroll bar is not visible, once you have enough entries to fill up the screen , it works fine. My layout is the tablelayout.
Thanks

Chen Fishbein
Re: Scrolling in different containers
Posted: Nov 26, 2009 4:36 AM   in response to: danjose
  Click to reply to this thread Reply

Hi,
Just committed a fix for this.

Chen

lwuit-users@mobileandembedded.org wrote:
> Hi Chen,
> There is one more minor issue on the fix. If I have less items in the table(number of rows is lesser than what needs to bring up vertical scroll bar) , a scroll on Y-Direction will make the X-axis scroll on each item . if you press down or up scroll, the entries will scroll down, but when the each component got the focus, it auto scroll on that entry in X-direction. This only happen if the vertical scroll bar is not visible, once you have enough entries to fill up the screen , it works fine. My layout is the tablelayout.
> Thanks
> [Message sent by forum member 'danjose' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=373311
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net


controllers

Posts: 7
Re: Scrolling in different containers
Posted: Nov 25, 2009 6:02 PM   in response to: Chen Fishbein
  Click to reply to this thread Reply

Scroll bar question I just read this post have been encountered in the successful resolution of
There is a problem:
Through what the data into the form
Form f = new Form ( "hello");
f.setLayout (new TableLayout (20, 1));
f.setScrollable (true);
for (int i = 0; i <20; i + +) (
f.addComponent (new Button ( "item-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-item" + i));
)
This data then traverse when enough will be very time-consuming, is there a simpler way, or inside the method, if the String [] [] put into the form on the inside. Thanks

In the new project, how the properties of some selected does not it? What can replace them!
For example: bgSelectionColor

controllers

Posts: 7
Re: Scrolling in different containers
Posted: Nov 25, 2009 6:23 PM   in response to: controllers
  Click to reply to this thread Reply

hi chen
If the table in a row in Canada focus on the better.
Up and down through the phone's keypad control of the focus line, when the focus moves to the top or the bottom of the screen will scroll the entire table, the focus line is always displayed on the screen above, and then give it the event, this very practical.
Thank you look forward to! ! ! ! !




 XML java.net RSS