Created
December 5, 2009 09:45
-
-
Save mpen/249634 to your computer and use it in GitHub Desktop.
TableのセルにJEditorPaneを表示する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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