Skip to content

Instantly share code, notes, and snippets.

@mpen
Created December 5, 2009 09:45
Show Gist options
  • Save mpen/249634 to your computer and use it in GitHub Desktop.
Save mpen/249634 to your computer and use it in GitHub Desktop.
TableのセルにJEditorPaneを表示する
// TableのセルにJEditorPaneを表示する
class EditorPane extends TextComponent {
override lazy val peer = new JEditorPane
}
class EditorPaneRenderer(comp: EditorPane) extends Table.AbstractRenderer[String, EditorPane](comp) {
override def configure(table: Table, isSelected: Boolean, hasFocus: Boolean, a: String, row: Int, column: Int): Unit = {
component.text = a
}
}
object EditorPaneAndTableRenderer extends SimpleGUIApplication {
lazy val table = new Table {
...
val epRenderer = new EditorPaneRenderer(new EditorPane)
override protected def rendererComponent(isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component = {
column match {
case 1 =>
val value = model.getValueAt(row, column) match {
case s: String => s
case x => x.toString
}
epRenderer.componentFor(this, isSelected, hasFocus, value, row, column)
case _ =>
super.rendererComponent(isSelected, hasFocus, row, column)
}
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment