B4J Question Autocomplete Textfield

Discussion in 'B4J Questions' started by tcpip, Mar 29, 2015.

  1. tcpip

    tcpip Member Licensed User

  2. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

    ThRuST and jmon like this.
  3. tcpip

    tcpip Member Licensed User

    Thank you Erel for your reply.
    I have added the library but when i try to run this example i get this error:
    Program started.
    Error occurred on line: 23 (main).
    java.lang.ClassNotFoundException: org.controlsfx$control$textfield$TextFields
    at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:287)
    at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:73)
    at b4j.example.main._setautocomplete(main.java:95)
    at b4j.example.main._appstart(main.java:80)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:224)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.start(main.java:36)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    at java.lang.Thread.run(Thread.java:745)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Make sure that the library is still checked in the libraries list.
    And make sure to use Java 8 under Tools - Configure Paths.
     
  5. tcpip

    tcpip Member Licensed User

    I installed java8 and added the path....but i get now another error

    Cannot find: C:\Program Files (x86)\Anywhere Software\B4J\libraries\controlsfx-8.jar
     
  6. tcpip

    tcpip Member Licensed User

    Its ok Erel.
    I found and download the controlsfx library and now is working.

    And it seems good.

    thanks
     
  7. Fabrice La

    Fabrice La Active Member Licensed User

    I am using the SetAutoComplete. work nice.
    Now i would like to use the Event that select the word (Event click the word in the autoComplete list )?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    There is no such event. You can use the TextChanged event and check whether the current text matches one of the items.
     
  9. le_toubib

    le_toubib Active Member Licensed User

    hello all
    is there a way to increase font size of the drop down list ???
    Also , is there a way to keep the list from appearing in case i add text programatically ??
     
    Last edited: Jan 12, 2017
  10. Erel

    Erel Administrator Staff Member Licensed User

    You can change the font size:
    1. Create a css file:
    Code:
    .auto-complete-popup {
       -fx-
    font-size: 20;
    }
    2. Load it:
    Code:
    MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "test.css"))
    [​IMG]

    There is no simple way to prevent the list from opening.
     
    le_toubib likes this.
  11. le_toubib

    le_toubib Active Member Licensed User

    thanx erel for replying
    is there a way to make the list width larger ? and height ?
     
  12. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    did not test, but something like this:

    Code:
    .auto-complete-popup .list-view {
    -fx-pref-width:
    100;
    }
     
    le_toubib likes this.
  13. jmon

    jmon Well-Known Member Licensed User

    emexes and ThRuST like this.
  14. MAGAREY

    MAGAREY Member Licensed User

    its posible to get the textfield view, catching it from the sender?

    I tried this but without success:

    Code:
    Sub autocompleted_Event (MethodName As String, Args() As Object) As Object
        
    Log("Success")
        
    Log(Args.Length)
        
    Dim jo As JavaObject = Args(0)
       
     
    Log(jo.RunMethod("getCompletion",Null))
        
    dim b as textfield
            b=
    Sender
           
    log(b)

        
    Return False
    End Sub
     
  15. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    dim b as textfield = sender
    should ALWAYS be your first line in the sub
     
    MAGAREY and jimmyF like this.
  16. ThRuST

    ThRuST Well-Known Member Licensed User

    @Erel You mentioned that it's not "perfect", so what's wrong with the example? it seems to work just fine. Can you perhaps make the neccessary improvements after all this time.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    When I tested it a few years ago there were issues with the list width. Might have been fixed in ControlsFX 9.

    There are better options available now such as MiniSearchView, SearchView or Search template from XUI Views.

    The time passed is not a factor that I consider.
     
    ThRuST likes this.
  18. ThRuST

    ThRuST Well-Known Member Licensed User

    @Erel I really like your example and would like to use it, but as it works now one have to press enter to select the item from the list then press enter again to perform the websearch, this is not smooth enough for my needs. Is there a way to directly after selection trigger the code to perform the search? Perhaps Enrique allready answered my question, this has to be tested.
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    You can probably monitor the TextChanged event. As I wrote there are better options available.
     
    ThRuST likes this.
  20. ThRuST

    ThRuST Well-Known Member Licensed User

    That works, but it would be neccessary to check for enter keypress so I'll try that as well.

    I found a solution here
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice