B4J Question How to add an Image to a "in code" created Button? - Daestrum (first post) Oct 05, 2015 (2 reactions) try
...
Dim iv As ImageView
Dim im As Image
Dim b As Button
iv.Initialize("")
im.Initialize("","your image for the button.png")
iv.SetImage(im)
b.Initialize("b1")
asJO(b).RunMethod("setGraphic",Array(iv))
MainForm.RootPane.AddNode(b,10,10,-1,-1)
Mai B4J Question How to add an icon to a button via code - ivan.tellez Aug 28, 2015 Its is possible to add an Icon from the Files folder to a button created in code?
This works with files outside the compiled jar:
Dim tButton As Button
tButton.Initialize("RibbonButton")
tButton.Style = "-fx-background-position: center top; -fx-background-repeat: no-repeat; -fx-background B4J Question add image to button - Daestrum (first post) May 07, 2016 After a quick test it looks like you need to add it to files in the designer and assets
43878
Hope this helps.
Oops I uploaded the wrong picture originally. (it was a background not a button) B4J Question Lack of basic controls - jmon (first post) Oct 12, 2016 (2 reactions) To set your button images, try this:
https://www.b4x.com/android/forum/threads/how-to-add-an-icon-to-a-button-via-code.57733/#post-363608
Then on the css of your button you need to set a padding:
CSSUtils.SetStyleProperty(btn, "-fx-padding", "4px")
Setting the padding with CSSUtils is the recommend B4J Question Button with image - Erel (first post) May 11, 2015 (1 reaction) You can use this code to add an ImageView to a button:
Sub SetGraphic(Btn As Button, Graphic As Node)
Dim jo As JavaObject = Btn
jo.RunMethod("setGraphic", Array(Graphic))
End Sub
Dim iv As ImageView
iv.Initialize("")
iv.SetImage(fx.LoadImage(File.DirAssets, "EffectNone.png"))
SetGraphic(but B4J Question [ABMaterial] Questions on understanding the framework... - Mashiane (first post) Sep 28, 2016 Question 6: How to add Clickable Images on the ABMCard where buttons are?
The ABMCard can have numerous buttons in it. How do instead have clickable images. I have rounded the sections where I'd like to perhaps have clickable images.
Currently the code to add a button there is
card1.AddAction("BU B4J Library B4J_Button_extra (Add images and enhance your buttons) - fernando1987 Nov 21, 2021 (2 reactions) 122074 B4j_Button_extra Autor: Fernando Arevalo Version: 0.01 B4j_Button_extra Functions: Show (btn As Button, image As String, color1 As String, color2 As String, width As Int, heigth As Int) Example: #Region Project Attributes #MainFormWidth: 600 #MainFormHeight: 600 #End Regio B4J Question B4J Button Images - Problems - stevel05 (first post) Aug 10, 2022 (1 reaction) That is the expected behaviour. the set graphic method on a node adds the graphic within the target node, thereby stretching the target node to allow it to fit. If you want to change the background image of the button, use the CSSUtils library. Sub ButtonBOTTOM(BTN As Button) CSSUtils.SetBack Share My Creation Creating javafx buttons with images - jkhazraji (first post) Sep 27, 2023 (1 reaction) Dim btn as JavaObject
'
'
'
Dim imgPath As String =File.Combine(File.DirApp,"home32.png")
btn=(Me).As(JavaObject).RunMethod("createButtonWithImage",Array("Home",imgPath))
(Me).As(JavaObject).RunMethod("addListener",Array(btn))
Form1.RootPane.AddNode(btn,60,30,0,0)
Private Sub btn_click(msg As Strin B4J Question Button Image - Erel (first post) Oct 13, 2016 You can set the image with the designer:
https://www.b4x.com/basic4android/images/SS-2016-10-13_09.00.47.png
Or: https://www.b4x.com/android/forum/threads/how-to-add-an-icon-to-a-button-via-code.57733/#post-363608 Page: 1 2 3 4 5 6 7 Powered by ColBERT |