B4J Tutorial B4J tutorial for Basic4android developers

B4J development tool is similar to Basic4android. The language and IDE are mostly identical.

The APIs (methods, keywords and libraries) are identical in some cases and different in other cases.

I converted existing frameworks such as DBUtils, HttpUtils2, DateUtils, RDC, ImageDownloader and others from B4A to B4J. It was simpler than I expected it to be. In some cases no changes were required at all.

Modules

There are two types of modules in B4J. Code modules and classes. Classes are identical to B4A classes.
Code modules are similar to B4A modules however they are more powerful as they can handle events.

A code module can be considered as a class with exactly one instance (such instances are sometimes called singletons or static classes). Activities and Services are not required in B4J. You should instead use code modules. Note that when you add an existing B4A activity or service to B4J project it will be converted to a code module.

CallSub is mostly not required in B4J as you can directly call methods of other classes or code modules.

Generally speaking it is simpler to develop with B4J as you do not need to deal with the activities (and services) life cycle. This also means that there is no such concept as "activity object".

UI

The main difference is in the UI. B4J is based on JavaFX UI and Basic4android is based on the native Android UI.

It is worth going over Oracle Scene Builder tutorials to better understand the UI. Once you understand how the UI integrates with B4J code then the other concepts such as the "event name" concept are the same.

Colors - In Basic4android colors are represented as Ints (2 bytes for Alpha, R, G, and B). In B4J colors are represented as Paints.
You can use fx.Colors.From32bit to convert an Int value to a Paint.

This tutorial will be expanded in the future...
 

Swissmade

Well-Known Member
Licensed User
Longtime User
This is exactly where I have waiting for.
Many thanks Erel.

Question is this only for B4A users??
 

arman

New Member
Licensed User
Longtime User
I must say, this is a huge leap for all of us. Thank you to make it free for us.
 

desof

Well-Known Member
Licensed User
Longtime User
Congratulations from Argentina!!

Where do I can see examples to start?
 

mjtaryan

Active Member
Licensed User
Longtime User
Thanks, Erel. This will be most helpful.

A curious question: Is your ultimate goal to create a full crosss-platform development system that also includes iOS and Blackberry?
 

gulliver

Member
Licensed User
Longtime User
A new challenge.
Thanks Erel.
 

Woofs

New Member
Licensed User
Longtime User
Thank you for your excellent development tool. Keep the tutorials coming please.
 

reikhard

Member
Licensed User
Longtime User
Thank You Erel for create another "tool" to develop... thanks also to everyone that is creating libraries and helping others in this forum :)
 

Ratna Fang

Member
Licensed User
Longtime User
does it mean i can create simple app for linux, mac, and win, using the same language (or at least similiar) with b4a?
awesome....

erel is the st. clauss of this year :) :D
 

Doug Johnson

Member
Licensed User
Longtime User
I am getting "Rapid Debugger failed to connect to device" when I compile and run. I began a new project and added a Button just to see how things look and run but can't seem to get to square one.

Ideas?....

DJ
 

giga

Well-Known Member
Licensed User
Longtime User
I am getting "Rapid Debugger failed to connect to device" when I compile and run. I began a new project and added a Button just to see how things look and run but can't seem to get to square one.

Ideas?....

DJ
Make sure you are connected to your device in (B4A) under Tools/B4A Bridge and select wireless or Bluetooth toy your device.

BTW. This is posted in the wrong spot B4J does not have rapid debugger.
 
Top