CodenameOne TextView Foreground Color - colors

I'm new to codename one and try to set the foreground (text) color of a TextView. Setting it to red color and writing a text after pressing a button works. The code is executed in button's action listener method:
mValueField.getStyle().setFgColor(0xFF0000); // set red color
mValueField.setText("Fill in!"); // write info text
After setting focus into the field the text should disappear and color should be black again. The code is executed in TextField's focusGained() method:
mValueField.setText(""); // clear info text
mValueField.getStyle().setFgColor(0x000000); // set black color
Problem is that the text disappears but new chars are still red instead of black.
Any solutions for me?

Don't use getStyle() it's designed for use within paint() or similar methods. Since the component has multiple states you need to customize every individual state e.g. getUnselectedStyle(), getSelectedStyle() etc.
Or you can use the getAllStyles() to set them all with a single call.

Related

tvOS button background color issue where it's not set properly

As you can see, I'm trying to set the button's color to a very light blue, but by default everything but the bezels are being darkened. Is the default button behavior causing this? Is there a workaround besides creating your own button? If I do have to create my own button, how can I reuse the default button's animation behavior? Thanks.
You don't have to create a custom button.
Instead, create an image containing the color you want and use that as a background image. Plus make sure to set the button's background color to default (clearColor), otherwise you will lose the rounded corners.

how to change the color of a spinner prompt

I have a spinner with a custom background and I need to change the initially displayed text (the initial prompt) from black to white.
This is what I've got at the moment
There are plenty of answers on SO and elsewhere on how to change the spinner ITEMS color using an adapter but nothing (that I can find) on how to change the initial text (the 'Android' in my example).
How do I change the color of the initial spinner prompt?
Blush ... Oops, I've just found out for myself. The answer is to replicate simple_spinner_item.xml and put it into the layout directory. I had done that but called it simple_spinner.xml, not simple_spinner_item.xml.

Getting the OS theme color values in PyQt

I just want to get the background color values of any widget (button, list item, textbox) when it's hovered and it's selected, which i'm looking to use in my custom stylesheet.
For better understanding I'm attaching the following screen shots taken in Ubuntu. The same is applicable for Windows also.
With hover effect :
With selected effect :
The selected color is returned by QPalette.color() for the key QPalette.Highlight.
And in a stylesheet, you can use { background-color: palette(highlight) }.
The hover background color doesn't seem to be part of the QPalette colors, but is apparently either painted as part of the native widgets API (gtk), or hardcoded into the QStyle classes.

How to remove the dark shadow of the screen when a Dialog is shown?

When a Dialog is shown then the background of screen is darkened. I want to remove this darkness so that the screen looks like normal. How to achieve that ?
When you show a Dialog the background becomes a Form, changing its style you can modify the background of a Dialog. I don´t really know if you can make this Form transparent. I use the LWUIT-Theme creator and modifiying the Form´s style, I can change the background for an image o for one colour.
Try it here!
http://lwuit.java.net/
Set the tint color of the parent form, you can also set this in the look and feel class and within the theme constants in the resource editor.
just add below code on your dialog:
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

How to get JButton default background color?

I use this myButton.setBackground(myColor) to change the JButton background color to my color, how to find it's original default background color so I can change it back? I know I can save its default background color before I change and use that, but I wonder if Java stores it somewhere so that maybe I can call something like: myButton.getClass.getDefaultBackground() to get it back ?
btn.setBackground(new JButton().getBackground());
how about this...
it will get the default color of button
myButton.setBackground(null)
changes it back to the default color.
This might help:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/SystemColor.html
Toolkit.getDesktopProperty(java.lang.String)
Toolkit.getDesktopProperty("control");
// control - The color rendered for the background of control panels and control objects, such as pushbuttons.
It works both with:
button.setBackground(null);
and
button.setBackground(new JButton().getBackground());
(when you create a new JButton, its background color is initialized as a null color)
So, choose the one you consider to be the best for your project
Don't try to get background from Jframe or other elements to apply it on the button; if you already changed it do this:
ElementToStyle.setBackground(null);
make a new button "db"
make a new variable type Color "jbb"
i.e. - Color jbb = db.getBackground();
now the default background color is stored in the Color jbb which you can now use as the color you want to find/use
Color cbt= jButton6.getBackground();
String color_button=cbt.getRed()+","+cbt.getGreen()+","+cbt.getBlue();
if you wont get RGB color button
try this code

Resources