I have a list on LWUIT form. I want to add background image to this form. I try using the following piece of code. The image is being set in background but the list distorts while scrolling.
categoryList=new List(categories.categoryVector);
categoryList.setListCellRenderer(new CategoryListCellRenderer());
Image img=parentMIDlet.constants.getBgImage();
//img=img.scaled(this.getPreferredW(), this.getPreferredH());
getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_ALIGNED);
getStyle().setBackgroundAlignment(Style.BACKGROUND_IMAGE_ALIGN_CENTER);
getStyle().setBgImage(img);
//getStyle().setBgPainter(new ImagePainter(img));
addComponent(BorderLayout.CENTER,categoryList);
categoryList.isScrollableY();
categoryList.setFixedSelection(List.FIXED_NONE);
categoryList.addActionListener(new CategoryListActionListener(mainMIDlet,categoryList));
If you are using 1.5 or newer you should use:
getStyle().setBackgroundType(Style.BACKGROUND_IMAGE_ALIGNED_CENTER);
Make sure the list bg transparency is set to 0 for both selected and unselected styles. Make sure the parent form is set to scrollable false.
Related
i am making a java desktop application using javafx. For gui building i am using scene builder 2.0.
Everything is just perfect as expected just 1 thing. I want to customize the buttons. i want to assign a custom graphic to a button.
When i use [button.setgraphic(node)] , this statement set the new graphic to the button but default graphic of button also remains present as well.
I just want to remove the default graphic and then want to assign the new (custom) garaphic to a control like buttons and radio buttons in javafx. 1 thing again i must tell that i am using scene builder for building gui.
How can i achieve this ?
thanks in advance....
Below is the screen-shot of current occuring situation, .....
Here i have made a button using javafx scene builder , and then in the controller of the fxml file (.java file) i am trying to set the image (shown in orange box in snapshot) to that button by using setGraphics property of button ..... i just need that button to be of following shape ...
You'd better customize your button via CSS. Here goes tutorial. What you are trying to do is to modify button picture (which is empty by default). I guess this wasn't your exact purpose.
button.setGraphic(null)
// worked for me.
I am displaying the main form in Box Layout.In that box layout,taken Label in another container which has been set as border layout. Now this container is added to main form.
following is my code :-
lblversion=new Label((String)keyvalues.get("lbl_versionnumber"));
lblversion.setAlignment(lblversion.RIGHT);
lblversion.setVerticalAlignment(lblversion.BOTTOM);
Container row0= new Container(new BorderLayout());
row0.addComponent(BorderLayout.SOUTH,lblversion);
this.addComponent(row0);
Now my problem is that i want to show label at bottom of the screen,but it shows after all the components have been added in form (not at bottom).
I have also attached image.. you can see it and get idea of it.
So is there any option to set label at bottom of the screen in J2ME with LWUIT ?
If any one has idea,please help me.
Set Main Form as Border Layout and keep all components in 1 container which should be BoxLayout and then put these container in main Form with Given Attribute of BorderLayout
And Remove Container from label and insert directly label to main form as such it has been given BorderLayout so add your Label in this Format and all Other components
this.addComponent(BorderLayout.SOUTH,lblversion);
I want to to change the header color of nokia lwuit based full touch form and i have tried setTitleComponent method but it is not working. Please also check the following link
http://projects.developer.nokia.com/LWUIT_for_Series_40/wiki/UsingSeries40FullTouchFeatures
in which it is mentioned we cannot style the header but is it means we cannot change the bgcolor as well or put custom images in the header?
Note that when using LWUIT for Series 40 port, the default way of running LWUIT apps is a normal-size canvas in Series 40 full touch devices. Thus the Series 40 chrome shows on top of canvas. And there is no way of customising it (other than the title text).
If you want to provide branding elements to the title, the options are:
1. create an additional lable below the Series 40 headerbar
2. run the application in full-screen. We are planning to create a high-level API for this but currently it is already possible using the following trick:
((GameCanvas) (javax.microedition.lcdui.Display.getDisplay(this)).getCurrent()).setFullScreenMode(true);
In the latter option you will of course lose the Series 40 full touch layout.
Use lwuit source, you can change method visibility if required, this is example what i used to use gradient color
form.getTitleComponent().getStyle().setBackgroundType(Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL);
form.getTitleComponent().getStyle().setBackgroundGradientEndColor(Color.GRADIENT_END);
form.getTitleComponent().getStyle().setBackgroundGradientStartColor(Color.GRADIENT_START);
form.getTitleComponent().getStyle().setFgColor(Color.WHITE);
form.getTitleComponent().getStyle().setPadding(10,10,0,0);
form.getTitleComponent().getStyle().setFont(font);
Here Color is my custom class that is used for color code, you can use your one.
I want to add large string content to a container dynamically.
There are 60 different contents(strings) to be displayed in this container.
To add the string to container, I am adding a TextArea(empty border with 100% transparency).
The problem is that TextArea offers scroll and I do not want it to scroll. Instead I want to grow(increase height) according to content. I am unable to achieve this.
Can you help me out with this?
Or can I use any other component for the purpose?
I am using LWUIT with J2ME.
You can derive text area and return false for isScrollableY() although it should generally work seamlessly even if you don't do that (since your parent layout is scrollable). Is it possible you changed the text area and don't revalidate the parent form on the EDT?
There are problems with text area layout when it is modified by a separate thread (race condition with the layout code).
First put the TextArea.setSingleLineTextArea(false) , and grow by content true.
I want to know how to create a label that contains two icons, one on each side and set it as the title bar for the form element (LWUIT widgets).
Form has a function to get a titleArea then you can put some components what you want.
Form f = new Form();
Container c = f.getTitleArea();
Label iconLabel1 = new Label("leftIcon");//using Image
Label iconLabel2 = new Label("rightIcon");//using Image
c.addComponent(BorderLayout.WEST, iconLabel1);
c.addComponent(BorderLayout.EAST, iconLabel2);
You can just add a component to the north portion of the screen which is the recommended way that will work properly and won't break for newer versions of LWUIT/Codename One.
When you don't set a title it will just work and you can give it the Title UIID. LWUIT 1.5 and newer have a TitleArea container but I suggest you stay away from it since CodenameOne customizes it quite allot for iOS/Android 4.x etc.
Use the setTitleComponent(Label title) method.
EDIT :
Derive the Label class and implement the paint method where you can use the Graphics method to draw Images and texts. Also set the label's text position to Label.CENTER .