cantas
cantas

Reputation: 114

how to move objects with JAVA JFrame?

I try to develop a java project for kids to develop myself. I'm not expecting a code, just examples or documentations about it. The project, takes two numbers and two different kind of fruits from combobox and it displays thoso fruits with matching via line. For example, the kid select 2 and 3 as a number and apple and orange as a fruit. The program shows 2 apples,there will be line among 2 apples and 3 oranges and there will be line among 3 oranges. And the kid(user) can move the fruits via drag and drop.

How can i do that? I dont know even keywords to search on anywhere.Which libraries or methods i have to learn ?

Sorry for bad language Thanks

Upvotes: 0

Views: 466

Answers (2)

mKorbel
mKorbel

Reputation: 109815

the kid select 2 and 3 as a number

  • two JSpinners for numbers with one SpinnerNumberModel (you can to reduce range)

  • or two JComboBoxes with integers in the model as the Items (you can to reduce range)


apple and orange as a fruit.

  • two JComboBoxes with Icon/ImageIcon in the model (see Oracle tutorial for working code example)

  • or two JLists with Icon/ImageIcon in the model (use the same methods as for JComboBox, Items in JComboBox are in JList)


can move the fruits via drag and drop.

  • use JList for this idea

  • put generated fruits as Item to the model for the another JList (horizontal wrap), for DnD to read Oracle tutorial for working code example about DnD between two JList


How can i do that? I dont know even keywords to search on anywhere.Which libraries or methods i have to learn ?

  • post an SSCCE, short runnable, compilable in the case that you will have any issue(s) with a.m. points, demostrated your progress

Upvotes: 2

xxlali
xxlali

Reputation: 1036

You can use javaFX. It is much more easier to use than swing and have a modern appearance. There is also a scene builder for javaFX. You can directly place combo boxes or lines via this scene builder.

Upvotes: 1

Related Questions