You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

1

Saturday, November 10th 2012, 11:44pm

JSpinner - How to pass custom SpinnerListModel to constructor

Hey there,

to create a spinner, first create its model and then pass the model to the JSpinner constructor.
In Java it should look something like this:

Source code

1
2
3
4
5
String[] monthStrings = { "Januar", "Februar", "März", "April", "Mai", "Juni",
                  "Juli", "August", "September", "Oktober", "November", "Dezember"};
//Edit: ..deleted one line!!
SpinnerListModel monthModel = New SpinnerListModel(monthStrings);
JSpinner spinner = New JSpinner(monthModel);


Now I am trying to achieve the same in Jabaco!
It throws an error though:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
Option Explicit

Import javax#swing#SpinnerListModel
 
Public Sub Form_Load() 
   Dim sArray() As String 
   sArray() = Split("Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember",",")
   'ERROR: Auto conversion 'String()' to 'java/lang/Object()' is not supported!
   Dim slm As New SpinnerListModel(sArray())
   Dim Spinner1 As JSpinner = New JSpinner(slm) 
   Me.add(Spinner1) 
   Spinner1.setBounds 10,10,100,20    
End Sub


Quoted

Dim slm As New SpinnerListModel(...expects... 'arg2 As List'


...seems to expect an object / List
I am not quite sure what to do with that?

Any thoughts?

Thanks,


Dani

This post has been edited 1 times, last edit by "Dani" (Nov 11th 2012, 10:12am)


Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

2

Monday, November 12th 2012, 5:46pm

Hey there,

OK, got it now!
If anyone knows how to pass a string array directly ... please let me know.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Option Explicit 

'Import java#util#ArrayList
   
Public Sub Form_Load()
   Dim sList As ArrayList = New java#util#ArrayList
   sList.add("Januar")
   sList.add("Februar")
   sList.add("März")
   sList.add("April")
   sList.add("Mai")
   sList.add("Juni")
   sList.add("Juli")
   sList.add("August")
   sList.add("September")
   sList.add("Oktober")
   sList.add("November")
   sList.add("Dezember")
   Spinner1.Parent.setModel(New SpinnerListModel(sList))
End Sub


Dani

Rate this thread
WoltLab Burning Board