How to make checkbox without a background programmatically? - java

I'm new to Android development and I'd like help from the experts here.
I make my checkbox change its background color to red upon a specific condition, and then I need to return its background color to the original one. I've tried the following code, but it gives me an error, so I'd like to know the correct code for doing so?
I have tried various ways, but nothing helps me solve my problem.
Female.setBackgroundColor(Color.parseColor("#null"));
Male.setBackgroundColor(Color.parseColor("#null"));

This sets the color to transparent what is the same as setting the background to #null:
Female.setBackgroundColor(0x00000000);
Male.setBackgroundColor(0x00000000);
Can be simplified by using just 0 but I think it is easier to understand if there is the ARGB code.

Related

is there a way to access the property of component inside another container?

I am working on a project(shown below).
When I type a value in textField the slider will correspond the same value, meanwhile the color will change, as well as the label(R: 0,G:0,B:0).
Also when you slide slider, the text of textfield, color, and label will change (I have already achieve this function). By the way, three sliders are put in a panel.
I tried to get component of panel, but there is no getValue() method which is weird.
Is there a way to solve this? Any help will be appreciated. (I am totally new to programming)
The easiest way to accomplish what I think you are trying to do is to use Beans Binding, at least if you use NetBeans as your IDE. Bind the JTextField for the Red color to the JSlider for the Red color. Do the same for Green and Blue components. At its most basic level, beans binding is a way to connect bean properties without using event listening and handling code.
It's really not exactly clear what you are trying to accomplish here since you have not responded to the comment I provided related to your Post so I'll just leave you with a gif Image displaying a demo of what Beans Binding can look like in action. The demo code is too large to post here but if the provided above link is not enough to assist you then (anyone) please feel free to e-mail me for the demo source.

Background color behind a variable or keywords

In Android Studio, i am unable to understand the meaning of background color of keywords or variables.
I've joined a picture in order to get a better idea.
1) the String variable "day" don't have any background color at the declaration and also inside the constructor.
2) The String variable "descriptionSummary" have a brown background color at the declaration but not in the constructor, why?
3) Why the keywords "public" have a brown background color?
I really don't understand the meaning and also i would like to change these colors, so thank you for the help.
You can hover over them to find out, but if I had to guess
day is fine. So is everything else not highlighted
descriptionSummary is initialized, but never used
You never used that constructor anywhere in your code, or it can be package-private (personally, I turned off that message on my IDE)
You've searched for getDescription, so it's green
You can change the theme of the IDE. Not sure how much control you get over those colors
The Android studio gives you suggestions to improve the code. For example, public can be turned into a package-private access. Hover over the highlighted text, and you'll see a light bulb and explanation like shown below.
day is not highlighted
the colour of descriptionsummary will change when you will use that in program
I dont think that we can change these colours because its predifined by android studio. We can change only theme if we want.

How to make Swing Checkbox in list with different background color

Lets start with saying Im not very knowledgeable with Swing. But I have a regular JTable where I have various columns, some of which is Booleans which gets translated to checkboxes. And as you can see in the image below, their background is pure white, and doesnt follow the "alternative" coloring as the other fields (Double and Strings). Any clue on what is happening here is appreciated.
Thanks for the comments guys. It led me straight right! So I googled some custom renderer for Nimbus and checkboxes and found this which did exactly that I wanted.
https://code.google.com/p/jsparklines/source/browse/trunk/src/main/java/no/uib/jsparklines/extra/NimbusCheckBoxRenderer.java?r=77
Thanks again

How to completely remove a button's background instead of just hiding it

I'm trying to create this game
in Java for my school A-level course. I'm currently trying to use an individual button for each of the squares and cannot in any way remove the buttons's background. I've tried setBackground(false) which hides the background, but it is still there so still clickable, which you can imagine completely screws up the board.
Ultimately what I'm asking is how to make a button from a picture the same size as the picture, without any extra backgrounds at all, not just hidden.
Here is a picture of what I mean:
Any help/suggestions would really be appreciated, I'm desperate!
There was a question on here for creating custom buttons with java:
Creating a custom button in Java
The answer to this question might solve your problem.

Swing: problems with component's background

I've got a problem, that swing components in different parts of program have sometimes wrong background. For example this or this.
As I mentioned, the bug is not permanent and it can appear in one place one time and never after. But still there are some places, where I can randomly reproduce it. Unfortunately, I don't see any solutions.
Has anyone some ideas how can I fix it?
If you set your components to non-opaque (I think the call is setOpaque(false)), that will let the background colour of the component that it is on top of show through.
in addition to what Paul said, there's the question if you use self made components.
Such components should take care of their complete occupied region (or at least the invalidated regions) in the paint callback. An error seen quite often that leads to strange artifacts when moving or resizing is that only "important" parts are repainted, for example a string to be shown, without drawing the background.
In this case, anything previously blitted ther will show through.

Categories