Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: alessandro-aglietti/itis-leonardo-da-vinci
base: 148d7e2129
...
head fork: alessandro-aglietti/itis-leonardo-da-vinci
compare: a7028a67e1
  • 4 commits
  • 290 files changed
  • 0 commit comments
  • 1 contributor
Showing with 19,704 additions and 0 deletions.
  1. BIN  swingset3/lib/AnimatedTransitions.jar
  2. BIN  swingset3/lib/AppFramework.jar
  3. BIN  swingset3/lib/TimingFramework.jar
  4. BIN  swingset3/lib/javaws.jar
  5. BIN  swingset3/lib/swing-worker.jar
  6. BIN  swingset3/lib/swingx.jar
  7. BIN  swingset3/release/swingset3.jar
  8. +22 −0 swingset3/src/META-INF/demolist
  9. 0  swingset3/src/META-INF/services/javax.swing.LookAndFeel
  10. +57 −0 swingset3/src/com/sun/swingset3/AboutBox.java
  11. +344 −0 swingset3/src/com/sun/swingset3/Demo.java
  12. +291 −0 swingset3/src/com/sun/swingset3/DemoPanel.java
  13. +48 −0 swingset3/src/com/sun/swingset3/DemoProperties.java
  14. +370 −0 swingset3/src/com/sun/swingset3/DemoSelectorPanel.java
  15. +131 −0 swingset3/src/com/sun/swingset3/IntroPanel.java
  16. +739 −0 swingset3/src/com/sun/swingset3/SwingSet3.java
  17. +410 −0 swingset3/src/com/sun/swingset3/codeview/CodeStyler.java
  18. +927 −0 swingset3/src/com/sun/swingset3/codeview/CodeViewer.java
  19. +51 −0 swingset3/src/com/sun/swingset3/codeview/Snippet.java
  20. +661 −0 swingset3/src/com/sun/swingset3/codeview/SnippetHighlighter.java
  21. +339 −0 swingset3/src/com/sun/swingset3/codeview/SnippetMap.java
  22. +322 −0 swingset3/src/com/sun/swingset3/codeview/SnippetNavigator.java
  23. +143 −0 swingset3/src/com/sun/swingset3/codeview/SnippetParser.java
  24. +16 −0 swingset3/src/com/sun/swingset3/codeview/resources/CodeViewer.properties
  25. BIN  swingset3/src/com/sun/swingset3/codeview/resources/images/snippetglyph.png
  26. BIN  swingset3/src/com/sun/swingset3/codeview/resources/images/snippetglyph.psd
  27. +129 −0 swingset3/src/com/sun/swingset3/demos/DemoUtilities.java
  28. +238 −0 swingset3/src/com/sun/swingset3/demos/JGridPanel.java
  29. +244 −0 swingset3/src/com/sun/swingset3/demos/JHyperlink.java
  30. +84 −0 swingset3/src/com/sun/swingset3/demos/ResourceManager.java
  31. +132 −0 swingset3/src/com/sun/swingset3/demos/Stacker.java
  32. +226 −0 swingset3/src/com/sun/swingset3/demos/button/ButtonDemo.java
  33. +1 −0  swingset3/src/com/sun/swingset3/demos/button/resources/ButtonDemo.html
  34. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/ButtonDemo.gif
  35. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/blogs.png
  36. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/document-print.png
  37. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/earth_day.gif
  38. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/earth_night.gif
  39. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/edit-find.png
  40. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/redbutton.png
  41. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/redbutton_dark.png
  42. BIN  swingset3/src/com/sun/swingset3/demos/button/resources/images/redbutton_glow.png
  43. +270 −0 swingset3/src/com/sun/swingset3/demos/colorchooser/BezierAnimationPanel.java
  44. +186 −0 swingset3/src/com/sun/swingset3/demos/colorchooser/ColorChooserDemo.java
  45. +11 −0 swingset3/src/com/sun/swingset3/demos/colorchooser/resources/ColorChooserDemo.properties
  46. BIN  swingset3/src/com/sun/swingset3/demos/colorchooser/resources/images/ColorChooserDemo.gif
  47. +445 −0 swingset3/src/com/sun/swingset3/demos/combobox/ComboBoxDemo.java
  48. +42 −0 swingset3/src/com/sun/swingset3/demos/combobox/resources/ComboBoxDemo.properties
  49. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/ComboBoxDemo.gif
  50. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/brenteyes.jpg
  51. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/brenthair.jpg
  52. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/brentmouth.jpg
  53. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/georgeseyes.jpg
  54. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/georgeshair.jpg
  55. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/georgesmouth.jpg
  56. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/hanseyes.jpg
  57. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/hanshair.jpg
  58. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/hansmouth.jpg
  59. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/howardeyes.jpg
  60. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/howardhair.jpg
  61. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/howardmouth.jpg
  62. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jameseyes.jpg
  63. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jameshair.jpg
  64. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jamesmouth.jpg
  65. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jeffeyes.jpg
  66. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jeffhair.jpg
  67. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jeffmouth.jpg
  68. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/joneyes.jpg
  69. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jonhair.jpg
  70. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/jonmouth.jpg
  71. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/laraeyes.jpg
  72. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/larahair.jpg
  73. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/laramouth.jpg
  74. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/larryeyes.jpg
  75. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/larryhair.jpg
  76. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/larrymouth.jpg
  77. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/lisaeyes.jpg
  78. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/lisahair.jpg
  79. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/lisamouth.jpg
  80. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/michaeleyes.jpg
  81. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/michaelhair.jpg
  82. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/michaelmouth.jpg
  83. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/philipeyes.jpg
  84. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/philiphair.jpg
  85. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/philipmouth.jpg
  86. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/scotteyes.jpg
  87. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/scotthair.jpg
  88. BIN  swingset3/src/com/sun/swingset3/demos/combobox/resources/images/scottmouth.jpg
  89. +164 −0 swingset3/src/com/sun/swingset3/demos/dialog/DialogDemo.java
  90. +1 −0  swingset3/src/com/sun/swingset3/demos/dialog/resources/DialogDemo.html
  91. BIN  swingset3/src/com/sun/swingset3/demos/dialog/resources/images/DialogDemo.gif
  92. +153 −0 swingset3/src/com/sun/swingset3/demos/editorpane/EditorPaneDemo.java
  93. +15 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/COPYRIGHT
  94. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/ant.jpg
  95. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/book.jpg
  96. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/bug.jpg
  97. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/bug2.jpg
  98. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/crest.jpg
  99. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/king.jpg
  100. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/micro.jpg
  101. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/Octavo/seaweed.jpg
  102. +121 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/ant.html
  103. +128 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/bug.html
  104. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/editorpane/back.jpg
  105. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/editorpane/forward.jpg
  106. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/book/editorpane/header.jpg
  107. +42 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/index.html
  108. +45 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/king.html
  109. +115 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/preface.html
  110. +62 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/seaweed.html
  111. +37 −0 swingset3/src/com/sun/swingset3/demos/editorpane/book/title.html
  112. +6 −0 swingset3/src/com/sun/swingset3/demos/editorpane/resources/EditorPaneDemo.properties
  113. BIN  swingset3/src/com/sun/swingset3/demos/editorpane/resources/images/EditorPaneDemo.gif
  114. +563 −0 swingset3/src/com/sun/swingset3/demos/filechooser/FileChooserDemo.java
  115. +38 −0 swingset3/src/com/sun/swingset3/demos/filechooser/resources/FileChooserDemo.properties
  116. BIN  swingset3/src/com/sun/swingset3/demos/filechooser/resources/images/FileChooserDemo.gif
  117. BIN  swingset3/src/com/sun/swingset3/demos/filechooser/resources/images/apply.png
  118. BIN  swingset3/src/com/sun/swingset3/demos/filechooser/resources/images/fliphor.png
  119. BIN  swingset3/src/com/sun/swingset3/demos/filechooser/resources/images/flipvert.png
  120. BIN  swingset3/src/com/sun/swingset3/demos/filechooser/resources/images/rotateleft.png
  121. BIN  swingset3/src/com/sun/swingset3/demos/filechooser/resources/images/rotateright.png
  122. +84 −0 swingset3/src/com/sun/swingset3/demos/frame/BusyGlass.java
  123. +252 −0 swingset3/src/com/sun/swingset3/demos/frame/FrameDemo.java
  124. +1 −0  swingset3/src/com/sun/swingset3/demos/frame/resources/FrameDemo.html
  125. BIN  swingset3/src/com/sun/swingset3/demos/frame/resources/images/FrameDemo.gif
  126. +438 −0 swingset3/src/com/sun/swingset3/demos/gridbaglayout/Calculator.java
  127. +98 −0 swingset3/src/com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java
  128. +4 −0 swingset3/src/com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties
  129. BIN  swingset3/src/com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif
  130. +360 −0 swingset3/src/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java
  131. +17 −0 swingset3/src/com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties
  132. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif
  133. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/bananas.png
  134. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png
  135. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/globe.png
  136. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/globe_small.png
  137. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/package.png
  138. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/package_small.png
  139. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png
  140. BIN  swingset3/src/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png
  141. +399 −0 swingset3/src/com/sun/swingset3/demos/list/ListDemo.java
  142. +109 −0 swingset3/src/com/sun/swingset3/demos/list/Permuter.java
  143. +18 −0 swingset3/src/com/sun/swingset3/demos/list/resources/ListDemo.properties
  144. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/ListDemo.gif
  145. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/blue.gif
  146. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/cyan.gif
  147. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/gray.gif
  148. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/green.gif
  149. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/magenta.gif
  150. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/red.gif
  151. BIN  swingset3/src/com/sun/swingset3/demos/list/resources/images/yellow.gif
  152. +246 −0 swingset3/src/com/sun/swingset3/demos/optionpane/OptionPaneDemo.java
  153. +42 −0 swingset3/src/com/sun/swingset3/demos/optionpane/resources/OptionPaneDemo.properties
  154. BIN  swingset3/src/com/sun/swingset3/demos/optionpane/resources/images/OptionPaneDemo.gif
  155. BIN  swingset3/src/com/sun/swingset3/demos/optionpane/resources/images/bottle.gif
  156. +200 −0 swingset3/src/com/sun/swingset3/demos/progressbar/ProgressBarDemo.java
  157. +35 −0 swingset3/src/com/sun/swingset3/demos/progressbar/resources/ProgressBarDemo.properties
  158. BIN  swingset3/src/com/sun/swingset3/demos/progressbar/resources/images/ProgressBarDemo.gif
  159. +138 −0 swingset3/src/com/sun/swingset3/demos/scrollpane/ScrollPaneDemo.java
  160. +11 −0 swingset3/src/com/sun/swingset3/demos/scrollpane/resources/ScrollPaneDemo.properties
  161. +7 −0 swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/COPYRIGHT
  162. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/ScrollPaneDemo.gif
  163. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/colheader.jpg
  164. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/crayons.jpg
  165. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/lowerleft.jpg
  166. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/rowheader.jpg
  167. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/upperleft.jpg
  168. BIN  swingset3/src/com/sun/swingset3/demos/scrollpane/resources/images/upperright.jpg
  169. +303 −0 swingset3/src/com/sun/swingset3/demos/slider/SliderDemo.java
  170. +19 −0 swingset3/src/com/sun/swingset3/demos/slider/resources/SliderDemo.properties
  171. BIN  swingset3/src/com/sun/swingset3/demos/slider/resources/images/SliderDemo.gif
  172. +330 −0 swingset3/src/com/sun/swingset3/demos/spinner/JMandelbrot.java
  173. +69 −0 swingset3/src/com/sun/swingset3/demos/spinner/JPaletteShower.java
  174. +72 −0 swingset3/src/com/sun/swingset3/demos/spinner/JSpinnerPanel.java
  175. +169 −0 swingset3/src/com/sun/swingset3/demos/spinner/MandelbrotControl.java
  176. +102 −0 swingset3/src/com/sun/swingset3/demos/spinner/Palette.java
  177. +172 −0 swingset3/src/com/sun/swingset3/demos/spinner/PaletteChooser.java
  178. +113 −0 swingset3/src/com/sun/swingset3/demos/spinner/SpinnerDemo.java
  179. +15 −0 swingset3/src/com/sun/swingset3/demos/spinner/resources/SpinnerDemo.properties
  180. BIN  swingset3/src/com/sun/swingset3/demos/spinner/resources/images/SpinnerDemo.gif
  181. +293 −0 swingset3/src/com/sun/swingset3/demos/splitpane/SplitPaneDemo.java
  182. +14 −0 swingset3/src/com/sun/swingset3/demos/splitpane/resources/SplitPaneDemo.properties
  183. BIN  swingset3/src/com/sun/swingset3/demos/splitpane/resources/images/SplitPaneDemo.gif
  184. BIN  swingset3/src/com/sun/swingset3/demos/splitpane/resources/images/day.jpg
  185. BIN  swingset3/src/com/sun/swingset3/demos/splitpane/resources/images/night.jpg
  186. +255 −0 swingset3/src/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java
  187. +22 −0 swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/TabbedPaneDemo.properties
  188. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/TabbedPaneDemo.gif
  189. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/blake.gif
  190. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/brooke.gif
  191. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/camille.jpg
  192. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/david.gif
  193. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.gif
  194. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.jpg
  195. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/matthew.gif
  196. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/miranda.jpg
  197. BIN  swingset3/src/com/sun/swingset3/demos/tabbedpane/resources/images/stephen.gif
  198. +333 −0 swingset3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java
  199. +153 −0 swingset3/src/com/sun/swingset3/demos/table/IMDBLink.java
  200. +94 −0 swingset3/src/com/sun/swingset3/demos/table/Link.java
  201. +103 −0 swingset3/src/com/sun/swingset3/demos/table/OscarCandidate.java
  202. +201 −0 swingset3/src/com/sun/swingset3/demos/table/OscarCellRenderers.java
  203. +174 −0 swingset3/src/com/sun/swingset3/demos/table/OscarDataParser.java
  204. +100 −0 swingset3/src/com/sun/swingset3/demos/table/OscarTableModel.java
  205. +604 −0 swingset3/src/com/sun/swingset3/demos/table/TableDemo.java
  206. +22 −0 swingset3/src/com/sun/swingset3/demos/table/resources/TableDemo.properties
  207. +397 −0 swingset3/src/com/sun/swingset3/demos/table/resources/bestpicture
  208. BIN  swingset3/src/com/sun/swingset3/demos/table/resources/images/TableDemo.gif
  209. BIN  swingset3/src/com/sun/swingset3/demos/table/resources/images/goldstar.png
  210. BIN  swingset3/src/com/sun/swingset3/demos/table/resources/images/nominee.png
  211. +1 −0  swingset3/src/com/sun/swingset3/demos/table/resources/oscars.xml
  212. +266 −0 swingset3/src/com/sun/swingset3/demos/textfield/JHistoryTextField.java
  213. +177 −0 swingset3/src/com/sun/swingset3/demos/textfield/TextFieldDemo.java
  214. +7 −0 swingset3/src/com/sun/swingset3/demos/textfield/resources/TextFieldDemo.properties
  215. BIN  swingset3/src/com/sun/swingset3/demos/textfield/resources/images/TextFieldDemo.gif
  216. +148 −0 swingset3/src/com/sun/swingset3/demos/togglebutton/DirectionPanel.java
  217. +268 −0 swingset3/src/com/sun/swingset3/demos/togglebutton/LayoutControlPanel.java
  218. +635 −0 swingset3/src/com/sun/swingset3/demos/togglebutton/ToggleButtonDemo.java
  219. +69 −0 swingset3/src/com/sun/swingset3/demos/togglebutton/resources/ToggleButtonDemo.properties
  220. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/ToggleButtonDemo.gif
  221. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b1.gif
  222. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b1d.gif
  223. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b1p.gif
  224. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b1r.gif
  225. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b2.gif
  226. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b2d.gif
  227. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b2p.gif
  228. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b2r.gif
  229. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b3.gif
  230. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b3d.gif
  231. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b3p.gif
  232. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/b3r.gif
  233. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/bl.gif
  234. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/bldn.gif
  235. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/bm.gif
  236. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/bmdn.gif
  237. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/br.gif
  238. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/brdn.gif
  239. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/c.gif
  240. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/cb.gif
  241. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/cbr.gif
  242. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/cbrs.gif
  243. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/cbs.gif
  244. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/cdn.gif
  245. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/ml.gif
  246. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/mldn.gif
  247. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/mr.gif
  248. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/mrdn.gif
  249. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/rb.gif
  250. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/rbp.gif
  251. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/rbr.gif
  252. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/rbrs.gif
  253. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/rbs.gif
  254. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/tl.gif
  255. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/tldn.gif
  256. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/tm.gif
  257. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/tmdn.gif
  258. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/tr.gif
  259. BIN  swingset3/src/com/sun/swingset3/demos/togglebutton/resources/images/trdn.gif
  260. +155 −0 swingset3/src/com/sun/swingset3/demos/tooltip/ToolTipDemo.java
  261. +10 −0 swingset3/src/com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties
  262. BIN  swingset3/src/com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif
  263. BIN  swingset3/src/com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png
  264. +148 −0 swingset3/src/com/sun/swingset3/demos/tree/TreeDemo.java
  265. +8 −0 swingset3/src/com/sun/swingset3/demos/tree/resources/TreeDemo.properties
  266. BIN  swingset3/src/com/sun/swingset3/demos/tree/resources/images/TreeDemo.gif
  267. +628 −0 swingset3/src/com/sun/swingset3/demos/tree/resources/tree.txt
  268. +165 −0 swingset3/src/com/sun/swingset3/demos/window/WindowDemo.java
  269. +13 −0 swingset3/src/com/sun/swingset3/demos/window/resources/WindowDemo.html
  270. BIN  swingset3/src/com/sun/swingset3/demos/window/resources/images/WindowDemo.gif
  271. +25 −0 swingset3/src/com/sun/swingset3/resources/SwingSet3.properties
  272. +16 −0 swingset3/src/com/sun/swingset3/resources/default.html
  273. BIN  swingset3/src/com/sun/swingset3/resources/images/about.jpg
  274. BIN  swingset3/src/com/sun/swingset3/resources/images/home.png
  275. BIN  swingset3/src/com/sun/swingset3/resources/images/home_notext.png
  276. BIN  swingset3/src/com/sun/swingset3/resources/images/home_text.png
  277. BIN  swingset3/src/com/sun/swingset3/resources/images/splash.png
  278. BIN  swingset3/src/com/sun/swingset3/resources/images/ss3_splash_nointro.png
  279. BIN  swingset3/src/com/sun/swingset3/resources/images/swingset3_icon.png
  280. +82 −0 swingset3/src/com/sun/swingset3/utilities/AnimatingSplitPane.java
  281. +177 −0 swingset3/src/com/sun/swingset3/utilities/ArrowIcon.java
  282. +222 −0 swingset3/src/com/sun/swingset3/utilities/CollapsiblePanel.java
  283. +561 −0 swingset3/src/com/sun/swingset3/utilities/DefaultsDisplay.java
  284. +94 −0 swingset3/src/com/sun/swingset3/utilities/GradientPanel.java
  285. +185 −0 swingset3/src/com/sun/swingset3/utilities/HTMLPanel.java
  286. +87 −0 swingset3/src/com/sun/swingset3/utilities/RoundedBorder.java
  287. +108 −0 swingset3/src/com/sun/swingset3/utilities/RoundedPanel.java
  288. +113 −0 swingset3/src/com/sun/swingset3/utilities/RoundedTitleBorder.java
  289. +159 −0 swingset3/src/com/sun/swingset3/utilities/Utilities.java
  290. +220 −0 swingset3/src/org/jdesktop/swingx/JXPanel.java
