How can I change background image in JFrame using JButtons? - jframe

I want to change the image background of a JFrame using a button. I know how to use JFrame and Jbutton.

you should add the following code in your button action listener
setContentPane(new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png")));

Related

three button using one image picker, the image is not update

I start learning Swift and try to fulfill using one image picker change button image when users trigger one of three buttons.
I watch online resource and understand how to use one image picker for changing one button image
But now I have three buttons, and each of them should have the ability to use image picker and change their own button image.
My solution for this is every time when the button is clicked and image picker is called, I set the UIImage outside the function equal to the info image
At meanwhile, knowing that image picker has triggered because the button was pushed down, I put a line for set-button-image with that UIImage in the button (IBAction function).
Below is my source code. Somehow the way I wrote will not update the button's image correctly.
Let me know if any information is missing or confused. Any advice or knowledge will be helpful, thanks.
sourceCode1
sourceCode2
main page
after clicking the add button the library shows
after select image, the button image shows all white
after clicking the white part, the image somehow shows
If I click another button, the button change like the first button???

How to make a button in android and make it invisible

I want to have a button which should not be visible but when clicked onclick should be executed..
I have tried making
Button button;
1)button.setVisiblity(4);//it made it invisible but onclick was not working
2)In the layout xml i have attached android:visibilty="invisible" //but it made it invisible
Remove the visibility bit and use the following instead.
button.setBackgroundColor(Color.TRANSPARENT);

Icon/image over UIButton iPhone

If I want an image on my UIButton, and I still want to use the default white button. Is it ok to add an image(icon) over some parts of the button?
I have a button with the text 'Show on map' and I want a icon to the right.
Is this the only approach or are there other possibilities? When I add an icon over the button some parts of the button won't be "clickable".
Thanks in advance.
you could create a custom button that has an image the 'icon' and then the rest is transparent and then overlay this button over the standard one and give them the same action.
An easier way would just to be create an image that is the button exactly as you want it and use the 'custom button' style and use this as the backgroundImage.

change the backgoroun images dynamically in blackberry eclipse

Please help me how to change the selected background image dynamically please give me sample example...
I Need to change My application background image when i select the particular image from drop-down list, If click on apply button that image will be display in the background.
Thanking you
I suggest you try hooking up your button to a listener, then using Background to create your background before using setBackground() to change the background.
If this doesn't update the way you want, overwrite the layout() method in your screen and call the setBackground() in there, then call UIApplication.getUIApplication().relayout() to get it to layout the screen again (be sure to do it in a synchronize block!)
Good luck!

How to display the button transperent in iphone

I am new to iphone development.I have text on the button.I want only test to be displayed and not the button border or color .It should be transparent such that only there is text in view and not the button.It is possible to do that in interface builder?Please help me out. Thanks.
Select "Custom" as the button's type in the inspector. However, I would recommend against such design unless it's really necessary because if a button doesn't look like a button it may be confusing to your users.