Picker has two components :
The Initial/Selected value displayed in Codenameone UI.
The Native picker dialogs/sheets.
It makes sense that we can not control the theme/color/style of Native Pickers as they are influenced by an OS-specific theme selected by the user.
But how do we change the color of text inside the picker in Codenameone Interface?
What I want to do in the following screenshot is to make the texts "3/20/20, 00:00, & 0-5 persons" white.
What I tried :
Channing the "Label" font-family in CSS changed the font so I tried changing the "color" from CSS but it didn't help.
I tried changing the foreground color like this : timePicker.style.fgColor = 0xfffff
In CSS I defined a style.
DropdownStyle{
background-color: #333333;
color: #FFFFFF;
}
Then I set the style to picker
datePicker.uiid ="DropdownStyle"
But none of the above ways worked as expected.
What is the right way to do it? I believe I am missing a very simple thing but I couldn't find it myself.
AS #shai-almog suggested, after digging through Component Inspector, I found out that
A PickerComponent has the ID "TextComponent" so if we replace the UIID of PickerComponent it's going to change the style of just the Holder Component that's why I was able to change the background-color only but not the text.
Inside it, there is Picker which Represents the Text and has the id TextComponentField.
So I had to Style them individually like this :
TextComponent{
background-color: rgba(0, 0, 0, 0.0);
}
TextComponentField{
color: white;
}
Output :
Related
I'm new in vaadin development and i hope someone can help me. I just created a grid table with a model and everything works fine. But now, i want to change the background color of the selected row. I figure out, that i have to create a theme. I found this in the Vaadin Forum: https://vaadin.com/forum/thread/17867059/how-to-set-selected-row-opacity-in-vaadin-grid
This is what i have already done:
I created a html class with the code from the link. I called this class grid-selection-theme.html
I put this class into src/main/webapp/frontend/styles/grid-selection-theme.html
In the java file with the Grid, i added the import: #HtmlImport("frontend://styles/grid-selection-theme.html);
I added the theme to the grid: mygrid.addThemeName("grid-selection-theme");
Here is the code from the other thread in the forum:
<dom-module id="grid-header" theme-for="vaadin-grid">
<template>
<style>
:host(:not([reordering])) [part~="row"][selected] [part~="body-cell"]:not([part~="details-cell"]) {
background-color: rgba(255, 0, 0, .50);
}
</style>
</template>
</dom-module>
But it does not work.
This seems to work fine for me, what is your version of framework?
In case you are using Vaadin 14, you would need to place styles into .css file instead and import the file using #CSSImport
My style file gridStyles.css contains:
:host([theme~="grid-selection-theme"]) [part~="row"][selected] [part~="body-cell"]:not([part~="details-cell"]) {
background-color: red;
}
Class where grid is used has this import defined:
#CssImport(value = "./styles/gridStyles.css", themeFor = "vaadin-grid")
Grid has theme name added
I've change a host selector to reflect a theme attribute: in case you have multiple grids on the same page, then style will be applied only to the one having mygrid.addThemeName("grid-selection-theme");
Output looks like this:
I have the following code, which displays the images in my table with no border, then an orange border when hovered over:
table.test {
}
.test img {
border: solid 4px transparent;
}
.test img:hover {
border-color: orange;
}
If it try the following, i expect the border to stay orange after click, but it does not
.test img:active {
border-color: orange;
}
The images being used are thumbnail size instead of checkboxes.
Any ideas how I can keep the border orange after click?
Images cannot use active. http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#selector-active.Wrap it within an anchor and prevent default on the anchor click and change the cursor maybe?
check this fiddle might help you using simple jquery let you give your output
$('.test img').on('click', function(){
//use jquery css function
$(this).css({"border-color":"orange"});
// or add class .active with your own style
$(this).addClass('active');
})
make your image as block element and add this jquery click event. solved
You can create a class called orangeborder (or anything, really). Give it the attributes of border-color:orange;.
Then you can use jQuery and use:
$('img').click(function(){
$(this).toggleClass('orangeborder');
});
jsFiddle
I am new to GWT and was learning it through some examples running in Eclipse. In one of those programs for a button I added setStyleName(class) (also checked with setStylePrimaryName()) and added one more style to that using addStyleName(class).
What I expected was that the button should display the css class properties setted using setStyleName()/setStylePrimaryname as this will be the primaryStylename.
But to my surprise if I add another style to button using addStyleName(), that style is getting as the button's style eventhough it is its secondaryStyleName! In such a case inorder to express the primary styleName, I had to add the secondary style Name using addStyleDependentName().
My code sets styles as follows.
final Button sendButton=new Button("Send");
final TextBox nameField=new TextBox();
sendButton.setStylePrimaryName("newButton");
sendButton.addStyleName("secondButton");
And in the css file
.newButton{
display:block;
font-size: 16pt;
color: black;
background-color: maroon;
}
.secondButton{
color:blue;
margin: 15px 10px 10px;
background-color: olive;
}
The button is always coming in olive background color except in cases where its adding as addStyleDependentName("secondButton") and
case 2: while using addStyleName("secondButton") and then setStyleName("newButton") (As setStyleName() will remove the existing secondary styles). I had also checked the values of primary style name and others using getStylePrimaryName() and getStyleName().
getStylePrimaryName() gives "newButton" and getStyleName() gives newButton,secondButton....So even having a primary style name why its always showing its secondary style property(here secondButton) added through addStyleName()?
*Please note: I have tried this on a text box as follows and its expressing the color mentioned under primary style as expected*
final TextBox nameField=new TextBox();
nameField.setText("---Enter Name Here---");
nameField.setStylePrimaryName("textStyle");
nameField.addStyleName("myText");
nameField.addStyleName("bigText");
and the CSS is as follows
.myText{
color:blue;
}
.bigText{
font-size: large;
}
.textStyle{
color:maroon;
text-shadow: aqua;
}
A thing noticed was that unless we are not adding the secondary styles as addStyleDependentName(), the properties are displaying in the order in which class names occur in CSS...That is, if the primary style name definition comes after secondary ones, primary gets displayed, else the secondary ones...The difference can be noted changing the order in which classes are defined in CSS
So in my button properties, when i changed the order to
.secondButton{
color:blue;
margin: 15px 10px 10px;
background-color: olive;
}
.newButton{
display:block;
font-size: 16pt;
color: black;
background-color: maroon;
}
the button color is getting as maroon. If the secondary styles are added as addStyleDependentName(), the primary style is expressed irrespective of the order in CSS
As per Docs :
Adds a secondary or dependent style name to this object.
After you set the setStyleName() or setStylePrimaryName() the addStyleName() will add another style,which you passed through the argument
The style primary name is the one style dependent names add a suffix to. Otherwise it's just a style name, and the CSS rules apply (GWT can't do anything around that, it's just HTML+CSS+JS in the end in the browser)
I am trying to customize text in google maps info window. I have a CSS file which has the following:
.zabove {color:#ff0000; font-weight: bold;} // red and bold
.zbelow {color:#14d714;} // green
And in the java class depending on a value for foo, I try to set the color of a label by using the setStyle method:
if(foo>100){
label.setStyle("zbove");
} else {
label.setStyle("zbelow");
The above does not result me any color, the text is just black.
What browser are you using. Try using different browser. What you are doing looks absolutely correct. Sometimes I have found the GWT application behaves differently on different browsers.
How to change single element of the widget style in GWT. I would like to create new version of TextBox style, so that only the border color changed to red, for example.How to get to the style responsible for the TextBox?
I tried to create new style
.gwt-TextBox.invalid {
border-color: red;
}
but it does not work.
Make sure you add class invalid to your TextBox:
textBox.addStyleName("invalid");
Use CssResource to associate your CSS file with GWT: http://code.google.com/webtoolkit/doc/latest/DevGuideUiCss.html#cssfiles