View
BIN  swingset3/lib/AnimatedTransitions.jar
Binary file not shown
View
BIN  swingset3/lib/AppFramework.jar
Binary file not shown
View
BIN  swingset3/lib/TimingFramework.jar
Binary file not shown
View
BIN  swingset3/lib/javaws.jar
Binary file not shown
View
BIN  swingset3/lib/swing-worker.jar
Binary file not shown
View
BIN  swingset3/lib/swingx.jar
Binary file not shown
View
BIN  swingset3/release/swingset3.jar
Binary file not shown
View
22 swingset3/src/META-INF/demolist
@@ -0,0 +1,22 @@
+com.sun.swingset3.demos.frame.FrameDemo
+com.sun.swingset3.demos.dialog.DialogDemo
+com.sun.swingset3.demos.window.WindowDemo
+com.sun.swingset3.demos.internalframe.InternalFrameDemo
+com.sun.swingset3.demos.tabbedpane.TabbedPaneDemo
+com.sun.swingset3.demos.scrollpane.ScrollPaneDemo
+com.sun.swingset3.demos.splitpane.SplitPaneDemo
+com.sun.swingset3.demos.gridbaglayout.GridBagLayoutDemo
+com.sun.swingset3.demos.table.TableDemo
+com.sun.swingset3.demos.tree.TreeDemo
+com.sun.swingset3.demos.list.ListDemo
+com.sun.swingset3.demos.togglebutton.ToggleButtonDemo
+com.sun.swingset3.demos.button.ButtonDemo
+com.sun.swingset3.demos.combobox.ComboBoxDemo
+com.sun.swingset3.demos.progressbar.ProgressBarDemo
+com.sun.swingset3.demos.slider.SliderDemo
+com.sun.swingset3.demos.spinner.SpinnerDemo
+com.sun.swingset3.demos.textfield.TextFieldDemo
+com.sun.swingset3.demos.editorpane.EditorPaneDemo
+com.sun.swingset3.demos.colorchooser.ColorChooserDemo
+com.sun.swingset3.demos.optionpane.OptionPaneDemo
+com.sun.swingset3.demos.tooltip.ToolTipDemo
View
0  swingset3/src/META-INF/services/javax.swing.LookAndFeel
No changes.
View
57 swingset3/src/com/sun/swingset3/AboutBox.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+package com.sun.swingset3;
+
+import java.awt.image.BufferedImage;
+import javax.imageio.ImageIO;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author Amy Fowler
+ */
+public class AboutBox extends JPanel {
+ private BufferedImage bgImage;
+
+ public AboutBox() {
+ try {
+ bgImage = ImageIO.read(AboutBox.class.getResource("resources/images/about.jpg"));
+ } catch (Exception ex) {
+ }
+
+
+
+
+ }
+
+}
View
344 swingset3/src/com/sun/swingset3/Demo.java
@@ -0,0 +1,344 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.sun.swingset3;
+
+import java.awt.Component;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.logging.Level;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+/**
+ * Wrapper class which encapsulates a GUI component to be displayed as a
+ * SwingSet3 demo.
+ *
+ * @author Amy Fowler
+ */
+public class Demo {
+
+ public enum State {
+ UNINITIALIZED, INITIALIZING, INITIALIZED, RUNNING, STOPPED, FAILED
+ }
+
+ private static final String IMAGE_EXTENSIONS[] = { ".gif", ".png", ".jpg" };
+
+ public static String deriveCategoryFromPackageName(String className) {
+ String parts[] = className.split("\\.");
+ // return the right-most package name
+ return parts.length >= 2 ? parts[parts.length - 2] : "general";
+ }
+
+ public static String deriveCategoryFromPackageName(Class demoClass) {
+ String packageName = demoClass.getPackage() != null ? demoClass.getPackage().getName() : null;
+ if (packageName != null) {
+ // if root package is swingset3, then remove it
+ String swingsetPackageName = Demo.class.getPackage().getName();
+ if (packageName.startsWith(swingsetPackageName + ".demos.")) {
+ packageName = packageName.replaceFirst(swingsetPackageName + ".demos.", "");
+ }
+ }
+ return packageName != null ? packageName : "general";
+ }
+
+ public static String deriveNameFromClassName(String className) {
+ String simpleName = className.substring(className.lastIndexOf(".") + 1, className.length());
+ return convertToDemoName(simpleName);
+ }
+
+ public static String deriveNameFromClassName(Class demoClass) {
+ String className = demoClass.getSimpleName();
+ return convertToDemoName(className);
+ }
+
+ private static String convertToDemoName(String simpleClassName) {
+ StringBuffer nameBuffer = new StringBuffer();
+ if (simpleClassName.endsWith("Demo")) {
+ nameBuffer.append(simpleClassName.substring(0, simpleClassName.indexOf("Demo")));
+ nameBuffer.append(" ");
+ nameBuffer.append("Demo");
+ }
+ return nameBuffer.toString();
+ }
+
+ private Class<?> demoClass;
+ private String name;
+ private String category;
+ private String shortDescription; // used for tooltips
+ private String iconPath;
+ private Icon icon;
+ private String[] sourceFilePaths;
+ private URL[] sourceFiles;
+
+ private Component component;
+
+ private State state;
+
+ private Exception failException;
+
+ private PropertyChangeSupport pcs;
+
+ public Demo(Class<?> demoClass) {
+ this.demoClass = demoClass;
+
+ initializeProperties();
+ }
+
+ protected void initializeProperties() {
+
+ // First look for DemoProperties annotation if it exists
+ DemoProperties properties = demoClass.getAnnotation(DemoProperties.class);
+ if (properties != null) {
+ this.name = properties.value();
+ this.category = properties.category();
+ this.shortDescription = properties.description();
+ this.iconPath = properties.iconFile();
+ this.sourceFilePaths = properties.sourceFiles();
+ } else {
+ this.name = deriveNameFromClassName(demoClass);
+ this.category = deriveCategoryFromPackageName(demoClass);
+ this.shortDescription = "No demo description, run it to find out...";
+ }
+ state = State.UNINITIALIZED;
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ public Class getDemoClass() {
+ return demoClass;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public Icon getIcon() {
+ if (icon == null) {
+ if (iconPath != null && !iconPath.equals("")) {
+ // icon packageName was specified in DemoProperties annotation
+ icon = getIconFromPath(iconPath);
+ } else {
+ // Look for icon with same name as demo class
+ for (String ext : IMAGE_EXTENSIONS) {
+ icon = getIconFromPath(getIconImagePath(ext));
+ if (icon != null) {
+ break;
+ }
+ }
+ }
+ }
+ return icon;
+ }
+
+ protected String getIconImagePath(String extension) {
+ // by default look for an image with the same name as the demo class
+ return "resources/images/" + demoClass.getSimpleName() + extension;
+ }
+
+ private Icon getIconFromPath(String path) {
+ Icon icon = null;
+ URL imageURL = demoClass.getResource(path);
+ if (imageURL != null) {
+ icon = new ImageIcon(imageURL);
+ }
+ return icon;
+ }
+
+ public String getShortDescription() {
+ return shortDescription;
+ }
+
+ public URL getHTMLDescription() {
+ // by default look for an html file with the same name as the demo class
+ return demoClass.getResource("resources/" + demoClass.getSimpleName() + ".html");
+ }
+
+ public URL[] getSourceFiles() {
+ // If not already cached, then look them up
+ if (sourceFiles == null) {
+ ArrayList<URL> pathURLs = new ArrayList<URL>();
+
+ // Get any names registered in DemoProperties meta-data.
+ // If meta-data is not specified then sourceFilePaths contains
+ // one empty string. In this case we skip it.
+ if (!(sourceFilePaths.length == 1 && sourceFilePaths[0].length() == 0)) {
+ for (String path : sourceFilePaths) {
+ URL url = getClass().getClassLoader().getResource(path);
+ if (url == null) {
+ SwingSet3.logger.log(Level.WARNING, "unable to load source file '" + path + "'");
+ } else {
+ pathURLs.add(url);
+ }
+ }
+ }
+
+ this.sourceFiles = pathURLs.toArray(new URL[pathURLs.size()]);
+ }
+
+ return sourceFiles;
+ }
+
+ void startInitializing() {
+ setState(Demo.State.INITIALIZING);
+ }
+
+ void setDemoComponent(Component component) {
+ if (component != null && !demoClass.isInstance(component)) {
+ setState(State.FAILED);
+ IllegalArgumentException e = new IllegalArgumentException("component must be an instance of " + demoClass.getCanonicalName());
+ failException = e;
+ throw e;
+ }
+ Component old = this.component;
+ this.component = component;
+
+ if (component != null) {
+ init();
+ } else {
+ setState(State.UNINITIALIZED);
+ }
+ pcs.firePropertyChange("demoComponent", old, component);
+
+ }
+
+ public Component createDemoComponent() {
+ Component component = null;
+ try {
+ component = (Component) demoClass.newInstance();
+ setDemoComponent(component);
+ } catch (Exception e) {
+ System.err.println(e);
+ e.printStackTrace();
+ failException = e;
+ setState(State.FAILED);
+ }
+ return component;
+ }
+
+ public Component getDemoComponent() {
+ return component;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ protected void setState(State state) {
+ State oldState = this.state;
+ this.state = state;
+ SwingSet3.logger.log(Level.FINE, "***>" + getName() + ":setState=" + state);
+ pcs.firePropertyChange("state", oldState, state);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener pcl) {
+ pcs.addPropertyChangeListener(pcl);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener pcl) {
+ pcs.removePropertyChangeListener(pcl);
+ }
+
+ private void init() {
+ setState(State.INITIALIZED);
+ try {
+ Method initMethod = demoClass.getMethod("init", (Class[]) null);
+ initMethod.invoke(component, (Object[]) null);
+ } catch (NoSuchMethodException nsme) {
+ // okay, no init method exists
+ } catch (IllegalAccessException iae) {
+ SwingSet3.logger.log(Level.SEVERE, "unable to init demo: " + demoClass.getName(), iae);
+ failException = iae;
+ setState(State.FAILED);
+ } catch (java.lang.reflect.InvocationTargetException ite) {
+ SwingSet3.logger.log(Level.SEVERE, "init method failed for demo: " + demoClass.getName(), ite);
+ failException = ite;
+ setState(State.FAILED);
+ } catch (NullPointerException npe) {
+ SwingSet3.logger.log(Level.SEVERE, "init method called before demo was instantiated: " + demoClass.getName(), npe);
+ failException = npe;
+ setState(State.FAILED);
+ }
+ }
+
+ public void start() {
+
+ try {
+ Method startMethod = demoClass.getMethod("start", (Class[]) null);
+ startMethod.invoke(component, (Object[]) null);
+ setState(State.RUNNING);
+ } catch (NoSuchMethodException nsme) {
+ setState(State.RUNNING);
+ // okay, no start method exists
+ } catch (IllegalAccessException iae) {
+ SwingSet3.logger.log(Level.SEVERE, "unable to start demo: " + demoClass.getName(), iae);
+ failException = iae;
+ setState(State.FAILED);
+ } catch (java.lang.reflect.InvocationTargetException ite) {
+ SwingSet3.logger.log(Level.SEVERE, "start method failed for demo: " + demoClass.getName(), ite);
+ failException = ite;
+ setState(State.FAILED);
+ } catch (NullPointerException npe) {
+ SwingSet3.logger.log(Level.SEVERE, "start method called before demo was instantiated: " + demoClass.getName(), npe);
+ failException = npe;
+ setState(State.FAILED);
+ }
+ }
+
+ public void stop() {
+ setState(State.STOPPED);
+ try {
+ Method stopMethod = demoClass.getMethod("stop", (Class[]) null);
+ stopMethod.invoke(component, (Object[]) null);
+
+ } catch (NoSuchMethodException nsme) {
+ // okay, no stop method exists
+
+ } catch (IllegalAccessException iae) {
+ SwingSet3.logger.log(Level.SEVERE, "unable to stop demo: " + demoClass.getName(), iae);
+ failException = iae;
+ setState(State.FAILED);
+ } catch (java.lang.reflect.InvocationTargetException ite) {
+ SwingSet3.logger.log(Level.SEVERE, "stop method failed for demo: " + demoClass.getName(), ite);
+ failException = ite;
+ setState(State.FAILED);
+ } catch (NullPointerException npe) {
+ SwingSet3.logger.log(Level.SEVERE, "stop method called before demo was instantiated: " + demoClass.getName(), npe);
+ }
+ }
+}
View
291 swingset3/src/com/sun/swingset3/DemoPanel.java
@@ -0,0 +1,291 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.sun.swingset3;
+
+import com.sun.swingset3.utilities.HTMLPanel;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.net.URL;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+
+import org.jdesktop.animation.timing.Animator;
+import org.jdesktop.animation.timing.interpolation.PropertySetter;
+import org.jdesktop.animation.timing.triggers.TimingTrigger;
+import org.jdesktop.animation.timing.triggers.TimingTriggerEvent;
+import org.jdesktop.swingx.JXPanel;
+import com.sun.swingset3.utilities.RoundedBorder;
+import com.sun.swingset3.utilities.RoundedPanel;
+import com.sun.swingset3.utilities.RoundedTitleBorder;
+import com.sun.swingset3.utilities.Utilities;
+
+/**
+ *
+ * @author aim
+ */
+public class DemoPanel extends JXPanel {
+ private static final Border roundedBorder = new RoundedBorder(10);
+ private static final Insets margin = new Insets(8, 10, 8, 8);
+
+ private Demo demo;
+
+ public DemoPanel(Demo demo) {
+ this.demo = demo;
+ setLayout(new BorderLayout());
+ // remind(aim): how to access resourceMap?
+ //resourceMap = getContext().getResourceMap();
+
+ LoadAnimationPanel loadAnimationPanel = new LoadAnimationPanel();
+
+ add(loadAnimationPanel);
+ loadAnimationPanel.setAnimating(true);
+
+ LoadedDemoPanel demoPanel = new LoadedDemoPanel(demo);
+
+ try {
+ loadAnimationPanel.setAnimating(false);
+ Animator fadeOutAnimator = new Animator(400,
+ new FadeOut(DemoPanel.this,
+ loadAnimationPanel, demoPanel));
+ fadeOutAnimator.setAcceleration(.2f);
+ fadeOutAnimator.setDeceleration(.3f);
+ Animator fadeInAnimator = new Animator(400,
+ new PropertySetter(DemoPanel.this, "alpha", 0.3f, 1.0f));
+ TimingTrigger.addTrigger(fadeOutAnimator, fadeInAnimator, TimingTriggerEvent.STOP);
+ fadeOutAnimator.start();
+ } catch (Exception ignore) {
+ System.err.println(ignore);
+ ignore.printStackTrace();
+ }
+ }
+
+ public Demo getDemo() {
+ return demo;
+ }
+
+ private static class FadeOut extends PropertySetter {
+ private JXPanel parent;
+ private JXPanel out;
+ private JComponent in;
+
+ public FadeOut(JXPanel parent, JXPanel out, JComponent in) {
+ super(out, "alpha", 1.0f, 0.3f);
+ this.parent = parent;
+ this.out = out;
+ this.in = in;
+ }
+
+ public void end() {
+ parent.setAlpha(0.3f);
+ parent.remove(out);
+ parent.add(in);
+ parent.revalidate();
+ }
+ } // Fader
+
+ private static class LoadAnimationPanel extends RoundedPanel {
+ private String message;
+ private int triState = 0;
+ private boolean animating = false;
+ private Animator animator;
+
+ public LoadAnimationPanel() {
+ super(10);
+ setBorder(roundedBorder);
+ setBackground(Utilities.deriveColorHSB(
+ UIManager.getColor("Panel.background"), 0, 0, -.06f));
+
+ // remind(aim): get from resource map
+ message = "demo loading";
+
+ PropertySetter rotator = new PropertySetter(this, "triState", 0, 3);
+ animator = new Animator(500, Animator.INFINITE,
+ Animator.RepeatBehavior.LOOP, rotator);
+ // Don't animate gears if loading is quick
+ animator.setStartDelay(200);
+ }
+
+ public void setAnimating(boolean animating) {
+ this.animating = animating;
+ if (animating) {
+ animator.start();
+ } else {
+ animator.stop();
+ }
+ }
+
+ public boolean isAnimating() {
+ return animating;
+ }
+
+ public void setTriState(int triState) {
+ this.triState = triState;
+ repaint();
+ }
+
+ public int getTriState() {
+ return triState;
+ }
+
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Graphics2D g2 = (Graphics2D) g.create();
+ Dimension size = getSize();
+
+ Color textColor = Utilities.deriveColorHSB(getBackground(), 0, 0, -.3f);
+ Color dotColor = Utilities.deriveColorHSB(textColor, 0, .2f, -.08f);
+ g2.setColor(textColor);
+ g2.setFont(UIManager.getFont("Label.font").deriveFont(32f));
+ FontMetrics metrics = g2.getFontMetrics();
+ Rectangle2D rect = metrics.getStringBounds(message, g2);
+ Rectangle2D dotRect = metrics.getStringBounds(".", g2);
+ float x = (float) (size.width - (rect.getWidth() + 3 * dotRect.getWidth())) / 2;
+ float y = (float) (size.height - rect.getHeight()) / 2;
+ g2.drawString(message, x, y);
+ int tri = getTriState();
+ float dx = 0;
+ for (int i = 0; i < 3; i++) {
+ g2.setColor(animator.isRunning() && i == tri ?
+ dotColor :
+ textColor);
+ g2.drawString(".", x + (float) (rect.getWidth() + dx), y);
+ dx += dotRect.getWidth();
+ }
+ }
+ } // LoadAnimationPanel
+
+ private static class LoadedDemoPanel extends RoundedPanel {
+ private String demoName;
+ private JComponent descriptionArea;
+ private JComponent demoPanel;
+
+ public LoadedDemoPanel(Demo demo) {
+ super(10);
+ setLayout(null);
+ demoName = demo.getName();
+
+ URL description = demo.getHTMLDescription();
+ if (description != null) {
+ descriptionArea = createDescriptionArea(description);
+ add(descriptionArea);
+
+ demoPanel = new RoundedPanel(new BorderLayout());
+ demoPanel.setBorder(roundedBorder);
+
+ } else {
+ // no description
+ demoPanel = new JXPanel(new BorderLayout());
+ }
+ demoPanel.add(demo.createDemoComponent());
+ add(demoPanel);
+
+ applyDefaults();
+ }
+
+ private static JComponent createDescriptionArea(URL descriptionURL) {
+ JEditorPane descriptionPane = new HTMLPanel();
+ descriptionPane.setEditable(false);
+ descriptionPane.setMargin(margin);
+ descriptionPane.setOpaque(true);
+ try {
+ descriptionPane.setPage(descriptionURL);
+ } catch (IOException e) {
+ System.err.println("couldn't load description from URL:" + descriptionURL);
+ }
+ return descriptionPane;
+ }
+
+ @Override
+ public void doLayout() {
+ if (demoPanel != null) {
+ Dimension size = getSize();
+ Insets insets = getInsets();
+
+ if (descriptionArea == null) {
+ // Make demo fill entire area within border
+ demoPanel.setBounds(insets.left, insets.top,
+ size.width - insets.left - insets.right,
+ size.height - insets.top - insets.bottom);
+ } else {
+ // Split space between HTML description and running demo
+ Dimension demoSize = demoPanel.getPreferredSize();
+ int margin = insets.top / 2;
+ Rectangle bounds = new Rectangle();
+ bounds.width = Math.max(demoSize.width, (int) (size.width * .50));
+ bounds.height = Math.max(demoSize.height, size.height -
+ 2 * margin);
+ bounds.x = size.width - bounds.width - margin;
+ bounds.y = margin;
+ demoPanel.setBounds(bounds);
+ descriptionArea.setBounds(insets.left, insets.top,
+ size.width - margin - insets.right - bounds.width,
+ size.height - insets.top - insets.bottom);
+ }
+ }
+ }
+
+ @Override
+ public void updateUI() {
+ super.updateUI();
+ applyDefaults();
+ }
+
+ private void applyDefaults() {
+ setBorder(new RoundedTitleBorder(demoName,
+ UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR1_KEY),
+ UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR2_KEY)));
+
+ setFont(UIManager.getFont(SwingSet3.TITLE_FONT_KEY));
+ Color bg = Utilities.deriveColorHSB(
+ UIManager.getColor("Panel.background"), 0, 0, -.06f);
+ setBackground(bg);
+ setForeground(UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
+ if (demoPanel != null) {
+ demoPanel.setBackground(Utilities.deriveColorHSB(bg, 0, 0, .04f));
+ }
+ if (descriptionArea != null) {
+ descriptionArea.setBackground(bg);
+ }
+ }
+ }
+}
View
48 swingset3/src/com/sun/swingset3/DemoProperties.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.sun.swingset3;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Annotation type for specifying meta-data about Demo
+ * @author aim
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DemoProperties {
+ String value(); // Name
+ String category();
+ String description();
+ String iconFile() default "";
+ String[] sourceFiles() default "";
+}
View
370 swingset3/src/com/sun/swingset3/DemoSelectorPanel.java
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.sun.swingset3;
+
+import com.sun.swingset3.utilities.GradientPanel;
+import com.sun.swingset3.utilities.CollapsiblePanel;
+import com.sun.swingset3.utilities.ArrowIcon;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import javax.swing.AbstractButton;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JToggleButton;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.MatteBorder;
+import com.sun.swingset3.utilities.Utilities;
+
+/**
+ *
+ * @author Administrator
+ */
+public class DemoSelectorPanel extends JPanel {
+ private static final Border chiselBorder = new ChiselBorder();
+ private static final Border panelBorder = new CompoundBorder(
+ chiselBorder, new EmptyBorder(6,8,6,0));
+ private static final Border categoryBorder = new CompoundBorder(
+ chiselBorder, new EmptyBorder(0,0,10,0));
+ private static final Border buttonBorder = new CompoundBorder(
+ new DemoButtonBorder(), new EmptyBorder(0, 18, 0, 0));
+
+ private GradientPanel titlePanel;
+ private JLabel demoListLabel;
+ private JPanel viewPanel;
+ private JScrollPane scrollPane;
+ // need to track components that have defaults customizations
+ private final List<CollapsiblePanel> collapsePanels = new ArrayList<CollapsiblePanel>();
+ private Icon expandedIcon;
+ private Icon collapsedIcon;
+ private Color visitedForeground;
+ private Color failedForeground;
+
+ private ButtonGroup group;
+ private final ActionListener demoActionListener = new DemoActionListener();
+ private int buttonHeight = 0;
+
+ private Demo selectedDemo;
+
+ public DemoSelectorPanel(String demoSetTitle, List<Demo> demoSet) {
+ super(new BorderLayout());
+
+ visitedForeground = new Color(100, 100, 150);
+ failedForeground = new Color(245, 20, 80);
+
+ // only one demo may be selected at a time
+ group = new ButtonGroup();
+
+ // create demo set title area at top
+ add(createTitleArea(demoSetTitle), BorderLayout.NORTH);
+
+ // create scrollable demo panel at bottom
+ JComponent selector = createDemoSelector(demoSet);
+ scrollPane = new JScrollPane(selector);
+ scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ add(scrollPane, BorderLayout.CENTER);
+
+ applyDefaults();
+ }
+
+ protected JComponent createTitleArea(String demoSetTitle) {
+ JPanel titleAreaPanel = new JPanel(new BorderLayout());
+ titlePanel = new GradientPanel(
+ UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR1_KEY),
+ UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR2_KEY));
+ titlePanel.setLayout(new BorderLayout());
+ titlePanel.setBorder(panelBorder);
+ demoListLabel = new JLabel(demoSetTitle);
+ demoListLabel.setOpaque(false);
+ demoListLabel.setHorizontalAlignment(JLabel.LEADING);
+ titlePanel.add(demoListLabel, BorderLayout.CENTER);
+ titleAreaPanel.add(titlePanel, BorderLayout.NORTH);
+
+ // Add panel with view combobox
+ viewPanel = new JPanel();
+ viewPanel.setLayout(new BoxLayout(viewPanel, BoxLayout.X_AXIS));
+ viewPanel.setBorder(new CompoundBorder(chiselBorder,
+ new EmptyBorder(12,8,12,8)));
+ JLabel viewLabel = new JLabel("View:");
+ viewPanel.add(viewLabel);
+ viewPanel.add(Box.createHorizontalStrut(6));
+ JComboBox viewComboBox = new JComboBox();
+ viewComboBox.addItem("by category");
+ viewPanel.add(viewComboBox);
+ titleAreaPanel.add(viewPanel, BorderLayout.CENTER);
+
+ return titleAreaPanel;
+ }
+
+ protected JComponent createDemoSelector(List<Demo> demoSet) {
+ JPanel selectorPanel = new JPanel();
+ GridBagLayout gridbag = new GridBagLayout();
+ selectorPanel.setLayout(gridbag);
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = c.gridy = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+
+ HashMap<String,JPanel> categoryMap = new HashMap<String,JPanel>();
+ GridBagLayout categoryGridbag = null;
+ GridBagConstraints cc = new GridBagConstraints();
+ cc.gridx = cc.gridy = 0;
+ cc.weightx = 1;
+ cc.fill = GridBagConstraints.HORIZONTAL;
+ CollapsiblePanel collapsePanel;
+ for(Demo demo: demoSet) {
+ String category = demo.getCategory();
+ JPanel categoryPanel = categoryMap.get(category);
+ if (categoryPanel == null) {
+ // Create category collapsible panel
+ categoryPanel = new JPanel();
+ categoryGridbag = new GridBagLayout();
+ categoryPanel.setLayout(categoryGridbag);
+ collapsePanel = new CollapsiblePanel(categoryPanel, category,
+ "click to expand or contract category");
+ collapsePanels.add(collapsePanel);
+ collapsePanel.setBorder(categoryBorder);
+ categoryMap.put(category, categoryPanel);
+ gridbag.addLayoutComponent(collapsePanel, c);
+ selectorPanel.add(collapsePanel);
+ c.gridy++;
+ }
+ DemoButton demoButton = new DemoButton(demo);
+ categoryGridbag.addLayoutComponent(demoButton, cc);
+ cc.gridy++;
+ group.add(demoButton);
+ categoryPanel.add(demoButton);
+ if (buttonHeight == 0) {
+ buttonHeight = demoButton.getPreferredSize().height;
+ }
+ }
+ // add empty component to take up any extra room on bottom
+ JPanel trailer = new JPanel();
+ c.weighty = 1.0;
+ gridbag.addLayoutComponent(trailer, c);
+ selectorPanel.add(trailer);
+
+ applyDefaults();
+
+ return selectorPanel;
+ }
+
+ public void updateUI() {
+ super.updateUI();
+ applyDefaults();
+ }
+
+ protected void applyDefaults() {
+
+ expandedIcon = new ArrowIcon(ArrowIcon.SOUTH,
+ UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
+ collapsedIcon = new ArrowIcon(ArrowIcon.EAST,
+ UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
+
+ setBorder(new MatteBorder(0,0,0,1,
+ UIManager.getColor(SwingSet3.CONTROL_MID_SHADOW_KEY)));
+
+ if (titlePanel != null) {
+ titlePanel.setGradientColor1(
+ UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR1_KEY));
+ titlePanel.setGradientColor2(
+ UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR2_KEY));
+ }
+
+ if (demoListLabel != null) {
+ demoListLabel.setForeground(UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
+ demoListLabel.setFont(UIManager.getFont(SwingSet3.TITLE_FONT_KEY));
+ }
+ if (viewPanel != null) {
+ viewPanel.setBackground(UIManager.getColor(SwingSet3.SUB_PANEL_BACKGROUND_KEY));
+ }
+ if (collapsePanels != null) {
+ for (CollapsiblePanel collapsePanel : collapsePanels) {
+ collapsePanel.setFont(
+ UIManager.getFont("CheckBox.font").deriveFont(Font.BOLD));
+ collapsePanel.setForeground(UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
+ collapsePanel.setExpandedIcon(expandedIcon);
+ collapsePanel.setCollapsedIcon(collapsedIcon);
+ }
+ }
+ revalidate();
+ }
+
+ public Demo getSelectedDemo() {
+ return selectedDemo;
+ }
+
+ protected void setSelectedDemo(Demo demo) {
+ Demo oldSelectedDemo = selectedDemo;
+ selectedDemo = demo;
+ firePropertyChange("selectedDemo", oldSelectedDemo, demo);
+ }
+
+ private class DemoButton extends JToggleButton {
+ private Demo demo;
+
+ public DemoButton(Demo demo) {
+ super();
+ this.demo = demo;
+ String demoName = demo.getName();
+ if (demoName.endsWith("Demo")) {
+ setText(demoName.substring(0, demoName.indexOf("Demo")));
+ } else {
+ setText(demoName);
+ }
+ setIcon(demo.getIcon());
+ setIconTextGap(10);
+ setHorizontalTextPosition(JToggleButton.TRAILING);
+ setHorizontalAlignment(JToggleButton.LEADING);
+ setOpaque(false);
+ setBorder(buttonBorder);
+ setFocusPainted(false);
+ setContentAreaFilled(false);
+ setToolTipText(demo.getShortDescription());
+ addActionListener(demoActionListener);
+ }
+
+ @Override
+ public void updateUI() {
+ super.updateUI();
+ // some look and feels replace our border, so take it back
+ setBorder(buttonBorder);
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ if (isSelected()) {
+ setBackground(UIManager.getColor("Tree.selectionBackground"));
+ g.setColor(UIManager.getColor("Tree.selectionBackground"));
+ Dimension size = getSize();
+ g.fillRect(0, 0, size.width, size.height);
+ setForeground(UIManager.getColor("Tree.selectionForeground"));
+ } else {
+ setBackground(UIManager.getColor("ToggleButton.background"));
+ Color foreground = UIManager.getColor("ToggleButton.foreground");
+ switch(demo.getState()) {
+ case STOPPED: {
+ foreground = visitedForeground;
+ break;
+ }
+ case FAILED: {
+ foreground = failedForeground;
+ }
+ }
+ setForeground(foreground);
+ }
+ super.paintComponent(g);
+ }
+
+ public Demo getDemo() {
+ return demo;
+ }
+ }
+
+ private class DemoActionListener implements ActionListener {
+ public void actionPerformed(ActionEvent event) {
+ DemoButton demoButton = (DemoButton)event.getSource();
+ setSelectedDemo(demoButton.getDemo());
+ }
+ }
+
+ private static class DemoButtonBorder implements Border {
+ private Insets insets = new Insets(2, 1, 1, 1);
+
+ public DemoButtonBorder() {
+ }
+
+ public Insets getBorderInsets(Component c) {
+ return insets;
+ }
+ public boolean isBorderOpaque() {
+ return true;
+ }
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ AbstractButton b = (AbstractButton)c;
+ if (b.isSelected()) {
+ Color color = c.getBackground();
+ g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.20f));
+ g.drawLine(x, y, x + width, y);
+ g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.10f));
+ g.drawLine(x, y + 1, x + width, y + 1);
+ g.drawLine(x, y + 2, x, y + height - 2);
+ g.setColor(Utilities.deriveColorHSB(color, 0, 0, .24f));
+ g.drawLine(x, y + height - 1, x + width, y + height-1);
+ }
+ }
+ }
+
+ private static class ChiselBorder implements Border {
+ private Insets insets = new Insets(1, 0, 1, 0);
+
+ public ChiselBorder() {
+ }
+
+ public Insets getBorderInsets(Component c) {
+ return insets;
+ }
+ public boolean isBorderOpaque() {
+ return true;
+ }
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ Color color = c.getBackground();
+ // render highlight at top
+ g.setColor(Utilities.deriveColorHSB(color, 0, 0, .2f));
+ g.drawLine(x, y, x + width, y);
+ // render shadow on bottom
+ g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.2f));
+ g.drawLine(x, y + height - 1, x + width, y + height - 1);
+ }
+ }
+}
View
131 swingset3/src/com/sun/swingset3/IntroPanel.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.sun.swingset3;
+
+import com.sun.swingset3.utilities.RoundedPanel;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import org.jdesktop.animation.timing.Animator;
+import org.jdesktop.animation.timing.interpolation.PropertySetter;
+
+/**
+ *
+ * @author Amy Fowler
+ */
+public class IntroPanel extends RoundedPanel {
+ private JLabel introImage;
+ private SlidingLabel introText;
+
+ public IntroPanel() {
+ setLayout(null);
+ setOpaque(false);
+
+ introImage = new JLabel(new ImageIcon(
+ SwingSet3.class.getResource("resources/images/home_notext.png")));
+ introImage.setVerticalAlignment(JLabel.TOP);
+
+ introText = new SlidingLabel(new ImageIcon(
+ SwingSet3.class.getResource("resources/images/home_text.png")));
+ introText.setVisible(false);
+
+ introImage.addMouseListener(new MouseAdapter() {
+ public void mousePressed(MouseEvent event) {
+ slideTextIn();
+ }
+ });
+
+ add(introText);
+ add(introImage);
+ }
+
+ @Override
+ public void doLayout() {
+ Dimension size = getSize();
+ Insets insets = getInsets();
+ int w = size.width - insets.left - insets.right;
+
+ Dimension prefSize = introImage.getPreferredSize();
+ introImage.setBounds(0, 0, prefSize.width, prefSize.height);
+
+ if (introText.isVisible()) {
+ prefSize = introText.getPreferredSize();
+ introText.setBounds(introText.getX(), introText.getY(),
+ prefSize.width, prefSize.height);
+ }
+
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+ if (!introText.isVisible()) {
+ introText.setLocation(1000, 110);
+ introText.setVisible(true);
+ slideTextIn();
+ }
+ }
+
+ public void slideTextIn() {
+ Animator animator = new Animator(800,
+ new PropertySetter(introText, "x", getWidth(), 30));
+ animator.setStartDelay(800);
+ animator.setAcceleration(.2f);
+ animator.setDeceleration(.5f);
+ animator.start();
+ }
+
+ public void slideTextOut() {
+ Animator animator = new Animator(600,
+ new PropertySetter(introText, "x", introText.getX(), -introText.getWidth()));
+ animator.setStartDelay(10);
+ animator.setAcceleration(.5f);
+ animator.setDeceleration(.2f);
+ animator.start();
+ }
+
+ public class SlidingLabel extends JLabel {
+ public SlidingLabel(Icon icon) {
+ super(icon);
+ }
+
+ public void setX(int x) {
+ setLocation(x, getY());
+ revalidate();
+ }
+ }
+}
View
739 swingset3/src/com/sun/swingset3/SwingSet3.java
@@ -0,0 +1,739 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Sun Microsystems nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.sun.swingset3;
+
+import com.sun.swingset3.utilities.AnimatingSplitPane;
+import com.sun.swingset3.utilities.Utilities;
+import org.jdesktop.application.Action;
+import org.jdesktop.application.ResourceMap;
+import org.jdesktop.application.SingleFrameApplication;
+import org.jdesktop.application.View;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.swing.AbstractAction;
+import javax.swing.ButtonGroup;
+import javax.swing.ButtonModel;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import com.sun.swingset3.codeview.CodeViewer;
+import com.sun.swingset3.utilities.RoundedBorder;
+import com.sun.swingset3.utilities.RoundedPanel;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+/**
+ *
+ * @author Amy Fowler
+ */
+public class SwingSet3 extends SingleFrameApplication {
+ static final Logger logger = Logger.getLogger(SwingSet3.class.getName());
+
+ private static final ServiceLoader<LookAndFeel> LOOK_AND_FEEL_LOADER = ServiceLoader.load(LookAndFeel.class);
+
+ public static String title;
+
+ public static final String CONTROL_VERY_LIGHT_SHADOW_KEY = "controlVeryLightShadowColor";
+ public static final String CONTROL_LIGHT_SHADOW_KEY = "controlLightShadowColor";
+ public static final String CONTROL_MID_SHADOW_KEY = "controlMidShadowColor";
+ public static final String CONTROL_VERY_DARK_SHADOW_KEY = "controlVeryDarkShadowColor";
+ public static final String CONTROL_DARK_SHADOW_KEY = "controlDarkShadowColor";
+ public static final String TITLE_GRADIENT_COLOR1_KEY = "titleGradientColor1";
+ public static final String TITLE_GRADIENT_COLOR2_KEY = "titleGradientColor2";
+ public static final String TITLE_FOREGROUND_KEY = "titleForegroundColor";
+ public static final String CODE_HIGHLIGHT_KEY = "codeHighlightColor";
+ public static final String TITLE_FONT_KEY = "titleFont";
+ public static final String SUB_PANEL_BACKGROUND_KEY = "subPanelBackgroundColor";
+
+ public static final int MAIN_FRAME_WIDTH = 880;
+ public static final int MAIN_FRAME_HEIGHT = 640;
+ public static final int DEMO_SELECTOR_WIDTH = 186;
+ public static final int DEMO_PANEL_HEIGHT = 400;
+ public static final int DEMO_PANEL_WIDTH = MAIN_FRAME_WIDTH - DEMO_SELECTOR_WIDTH;
+
+ private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
+ private static final Border PANEL_BORDER = new EmptyBorder(10, 10, 10, 10);
+
+ private static final String DEMO_LIST_FILE = "/META-INF/demolist";
+
+ static {
+ // Property must be set *early* due to Apple Bug#3909714
+ if (System.getProperty("os.name").equals("Mac OS X")) {
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ }
+
+ // temporary workaround for problem with Nimbus classname
+ UIManager.LookAndFeelInfo lafInfo[] = UIManager.getInstalledLookAndFeels();
+ for(int i = 0; i < lafInfo.length; i++) {
+ if (lafInfo[i].getName().equals("Nimbus")) {
+ lafInfo[i] = new UIManager.LookAndFeelInfo("Nimbus",
+ "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
+ break;
+ }
+ }
+ UIManager.setInstalledLookAndFeels(lafInfo);
+ UIManager.put("swing.boldMetal", Boolean.FALSE);
+ }
+
+ public static void main(String[] args) {
+ launch(SwingSet3.class, args);
+ }
+
+ public static boolean runningOnMac() {
+ return System.getProperty("os.name").equals("Mac OS X");
+ }
+
+ public static boolean usingNimbus() {
+ return UIManager.getLookAndFeel().getName().equals("Nimbus");
+ }
+
+ private static List<String> readDemoClassNames(Reader reader) throws IOException {
+ List<String> demoClassNames = new ArrayList<String>();
+
+ BufferedReader breader = new BufferedReader(reader);
+ String line;
+ while((line = breader.readLine()) != null) {
+ demoClassNames.add(line);
+ }
+ breader.close();
+ return demoClassNames;
+ }
+ // End of statics
+
+ private ResourceMap resourceMap;
+
+ // Application models
+ private String demoListTitle;
+ private List<Demo> demoList;
+ private PropertyChangeListener demoPropertyChangeListener;
+ private Map<String, DemoPanel> runningDemoCache;
+ private Demo currentDemo;
+
+ // GUI components
+ private JPanel mainPanel;
+ private DemoSelectorPanel demoSelectorPanel;
+ private AnimatingSplitPane demoSplitPane;
+ private JPanel demoContainer;
+ private JComponent currentDemoPanel;
+ private JComponent demoPlaceholder;
+ private JPanel codeContainer;
+ private CodeViewer codeViewer;
+ private JCheckBoxMenuItem sourceCodeCheckboxItem;
+ private ButtonGroup lookAndFeelRadioGroup;
+
+ private JPopupMenu popup;
+
+ // Properties
+ private String lookAndFeel;
+ private boolean sourceVisible = true;
+
+ @Override
+ protected void initialize(String args[]) {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
+ } catch (Exception ex) {
+ // not catestrophic
+ }
+ resourceMap = getContext().getResourceMap();
+
+ title = resourceMap.getString("mainFrame.title");
+ runningDemoCache = new HashMap<String, DemoPanel>();
+ setDemoList(resourceMap.getString("demos.title"), getDemoClassNames(args));
+
+ IntroPanel intro = new IntroPanel();
+ setDemoPlaceholder(intro);
+
+ }
+
+ private List<String>getDemoClassNames(String args[]) {
+ List<String> demoList = new ArrayList<String>();
+ boolean augment = false;
+ Exception exception = null;
+
+ // First look for any demo list files specified on the command-line
+ for(String arg : args) {
+ if (arg.equals("-a") || arg.equals("-augment")) {
+ augment = true;
+ } else {
+ // process argument as filename containing names of demo classes
+ try {
+ demoList.addAll(readDemoClassNames(new FileReader(arg) /*filename*/));
+ } catch (IOException ex) {
+ exception = ex;
+ logger.log(Level.WARNING, "unable to read demo class names from file: "+arg, ex);
+ }
+ }
+ }
+
+ if (demoList.isEmpty() || augment) {
+ // Load default Demos
+ try {
+ demoList.addAll(readDemoClassNames(new InputStreamReader(getClass().getResourceAsStream(DEMO_LIST_FILE))));
+ } catch (IOException ex) {
+ exception = ex;
+ logger.log(Level.WARNING, "unable to read resource: " + DEMO_LIST_FILE, ex);
+ }
+ }
+
+ if (demoList.isEmpty()) {
+ displayErrorMessage(resourceMap.getString("error.noDemosLoaded"),
+ exception);
+ }
+ return demoList;
+
+ }
+
+ public void setDemoList(String demoListTitle, List<String> demoClassNamesList) {
+ List<Demo> demoList = new ArrayList<Demo>();
+ for(String demoClassName: demoClassNamesList) {
+ Demo demo = createDemo(demoClassName);
+
+ if (demo != null) {
+ demoList.add(demo);
+ }
+ }
+ this.demoListTitle = demoListTitle;
+ this.demoList = demoList;
+ }
+
+ /**
+ */
+ protected Demo createDemo(String demoClassName) {
+ Class<?> demoClass = null;
+ Demo demo = null;
+ try {
+ demoClass = Class.forName(demoClassName);
+ } catch (ClassNotFoundException cnfe) {
+ logger.log(Level.WARNING, "demo class not found:"+ demoClassName);
+ }
+ if (demoClass != null) {
+ // Wrap Demo
+ demo = new Demo(demoClass);
+ demo.addPropertyChangeListener(getDemoPropertyChangeListener());
+ }
+ return demo;
+ }
+
+ protected PropertyChangeListener getDemoPropertyChangeListener() {
+ if (demoPropertyChangeListener == null) {
+ demoPropertyChangeListener = new DemoPropertyChangeListener();
+ }
+ return demoPropertyChangeListener;
+ }
+
+ @Override
+ protected void startup() {
+ UIManager.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getPropertyName().equals("lookAndFeel")) {
+ configureDefaults();
+ }
+ }
+ });
+
+ configureDefaults();
+
+ View view = getMainView();
+ view.setComponent(createMainPanel());
+ view.setMenuBar(createMenuBar());
+
+ applyDefaults();
+
+ // application framework should handle this
+ getMainFrame().setIconImage(resourceMap.getImageIcon("Application.icon").getImage());
+
+ show(view);
+ }
+
+ private void configureDefaults() {
+
+ // Color palette algorithm courtesy of Jasper Potts
+ Color controlColor = UIManager.getColor("control");
+
+ UIManager.put(CONTROL_VERY_LIGHT_SHADOW_KEY,
+ Utilities.deriveColorHSB(controlColor, 0, 0, -0.02f));
+ UIManager.put(CONTROL_LIGHT_SHADOW_KEY,
+ Utilities.deriveColorHSB(controlColor, 0, 0, -0.06f));
+ UIManager.put(CONTROL_MID_SHADOW_KEY,
+ Utilities.deriveColorHSB(controlColor, 0, 0, -0.16f));
+ UIManager.put(CONTROL_VERY_DARK_SHADOW_KEY,
+ Utilities.deriveColorHSB(controlColor, 0, 0, -0.5f));
+ UIManager.put(CONTROL_DARK_SHADOW_KEY,
+ Utilities.deriveColorHSB(controlColor, 0, 0, -0.32f));
+
+ // Calculate gradient colors for title panels
+ Color titleColor = UIManager.getColor(usingNimbus()? "nimbusBase" : "activeCaption");
+
+ // Some LAFs (e.g. GTK) don't contain "activeCaption"
+ if (titleColor == null) {
+ titleColor = controlColor;
+ }
+ float hsb[] = Color.RGBtoHSB(
+ titleColor.getRed(), titleColor.getGreen(), titleColor.getBlue(), null);
+ UIManager.put(TITLE_GRADIENT_COLOR1_KEY,
+ Color.getHSBColor(hsb[0]-.013f, .15f, .85f));
+ UIManager.put(TITLE_GRADIENT_COLOR2_KEY,
+ Color.getHSBColor(hsb[0]-.005f, .24f, .80f));
+ UIManager.put(TITLE_FOREGROUND_KEY,
+ Color.getHSBColor(hsb[0], .54f, .40f));
+
+ // Calculate highlight color for code pane
+ UIManager.put(CODE_HIGHLIGHT_KEY,
+ Color.getHSBColor(hsb[0]-.005f, .20f, .95f));
+
+ Font labelFont = UIManager.getFont("Label.font");
+ UIManager.put(TITLE_FONT_KEY, labelFont.deriveFont(Font.BOLD, labelFont.getSize()+4f));
+
+ Color panelColor = UIManager.getColor("Panel.background");
+ UIManager.put(SUB_PANEL_BACKGROUND_KEY,
+ Utilities.deriveColorHSB(panelColor, 0, 0, -.06f));
+
+ applyDefaults();
+
+ }
+
+ protected void applyDefaults() {
+ if (codeViewer != null) {
+ codeViewer.setHighlightColor(UIManager.getColor(CODE_HIGHLIGHT_KEY));
+ }
+ }
+
+ protected JComponent createMainPanel() {
+
+ // Create main panel with demo selection on left and demo/source on right
+ mainPanel = new JPanel();
+ mainPanel.setLayout(new BorderLayout());
+
+ // Create demo selector panel on left
+ demoSelectorPanel = new DemoSelectorPanel(demoListTitle, demoList);
+ demoSelectorPanel.setPreferredSize(new Dimension(DEMO_SELECTOR_WIDTH, MAIN_FRAME_HEIGHT));
+ demoSelectorPanel.addPropertyChangeListener(new DemoSelectionListener());
+ mainPanel.add(demoSelectorPanel, BorderLayout.WEST);
+
+ // Create splitpane on right to hold demo and source code
+ demoSplitPane = new AnimatingSplitPane(JSplitPane.VERTICAL_SPLIT);
+ demoSplitPane.setBorder(EMPTY_BORDER);
+ mainPanel.add(demoSplitPane, BorderLayout.CENTER);
+
+ // Create panel to contain currently running demo
+ demoContainer = new JPanel();
+ demoContainer.setLayout(new BorderLayout());
+ demoContainer.setBorder(PANEL_BORDER);
+ demoContainer.setPreferredSize(new Dimension(DEMO_PANEL_WIDTH, DEMO_PANEL_HEIGHT));
+ demoSplitPane.setTopComponent(demoContainer);
+
+ currentDemoPanel = demoPlaceholder;
+ demoContainer.add(demoPlaceholder, BorderLayout.CENTER);
+
+ // Create collapsible source code pane
+
+ codeViewer = new CodeViewer();
+ codeContainer = new JPanel(new BorderLayout());
+ codeContainer.add(codeViewer);
+ codeContainer.setBorder(PANEL_BORDER);
+ codeContainer.setMinimumSize(new Dimension(0,0));
+ demoSplitPane.setBottomComponent(codeContainer);
+
+ addPropertyChangeListener(new SwingSetPropertyListener());
+
+ // Create shareable popup menu for demo actions
+ popup = new JPopupMenu();
+ popup.add(new EditPropertiesAction());
+ popup.add(new ViewCodeSnippetAction());
+
+ return mainPanel;
+ }
+
+ protected JMenuBar createMenuBar() {
+
+ JMenuBar menubar = new JMenuBar();
+ menubar.setName("menubar");
+
+ // File menu
+ JMenu fileMenu = new JMenu();
+ fileMenu.setName("file");
+ menubar.add(fileMenu);
+
+ // File -> Quit
+ if (!runningOnMac()) {
+ JMenuItem quitItem = new JMenuItem();
+ quitItem.setName("quit");
+ quitItem.setAction(getAction("quit"));
+ fileMenu.add(quitItem);
+ }
+
+ // View menu
+ JMenu viewMenu = new JMenu();
+ viewMenu.setName("view");
+ // View -> Look and Feel
+ viewMenu.add(createLookAndFeelMenu());
+ // View -> Source Code Visible
+ sourceCodeCheckboxItem = new JCheckBoxMenuItem();
+ sourceCodeCheckboxItem.setSelected(isSourceCodeVisible());
+ sourceCodeCheckboxItem.setName("sourceCodeCheckboxItem");
+ sourceCodeCheckboxItem.addChangeListener(new SourceVisibilityChangeListener());
+ viewMenu.add(sourceCodeCheckboxItem);
+ menubar.add(viewMenu);
+
+ return menubar;
+ }
+
+ protected JMenu createLookAndFeelMenu() {
+ JMenu menu = new JMenu();
+ menu.setName("lookAndFeel");
+
+ // Look for toolkit look and feels first
+ UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels();
+ lookAndFeel = UIManager.getLookAndFeel().getClass().getName();
+ lookAndFeelRadioGroup = new ButtonGroup();
+ for(UIManager.LookAndFeelInfo lafInfo: lookAndFeelInfos) {
+ menu.add(createLookAndFeelItem(lafInfo.getName(), lafInfo.getClassName()));
+ }
+ // Now load any look and feels defined externally as service via java.util.ServiceLoader
+ LOOK_AND_FEEL_LOADER.iterator();
+ for (LookAndFeel laf : LOOK_AND_FEEL_LOADER) {
+ menu.add(createLookAndFeelItem(laf.getName(), laf.getClass().getName()));
+ }
+
+ return menu;
+ }
+
+ protected JRadioButtonMenuItem createLookAndFeelItem(String lafName, String lafClassName) {
+ JRadioButtonMenuItem lafItem = new JRadioButtonMenuItem();
+
+ lafItem.setSelected(lafClassName.equals(lookAndFeel));
+ lafItem.setHideActionText(true);
+ lafItem.setAction(getAction("setLookAndFeel"));
+ lafItem.setText(lafName);
+ lafItem.setActionCommand(lafClassName);
+ lookAndFeelRadioGroup.add(lafItem);
+
+ return lafItem;
+ }
+
+ private javax.swing.Action getAction(String actionName) {
+ return getContext().getActionMap().get(actionName);
+ }
+
+ // For displaying error messages to user
+ protected void displayErrorMessage(String message, Exception ex) {
+ JPanel messagePanel = new JPanel(new BorderLayout());
+ JLabel label = new JLabel(message);
+ messagePanel.add(label);
+ if (ex != null) {
+ RoundedPanel panel = new RoundedPanel(new BorderLayout());
+ panel.setBorder(new RoundedBorder());
+
+ // remind(aim): provide way to allow user to see exception only if desired
+ StringWriter writer = new StringWriter();
+ ex.printStackTrace(new PrintWriter(writer));
+ JTextArea exceptionText = new JTextArea();
+ exceptionText.setText("Cause of error:\n" +
+ writer.getBuffer().toString());
+ exceptionText.setBorder(new RoundedBorder());
+ exceptionText.setOpaque(false);
+ exceptionText.setBackground(
+ Utilities.deriveColorHSB(UIManager.getColor("Panel.background"),
+ 0, 0, -.2f));
+ JScrollPane scrollpane = new JScrollPane(exceptionText);
+ scrollpane.setBorder(EMPTY_BORDER);
+ scrollpane.setPreferredSize(new Dimension(600,240));
+ panel.add(scrollpane);
+ messagePanel.add(panel, BorderLayout.SOUTH);
+ }
+ JOptionPane.showMessageDialog(getMainFrame(), messagePanel,
+ resourceMap.getString("error.title"),
+ JOptionPane.ERROR_MESSAGE);
+
+ }
+
+ public void setDemoPlaceholder(JComponent demoPlaceholder) {
+ JComponent oldDemoPlaceholder = this.demoPlaceholder;
+ this.demoPlaceholder = demoPlaceholder;
+ firePropertyChange("demoPlaceholder", oldDemoPlaceholder, demoPlaceholder);
+ }
+
+ public JComponent getDemoPlaceholder() {
+ return demoPlaceholder;
+ }
+
+ public void setCurrentDemo(Demo demo) {
+ if (currentDemo == demo) {
+ return; // already there
+ }
+ Demo oldCurrentDemo = currentDemo;
+ currentDemo = demo;
+ if (demo != null) {
+ DemoPanel demoPanel = runningDemoCache.get(demo.getName());
+ if (demoPanel == null || demo.getDemoComponent() == null) {
+ demo.startInitializing();
+ demoPanel = new DemoPanel(demo);
+ demoPanel.setPreferredSize(currentDemoPanel.getPreferredSize());
+ runningDemoCache.put(demo.getName(), demoPanel);
+ }
+ demoContainer.remove(currentDemoPanel);
+ currentDemoPanel = demoPanel;
+ demoContainer.add(currentDemoPanel, BorderLayout.CENTER);
+ demoContainer.revalidate();
+ demoContainer.repaint();
+ getMainFrame().validate();
+ }
+
+ if (currentDemo == null) {
+ demoContainer.add(demoPlaceholder, BorderLayout.CENTER);
+ }
+
+ if (isSourceCodeVisible()) {
+ codeViewer.setSourceFiles(currentDemo != null?
+ currentDemo.getSourceFiles() : null);
+ }
+
+ firePropertyChange("currentDemo", oldCurrentDemo, demo);
+ }
+
+
+ public Demo getCurrentDemo() {
+ return currentDemo;
+ }
+
+ public void setLookAndFeel(String lookAndFeel) throws ClassNotFoundException,
+ InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
+
+ String oldLookAndFeel = this.lookAndFeel;
+
+ if (oldLookAndFeel != lookAndFeel) {
+ UIManager.setLookAndFeel(lookAndFeel);
+ this.lookAndFeel = lookAndFeel;
+ updateLookAndFeel();
+ firePropertyChange("lookAndFeel", oldLookAndFeel, lookAndFeel);
+ }
+ }
+
+ @Action
+ public void setLookAndFeel() {
+ ButtonModel model = lookAndFeelRadioGroup.getSelection();
+ String lookAndFeelName = model.getActionCommand();
+ try {
+ setLookAndFeel(lookAndFeelName);
+ } catch (Exception ex) {
+ displayErrorMessage(resourceMap.getString("error.unableToChangeLookAndFeel") +
+ "to "+lookAndFeelName, ex);
+ }
+ }
+
+ public String getLookAndFeel() {
+ return lookAndFeel;
+ }
+
+ public void setSourceCodeVisible(boolean sourceVisible) {
+ boolean oldSourceVisible = this.sourceVisible;
+ this.sourceVisible = sourceVisible;
+ firePropertyChange("sourceCodeVisible", oldSourceVisible, sourceVisible);
+ }
+
+ public boolean isSourceCodeVisible() {
+ return sourceVisible;
+ }
+
+ private void updateLookAndFeel() {
+ Window windows[] = Frame.getWindows();
+
+ for(Window window : windows) {