Java.use(better, Scala); tips342_colorTabbedPane

《前の記事|記事一覧|次の記事》
Java.use(better, Scala)


Tips #342

TabbedPane



私たちの人生は
私たちが費やした努力だけの価値がある
François Mauriac - Wikipedia

《関連記事》


┃アプリケーションの動作


■ AppWindow.scala

    
tips342_colorTabbedPane/scala/src/AppWindow.scala
1: /* 2: * Copyright (c) 2010-2013, KOTSUBU-chan and/or its affiliates. 3: * Copyright (c) 1998, Atelier-AYA. 4: * All rights reserved. 5: */ 6: package cherry.pie 7: 8: // ---------------------------------------- 9: import swing._ 10: object appWindow extends MainFrame { 11: val version = appWindow 12: .getClass.getName+": #1.0.04 a2" 13: // ---------------------------------------- 14: title = "TabbedPane" 15: contents = TopPanel 16: peer.setLocationRelativeTo(null) 17: } 18: 19: // ---------------------------------------- 20: object TopPanel extends FlowPanel { 21: new TabbedPane { 22: contents += this 23: preferredSize = new Dimension(200, 100) 24: ColorMap.keys foreach { e => 25: pages += new TabbedPane.Page(e, new Panel {}) 26: } 27: listenTo(selection) 28: import swing.event.SelectionChanged 29: reactions += { 30: case SelectionChanged(source: TabbedPane) => 33: val page = source.selection.page 34: page.content.background = ColorMap.color(page.title) 35: } 36: } 37: } 38: 39: // ---------------------------------------- 40: object ColorMap { 41: import java.awt.Color 42: val colorChart = Map( 43: "red" -> Color.red, 44: "green" -> Color.green, 45: "blue" -> Color.blue, 46: "cyan" -> Color.cyan, 47: "magenta" -> Color.magenta, 48: "yellow" -> Color.yellow, 49: "black" -> Color.black, 50: "white" -> Color.white) 51: def keys = colorChart.keys.toList sortWith { _

[22]タブ付きのパネル TabbedPane を用意します。
[25]個別の頁 TabbedPane.Page を用意します。

TOP
》作業中です《

Created: 2010/01/29|Last updated: 2013/12/31 1:47:02