Reputation: 389
I am creating a GUI using seesaw for the first time and I am stuck on how to add buttons to button groups and display them(buttons) on the same frame. This is what I have so far.
(def b (button :text "Start a new Project"))
(def c (button :text "Continue an Existing Project"))
(def groups (button-group))
(flow-panel :items [(b :group groups)
(c :group groups)])
(display groups)
Upvotes: 0
Views: 361
Reputation: 54035
(button)
returns a button (a component) which is not a function. If you later use it as (b :group groups)
, it actually tries to invoke b
as if it was a function, passing it two arguments: :group
and groups
. That's why it fails, because it can't cast button to function.
Secondly, I believe (button)
creates a regular JButton
, for which the group makes little sense. Did you mean radio buttons, like (radio)
?
One of these two should probably do what you expect.
Radio buttons:
(def groups (button-group))
(def b (radio :text "Start a new Project" :group groups))
(def c (radio :text "Continue an Existing Project" :group groups))
(def panel
(flow-panel :items [b c]))
(invoke-later
(-> (frame :content panel :on-close :dispose) pack! show!))
Regular buttons:
(def b (button :text "Start a new Project"))
(def c (button :text "Continue an Existing Project"))
(def panel
(flow-panel :items [b c]))
(invoke-later
(-> (frame :content panel :on-close :dispose) pack! show!))
You probably can use your (display)
function instead of this (invoke-later)
snippet here, but this works end-to-end for me.
Upvotes: 3