PDA

View Full Version : setBodyStyle() and layout()



g1_
3 Nov 2009, 12:46 AM
Hi quick question.

If want to change the background colour of a ContentPanel, do I just need to do some thing like:


//sets the background color
public void setbgcolor(String color) {
color = color.trim() ;
if ( color.charAt(0) != '#' ) color = "#"+color ;
setBodyStyle("backgroundColor: "+color+";") ;
layout() ;
app.view.layout() ;
}//end: method setbgcolor

(the above code is a method in a class that extends ContentPanel; app.view is a ViewPort which is this ContentPanel's parent)

Do I call layout() on the content panel itself or it's parent? If you call layout on a component does it filter down to it's children?

I can't seem to get it to work. I'm assuming setBodyStyle sets the css for this component. Does layout() also consult this css?

Another, somewhat unrelated query, when is the best time to change the GXT theme. ie:


GXT.init() ;
if (!Theme.GRAY.getId().equals(GXT.getThemeId())) {
ThemeManager.register(Theme.GRAY) ;
try {
GXT.switchTheme(Theme.GRAY) ;
}//end: try
catch(Exception e) {
e.printStackTrace() ;
}//end: catch
}//end: if


Currently my app seems to load the default blue theme and then swap to the grey theme a second or 2 after the app is loaded which looks strange.