B4J Code Snippet B4XTable Column Resizing... (works for me)

Hi there...

Well many of us need/asking column resizing... but noone do the start... well I ve decided to start... but hey... need help.. I think is a good start... need a lot of fixes and your ideas...

I am uploading an example - and give you my notes here...

What works....
- Resizing Columns... smooth (in Release mode)
- Works only with columns had set their width, no auto-resize !!! Caution.
- When Resizing form works ok...
- Double-Click guideline hide column (width 1pixel)... double click again... restore width !!!

What not works...
- No with autoresizing columns / auto-width
- No for the moment with changed order columns
- When using scrollbar loosing the coordinates - you must go back...

(no b4xtable scrollbar event to check, a fix you can do is using timer and call every 500ms the enableresize, didn;t try it but i think will work)
Thanks to LucaMs !! ... :) fixed that too

What not tried...
- At B4A, B4I... please check them

My programming mistakes..
- Can't understand so good the b4xview and adding at root new items... so removefromview has errors... please fix it and tell me the way...
Erel told me the way ! :)

Here a Video to see - how works... old-video now all working !


Is totally open-source - and ofcourse you can always donate me and B4X too.. Please share your code too... to make b4xtable stronger !

Credits to: Erel, LucaMs, Mahares, aeric...

⭐ You can donate me (buy me a coffee, drink, etc) If you think I've helped you...
 

Attachments

  • B4XTableExample-column-resizing-NEW2.zip
    55.7 KB · Views: 244
  • AnimationDONATE.gif
    AnimationDONATE.gif
    10.7 KB · Views: 156
  • AnimationDONATE2.gif
    AnimationDONATE2.gif
    10.8 KB · Views: 7,513
Last edited:

Mahares

Expert
Licensed User
Longtime User
What works
You show a video that looks like it is working, the title of your threead says: not fully working, but the project crashes with following error. So what is the verdict.
B4X:
B4J line: 154
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:568: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error
 

Magma

Expert
Licensed User
Longtime User
You show a video that looks like it is working, the title of your threead says: not fully working, but the project crashes with following error. So what is the verdict.
B4X:
B4J line: 154
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:568: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error
but it works-not lying.. wait a little i will upload an update with some new features..
 

Magma

Expert
Licensed User
Longtime User
updated...

Added double click to restore width - hide column (width:1 dip)
Added Timer to check scrollbar x (so... now you can move the scrollbar too)

...I think now it is someway ready... if someone want to to work with the order of columns be my guest... also... if someone find the way to calculate searchbox, buttons height or scrollbar height (is easy i think).. .tell me to fix it...
 

Magma

Expert
Licensed User
Longtime User
You show a video that looks like it is working, the title of your threead says: not fully working, but the project crashes with following error. So what is the verdict.
B4X:
B4J line: 154
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:568: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error
Found what was....

When packing to zip from b4j menu... for some reason these lines give error:

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?VMArgs=-DZeroSharedFiles%3DTrue&File=%B4X%\Zipper.jar&Args=B4XTableExample.zip

please remove them... and will work !... but first download the new zip... i think already removed... and has new features...
 

Mahares

Expert
Licensed User
Longtime User
please remove them... and will work !... but first download the new zip... i think already removed... and has new features...
Sorry. Even with your new version I have the same problem. It has nothing to do with what you mentioned as the reason in post#5. Maybe someone can report to you if it worked for them, then I do not know what my problem is. Maybe someone else can tell us. ANyway, thank you, I do not have to have that feature, as I do not need it. I just wanted to help by testing it.

B4X:
B4J Version: 9.30
Parsing code.    (0.13s)
    Java Version: 11
