B4J Question [SOLVED] Autocomplete box size

jroriz

Active Member
Licensed User
Longtime User
Hi.

Is it possible to increase the size of the autocomplete box?

upload_2017-7-23_22-44-37.png


The autocomplete was created like this:
B4X:
Sub SetAutoComplete(Items As List, Field As TextField)
    Dim jo As JavaObject
    jo.InitializeStatic("org.controlsfx.control.textfield.TextFields")
    jo.RunMethod("bindAutoCompletion", Array(Field, Items))
End Sub
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
hi!

with your current jo, you can implement the following methods:

controlsfx.bitbucket.io/org/controlsfx/control/textfield/AutoCompletionBinding.html

There you can set prefwidth, maxwidth etc. etc.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
like this (did not tested it):

B4X:
Sub SetAutoComplete(Items As List, Field As TextField)
    Dim jo As JavaObject
    Dim jo2 As JavaObject

    jo.InitializeStatic("org.controlsfx.control.textfield.TextFields")
    jo2 =  jo.RunMethod("bindAutoCompletion", Array(Field, Items))
   
    jo2.RunMethod("setMinWidth",Array(100))
   
End Sub
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
like this (did not tested it):

B4X:
Sub SetAutoComplete(Items As List, Field As TextField)
    Dim jo As JavaObject
    Dim jo2 As JavaObject

    jo.InitializeStatic("org.controlsfx.control.textfield.TextFields")
    jo2 =  jo.RunMethod("bindAutoCompletion", Array(Field, Items))
  
    jo2.RunMethod("setMinWidth",Array(100))
  
End Sub

Hi.

How do I create an ItemSelected event for the object?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi!

See attached file:

I used JcontrolFx library but if you are using additional Jar should work all the same.
 

Attachments

  • jo.zip
    2 KB · Views: 334
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I am afraid, it is not possible to have custom parameters on this option. But you could use a global variable (a map for example) and use it as your parameter.
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
like this (did not tested it):

B4X:
Sub SetAutoComplete(Items As List, Field As TextField)
    Dim jo As JavaObject
    Dim jo2 As JavaObject

    jo.InitializeStatic("org.controlsfx.control.textfield.TextFields")
    jo2 =  jo.RunMethod("bindAutoCompletion", Array(Field, Items))
  
    jo2.RunMethod("setMinWidth",Array(100))
  
End Sub

Hi.
Now i need to "rebind" the list. But if i call this sub again to refresh the list, a new box is created. Can you help?
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi Joao!

please see attached example!

There is a function dispose, but you need to have a reference to the binding to use it. so i passed both initializations to global variables.
 

Attachments

  • jo.b4j.zip
    17.3 KB · Views: 324
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
I actually knew about dispose. I just did not know how to use it.
Another coffee ...
Thank you again.
 
Upvote 0
Top