B4J Question Moving unwanted columns

desof

Well-Known Member
Licensed User
Longtime User
Hello adjust TableView columns as in figure 1 (design) is shown but supplemented with data and change the width is not as I want to see picture 2 (Implementation)


PICTURE 1 (Design) OK!


PICTURE 2 (Ejecución) nO xxx
 

Daestrum

Expert
Licensed User
Longtime User
It's to do with this setting, but have not tried to see what effect they have, or even how to apply to the table.
http://docs.oracle.com/javafx/2/api/javafx/scene/control/TableView.html#UNCONSTRAINED_RESIZE_POLICY

I found a solution: ( you need to use the lib I wrote jScriptEngine)

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private tab1 As TableView
    Private js As jScriptEngine  ' need to add this to libs
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("tabres1") 'Load the layout file.
    tab1.SetColumns(Array As String("One","Two","Three"))
    MainForm.Show
    js.enginePut("tab1",tab1)
    js.evalString("tab1.setColumnResizePolicy(tab1.CONSTRAINED_RESIZE_POLICY);")
End Sub

The result is you get three columns, not the default 'what you want plus one'.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Nice find

You can also apply it using JavaObject

B4X:
        Dim JO As JavaObject = Tab1
    Dim Policy As JavaObject
    Policy = Policy.InitializeStatic("javafx.scene.control.TableView").GetField("CONSTRAINED_RESIZE_POLICY")
    JO.RunMethod("setColumnResizePolicy",Array As Object(Policy))
 
Last edited:
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User


Sorry my English is very bad.

And this piece of code where you're going?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Something like this:

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Tab1 As TableView
 
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    Dim JO As JavaObject = Tab1 'Tab1 is a TableView defined in layout "1"
    Dim Policy As JavaObject
    Policy = Policy.InitializeStatic("javafx.scene.control.TableView").GetField("CONSTRAINED_RESIZE_POLICY")
    JO.RunMethod("setColumnResizePolicy",Array As Object(Policy))
 
    MainForm.Show
End Sub

Tags: B4j Table Hide unwanted columns resize policy
 
Last edited:
Upvote 0

desof

Well-Known Member
Licensed User
Longtime User



Parsing code. 0.01
Compiling code. Error
Error compiling program.
Error description: Referencia a objeto no establecida como instancia de un objeto.
Occurred on line: 51
Policy = Policy.InitializeStatic("javafx.scene.control.TableView").GetField("CONSTRAINED_RESIZE_POLICY")
Word: getfield
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Have you got the latest version 1.06 of B4j?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
The Java Object has changed slightly in 1.06, along with other amendments and bug fixes, I suggest you download the latest version.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
As B4j is free and the link is readily accessible, Erel doesn't send out links, just an announcement on the forum that a new version is available.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…