Building folders structure.    (0.15s)
Compiling code.    (0.29s)
Compiling layouts code.    (0.02s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    (3.55s)
Compiling debugger engine code.    Error
B4J line: 172
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:592: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error
 

Magma

Expert
Licensed User
Longtime User
Very strange...
I would like to listen other members too..

Today I am not in office/on PC ... to check the zip again..

Or screenshot libs using.. I am not remember anything special... is just the example of b4xtable erel made old days

+testing done with Release only if that helps...

Ps: as I am reading your post (Mahares, I understand that you using debug mode.. As I remember I was testing in Release mode)
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
Ps: as I am reading your post (Mahares, I understand that you using debug mode.. As I remember I was testing in Release mode)
It runs in release, but crashes in debug. Now, I can check it out. I am surprised no one that tested it did not bring it up to our attention earlier.
ευχαριστώ
 

aeric

Expert
Licensed User
Longtime User
You show a video that looks like it is working, the title of your threead says: not fully working, but the project crashes with following error. So what is the verdict.
B4X:
B4J line: 154
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:568: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error

I have eliminate the error by removing the casting:

B4X:
hheaderpanel = xui.CreatePanel("hhheaderpanel")

It runs in release, but crashes in debug.
The crash in debug happened in hhheaderpanel_MouseExited when the Sender is null and I may have fixed/bypassed it with the following:

B4X:
Private Sub hhheaderpanel_MouseExited (EventData As MouseEvent)
    If EventData.PrimaryButtondown Then Return
    Dim pane1 As B4XView = Sender
    ' modified by aeric
    Log(Sender)
    'pane1.SetColorAndBorder(xui.Color_Transparent, 2,0,0)
    If pane1.IsInitialized Then
        pane1.SetColorAndBorder(xui.Color_Transparent, 2, 0, 0)
    End If
End Sub

And I am not sure the following help but I think no harm to add it inside Sub Class_Globals:
B4X:
#RaisesSynchronousEvents: hhheaderpanel


P/S: I thought to change the mouse cursor using
B4X:
pane1.As(Pane).MouseCursor = fx.Cursors.H_RESIZE
but H_RESIZE does not exist.
 

Magma

Expert
Licensed User
Longtime User
when you say... removing the cast... ? how did you add the pane... as simple pane ?

a code... or a zip will be helpful for all...

did anyone tried at b4a or thought a way to use there ?
I have eliminate the error by removing the casting:

B4X:
hheaderpanel = xui.CreatePanel("hhheaderpanel")
 

aeric

Expert
Licensed User
Longtime User
when you say... removing the cast... ? how did you add the pane... as simple pane ?
You already define the variable hheaderpanel As B4XView in Class_Globals on top:
B4X:
'added by MAGMA:
Dim hheaderpanel As B4XView
So you do not require to cast it again as B4XView.
B4X:
' modified by aeric
'hheaderpanel.As(B4XView) = xui.CreatePanel("hhheaderpanel")
hheaderpanel = xui.CreatePanel("hhheaderpanel")
 

Attachments

  • B4XTableExample.zip
    55.8 KB · Views: 160

Magma

Expert
Licensed User
Longtime User
no... getting ... after some mouseovers and after scolling horizantal... errors: :(

Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
PaneWrapper$ConcretePaneWrapper$NonResizePane@cea9627
PaneWrapper$ConcretePaneWrapper$NonResizePane@3c831144
Unexpected event (missing RaiseSynchronousEvents): hhheaderpanel_mouseexited
java.lang.Exception: Stack trace
at java.base/java.lang.Thread.dumpStack(Thread.java:1387)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:199)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
at anywheresoftware.b4j.objects.NodeWrapper$7.handle(NodeWrapper.java:175)
at anywheresoftware.b4j.objects.NodeWrapper$7.handle(NodeWrapper.java:1)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.base/com.sun.javafx.event.EventQueue.fire(EventQueue.java:48)
at javafx.graphics/javafx.scene.Scene$MouseHandler.handleNodeRemoval(Scene.java:3692)
at javafx.graphics/javafx.scene.Scene$MouseHandler.access$7700(Scene.java:3579)
at javafx.graphics/javafx.scene.Scene.generateMouseExited(Scene.java:3576)
at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:591)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:329)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
at anywheresoftware.b4j.objects.NodeWrapper.RemoveNodeFromParent(NodeWrapper.java:354)
at anywheresoftware.b4a.objects.B4XViewWrapper.RemoveViewFromParent(B4XViewWrapper.java:265)
at b4j.example.b4xmainpage$ResumableSub_enableresize.resume(b4xmainpage.java:375)
at b4j.example.b4xmainpage._enableresize(b4xmainpage.java:288)
at b4j.example.b4xmainpage._b4xtabletimers_tick(b4xmainpage.java:557)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:135)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
null
PaneWrapper$ConcretePaneWrapper$NonResizePane@7d4a63cd
PaneWrapper$ConcretePaneWrapper$NonResizePane@187172bb
PaneWrapper$ConcretePaneWrapper$NonResizePane@a4b064d
PaneWrapper$ConcretePaneWrapper$NonResizePane@44b6ac4e
null
PaneWrapper$ConcretePaneWrapper$NonResizePane@5d4ea6f2
PaneWrapper$ConcretePaneWrapper$NonResizePane@4f01fe42
PaneWrapper$ConcretePaneWrapper$NonResizePane@6249c940
null
PaneWrapper$ConcretePaneWrapper$NonResizePane@729a5e09
PaneWrapper$ConcretePaneWrapper$NonResizePane@7b85250e
PaneWrapper$ConcretePaneWrapper$NonResizePane@1df6a371
PaneWrapper$ConcretePaneWrapper$NonResizePane@62257bd
PaneWrapper$ConcretePaneWrapper$NonResizePane@707207bb
null
PaneWrapper$ConcretePaneWrapper$NonResizePane@5da98406
PaneWrapper$ConcretePaneWrapper$NonResizePane@2d7309c2
null
PaneWrapper$ConcretePaneWrapper$NonResizePane@5ef55216
PaneWrapper$ConcretePaneWrapper$NonResizePane@2fcc3cb2
PaneWrapper$ConcretePaneWrapper$NonResizePane@3e7766da
PaneWrapper$ConcretePaneWrapper$NonResizePane@599e5032
PaneWrapper$ConcretePaneWrapper$NonResizePane@31baf469
 

Magma

Expert
Licensed User
Longtime User
P/S: I thought to change the mouse cursor using
B4X:
pane1.As(Pane).MouseCursor = fx.Cursors.H_RESIZE
but H_RESIZE does not exist.

B4X:
        Dim cursor As JavaObject
        cursor.InitializeStatic("javafx.scene.Cursor")

        Dim joObj As JavaObject = pane1
        joObj.RunMethod("setCursor", Array(cursor.GetField("E_RESIZE")))
 
Top