Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scala.swing.ComboBox should support mutable item lists #128

Open
scabug opened this issue Jan 3, 2009 · 2 comments
Open

scala.swing.ComboBox should support mutable item lists #128

scabug opened this issue Jan 3, 2009 · 2 comments

Comments

@scabug
Copy link

scabug commented Jan 3, 2009

To enable dynamical Swing comboboxes, scala.swing.ComboBox should also be able to use the MutableComboBoxModel. Something like the addition of a mutable model in addition to the existing constant model:

class MutableModel[A](items: Buffer[A]) extends ConstantModel(items) with MutableComboBoxModel {
   def removeElementAt( n: Int ) = items.remove( n )
   def removeElement( item: Any ) = items.remove( items.indexOf(item) )
   def insertElementAt( item: Any, n: Int ) = items.insert( n, item.asInstanceOf[A] )
   def addElement( item: Any ) = items.append( item.asInstanceOf[A] )
}

The choice of the model could depend on some parameters in the constructor (e.g. matching Seq or Buffer).

@scabug
Copy link
Author

scabug commented Jan 3, 2009

Imported From: https://issues.scala-lang.org/browse/SI-1613?orig=1
Reporter: Daniel Willmann (dwillmann)

@scabug
Copy link
Author

scabug commented Jul 5, 2014

Thomas Santana (mailleux) said:
I achieved this using a combo box which you can specify the model.

Here is the example:
https://github.com/nebulorum/virtual-combat-cards/blob/master/vcc-swing/src/main/scala/vcc/util/swing/ExplicitModelComboBox.scala

I would recommend making ComboBox accept a mode. Provide a default mutable model implementation and allows users to create their own. The example above uses an immutable Seq because I rather use this.

I would also suggest making the model type visible so you don't have to add a bunch o methods in ComboBox and have to deal with mutable and immutable collections.

@scabug scabug closed this as completed Jul 17, 2015
@SethTisue SethTisue transferred this issue from scala/bug Nov 19, 2020
@SethTisue SethTisue reopened this Nov 19, 2020
@scala scala deleted a comment from scabug Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants