Share My Creation Java Object Creator

This I must stress is a work in progress, but has enough functionality to be useful now.

Basically, this program will try to create JavaObjects and subs to allow you to access items not included in the IDE.

The screen has a TextField where you enter the item ie TableView. It is not case sensitive so tableview and TableView are counted as equal.

The button is there for people who like clicking after entering text ( although hitting return in the TextField will do the same thing)

Below the TextField is a ComboBox - this will be populated with the class names that contain the item you entered. 99% of the time just choose the javafx... class. (yes there are slashes between the path parts)

On selecting the class the ComboBox below will be populated with the methods for the class.

You will notice that the TextArea now has some generated code in it at this stage. These are the constructors for the item you chose in the first ComboBox.

When you select an item in the bottom ComboBox, more code is generated, this is a sub you can copy to your code. The sub is general purpose it relates to all controls of that type.
Suppose the generated code is
B4X:
Sub TableView_applyCSS(ob as JavaObject,arg As String)
...
End Sub
To use it, the ob is the TableView you want it to work on so calling
B4X:
TableView_applyCSS(myTableView,"-fx-background-color: red")
Will apply the css to myTableView

All the subs follow a similar format where ob is the Object to work on.



Simply copy and paste the code into your program.

The second ComboBox allows you to select another method, and generate further code.

If you want change the item in the TextBox or top ComboBox , you will need to restart the program.

Notes:
1, It has the java path built in and assumes that JAVA_HOME points to the JDK .bin folder.
2, If after you type in the TextField and it goes blank, it's because it cannot find the class you requested.
3, If you know you want, for example, TableView css methods, you can type TableView css, and it will only list out methods that contain css in the lower ComboBox.
4, If the code looks odd, eg it says sub return type As java.util.HashMap it's because it doesn't know how to map that to B4J - you will need to manually correct it.


As I progress it will map things better to B4J.

Remember - This is a Beta version, don't rely on the generated code being 100% correct.
 

Attachments

  • JoCreator.jar
    330.1 KB · Views: 388
  • JavaObjectCreatorSource(Beta version).zip
    6.4 KB · Views: 392
Last edited:

Daestrum

Expert
Licensed User
Longtime User
Just noticed if you use the shortcut to find details eg, tableview css , it screws the sub name up.
B4X:
Sub tableview css_applyCss(ob As JavaObject)
...
Sorted in next version


EDIT- UPDATE:
Rewriting - found a much better way to generate the code, not using JavaObject as this generates too much unneeded code, now generating the java code directly into a #if java ... #end java
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User

Daestrum

Expert
Licensed User
Longtime User
Eventually I will release it as source, so people can tweak it to suit their needs.

GUI not my strong point - functional wins over looking good for me :)

Will look at the RichTextArea thank you for the suggestion.

I may replace the choicebox's with simple listview's as the choicebox's don't show you can select things until you try.

The new Sub code generation looks better
B4X:
Sub someName(ob as JavaObject) As String
   return inline.RunMethod("someFunc",array(ob))
#if Java
public static String someFunc(Object ob){
   return ob.the_real_function();
}
#end if
End Sub

It produces far more compact code.
 

Daestrum

Expert
Licensed User
Longtime User
Uploaded the source - ignore the untidy code layout - it was written straight from the brain, not had a chance to tidy it up yet. :)
 

BPak

Active Member
Licensed User
Longtime User
Eventually I will release it as source, so people can tweak it to suit their needs.

GUI not my strong point - functional wins over looking good for me :)

Will look at the RichTextArea thank you for the suggestion.

I may replace the choicebox's with simple listview's as the choicebox's don't show you can select things until you try.

The new Sub code generation looks better
B4X:
Sub someName(ob as JavaObject) As String
   return inline.RunMethod("someFunc",array(ob))
#if Java
public static String someFunc(Object ob){
   return ob.the_real_function();
}
#end if
End Sub

It produces far more compact code.
Like this tool. looking forward to its use.
 
Top