Java.use(better, Scala); tips341_colorComboBox

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


Tips #341

ComboBox



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

《関連記事》

-


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


■ AppWindow.scala

    
tips341_colorComboBox/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" 13: // ---------------------------------------- 14: title = "ComboBox" 15: contents = TopPanel 16: peer.setLocationRelativeTo(null) 17: } 18: 19: // ---------------------------------------- 20: object TopPanel extends FlowPanel { 21: _self => 22: val controlPane = new ComboBox(ColorMap.keys) { 23: listenTo(selection) 24: import swing.event.SelectionChanged 25: reactions += { 26: case SelectionChanged(source: ComboBox[String]) => 27: val key = source.selection.item 28: canvasPane.background = ColorMap.color(key) 29: } 30: } 31: val canvasPane = new Panel { 32: preferredSize = new Dimension(100,100) 33: } 34: new SplitPane { 35: _self.contents += this 36: contents_=(controlPane, canvasPane) 37: // leftComponent = controlPane 38: // rightComponent = canvasPane 39: orientation = Orientation.Vertical 40: dividerLocation = 100 41: } 42: } 43: 44: // ---------------------------------------- 45: object ColorMap { 46: import java.awt.Color 47: val colorChart = Map( 48: "red" -> Color.red, 49: "green" -> Color.green, 50: "blue" -> Color.blue, 51: "cyan" -> Color.cyan, 52: "magenta" -> Color.magenta, 53: "yellow" -> Color.yellow, 54: "black" -> Color.black, 55: "white" -> Color.white) 56: def keys = colorChart.keys.toList sortWith { _

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

TOP
》作業中です《

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