Slider in codenameone - codenameone

Can any one please tell me how i can add slider and moving form in codename one (with sample lines of code) and also want to know are these features supported by all types of devices?
Regards,
Megha

I think you mean how to animate forms changes
Form.setTransitionInAnimator(CommonTransitions.somthing)
Form.setTransitionOutAnimator(CommonTransitions.somthing)
Next, you should handle some "finger slide" event.

To add a slider you can use the following code
Slider jSlider = new Slider();
jSlider.setMaxValue(255);
jSlider.setMinValue(0);
jSlider.setProgress(50); // Set the starting value
jSlider.setEditable(true); // To it works as a slider instead of a progress bar
Now you have created a slider which you can add to your component like you would in Swing. You can type 'jSlider.' in eclipse to find out which other methods you can use, or you can go to the API: http://codenameone.googlecode.com/svn/trunk/CodenameOne/javadoc/com/codename1/ui/Slider.html
I think min/maxValue are selfexplenatory though :)
If you want to open a new form, simply create a new class extending form or do it in code like
Form form = new Form();
form.animate(); // To make it "slide in"
form.show();
Also noteworthy, the slider doesn't work with the lumia skin per default, though you can make it work. I actually asked this question on here as well:
Slider doesn't draw (CodeName One) with Windows phone skin

Related

Touch-to-zoom animation in Codename One

I have an image inside a Codename One Label. I would like to open it to fullscreen after a tap and with an animation zoom, like in this video:
https://stuff.mit.edu/afs/sipb/project/android/docs/training/animation/anim_zoom.mp4
How can I get something similar using Codename One? Thank you for any hint.
You can do two things:
Place the image in a layered layout on the entire form and just animateLayout() the UI. This will produce this effect without moving to a new form. Assuming the image is a ScaleImageLabel.
You can move to a separate Form with a transition that mutates the content of the current form in that way specifically MorphTransition which was designed just for this effect. Make sure to use setName for the component in the source and destination forms so the transition will know which component to morph into which. You can morph multiple components:
MorphTransition m = MorphTransition.create(1200).morph(componentName);

GWT LayoutPanel children events not working

Hi I have an issue with GWT client side where events not being received by widgets when their parent, somewhere along the tree, is using GWT LayoutPanel or any of the Layout containers.
Here is a demonstration with simplified code.
This code works:
LayoutPanel layoutPanel = new LayoutPanel();
layoutPanel.add(new SimplePanel());
layoutPanel.add(new Button("Button1"));
RootLayoutPanel.get().add(layoutPanel);
The button is highlighted on hover, and attached ClickHandler receives events.
However the code below does not. Only change was reverse the add() to layoutPanel order:
LayoutPanel layoutPanel = new LayoutPanel();
layoutPanel.add(new Button("Button1"));
layoutPanel.add(new SimplePanel());
RootLayoutPanel.get().add(layoutPanel);
The button is drawn, but no events are dispatched, not even the ':hover' events are getting through. Inspection of the generated HTML shows the 'button' tag is being generated.
I am using GWT 2.8.2, Google Appengine 1.9.66 and Java 8 (appengine-web.xml configured for version 2 and Java8 JRE).
I have a much more complicated GUI that is having the same issue, I just boiled it down to the above example to demonstrate the problem.
Because you don't specify any layout option to the added widgets, you're actually overlaying them on top of one another, so in the second case the button is behind the simple panel, which is transparent so I doesn't visually hide the button.

Codename One: How to increase height of dialog

I have developed app using Codename one.I want to set specific height of dialog because my text overidden while displaying message in dialog body .what should I do for that?
Thanks in Advance?
I have added image in which first image is original image and second one is cut image which is displaying on screen while using infinite progress bar. my code is "Dialog ipDialog = new InfiniteProgress().showInifiniteBlocking(); ipDialog.Dispose()" I want whole image on screen like original image.
can you help me to solved this ?
You can use the Dialog show method that accepts int values to determine the distance from the edges. But normally this is a matter of the text sizing and dialog construction.
Also make sure you are showing the Dialog from the EDT thread.

Polymer grid in different views

I'm not sure if this is the right place to ask because I dont have any code to show. I'm actually looking for ideas on possible ways to solve my problem.
I have an app that displays the grid on the screen when the media query has a min width of a tablet.
But when the view is in mobile mode I don't want to show the grid. Instead I have a drop down menu which has a grid option. When selected will be show in a paper-dialog (pop up)
The problem is I have to create two grids (vaadin-grid) and show the appropriate one based on the view. Is there a way to have only one grid? Can I put it in a paper-dialog but not pop-out when in tablet and desktop view?
Thanks in advance
If your grid element has every custom property then that is an element in the DOM, so you can move it into the dialog if thats needed using javascript:
let myGrid = this.$$('#myGrid');
let myDialogContent = this.$$('#myDialogContent');
Polymer.dom(myDialogContent).appendChild(myGrid);
Also if you think it a different way, then you can hide the grid outside of the screen and you can slide that in when it's needed like a drawer panel and you dont need to move the element at all in the DOM.
By the way for programming question stackoverflow has the https://softwareengineering.stackexchange.com/ site, but I think it is Ok to send it here.

Hiding a component within a Border-Layout region programatically

I have a border Layout with let's say two regions; center and west. The westregion is added with the splitter param and is collapsible. Now I have a toolbar from which I want to hide/show the west region. I've solved this by calling the toggleTargetCmp() method of the splitter. Well I know, this is a private method and should not be used, but I found no other way to archive this. So far so good. All this works.
But now I want to hide the splitter & placeholder (I fetch the placeholder ownet by using the getCollapseTarget() method of the splitter) if the button in the toolbar gets clicked. I tried it with setVisible(false) which works for the splitter but it didn't work well for the placeholder... after a deeper look onto the placeholder instance I can tell that it is set to hidden: true but it uses the hideMode: 'offsets' by default plus hiddenAnchestor: false which is not documented in the API.
Based on the API docu for hideMode I tried to set it to 'display'
before calling setVisible(false) without any luck, the placeholder still stays visible.
So how can I hide the placholder, too. Or is there even a better way to archive this?
Have you tried hide method? It works exactly as you describe - hides region and splitter.
In my project I do it like this:
panel.hide();
where panel is one of borderPanel items.

Resources