diff --git a/.idea/copyright/JetBrains.xml b/.idea/copyright/JetBrains.xml new file mode 100644 index 0000000..1eeffff --- /dev/null +++ b/.idea/copyright/JetBrains.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index e7bedf3..b8a393d 100755 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -1,3 +1,7 @@ - + + + + + \ No newline at end of file diff --git a/.idea/fileColors.xml b/.idea/fileColors.xml new file mode 100644 index 0000000..f751d9c --- /dev/null +++ b/.idea/fileColors.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/libraries/SwingSet3_Libraries.xml b/.idea/libraries/SwingSet3_Libraries.xml new file mode 100644 index 0000000..907a651 --- /dev/null +++ b/.idea/libraries/SwingSet3_Libraries.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 75af768..5156efe 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -6,7 +6,7 @@ - + diff --git a/.idea/scopes/Darcula.xml b/.idea/scopes/Darcula.xml new file mode 100644 index 0000000..6393e92 --- /dev/null +++ b/.idea/scopes/Darcula.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/scopes/Demos.xml b/.idea/scopes/Demos.xml new file mode 100644 index 0000000..379f6a8 --- /dev/null +++ b/.idea/scopes/Demos.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Darcula.iml b/Darcula.iml index 3798331..467d5ed 100755 --- a/Darcula.iml +++ b/Darcula.iml @@ -5,10 +5,12 @@ + + diff --git a/lib/demo/AnimatedTransitions.jar b/lib/demo/AnimatedTransitions.jar new file mode 100644 index 0000000..cc5adf0 Binary files /dev/null and b/lib/demo/AnimatedTransitions.jar differ diff --git a/lib/demo/AppFramework.jar b/lib/demo/AppFramework.jar new file mode 100644 index 0000000..8dd4469 Binary files /dev/null and b/lib/demo/AppFramework.jar differ diff --git a/lib/demo/TimingFramework.jar b/lib/demo/TimingFramework.jar new file mode 100644 index 0000000..5fb88cc Binary files /dev/null and b/lib/demo/TimingFramework.jar differ diff --git a/lib/demo/swing-worker.jar b/lib/demo/swing-worker.jar new file mode 100644 index 0000000..bcdd9d9 Binary files /dev/null and b/lib/demo/swing-worker.jar differ diff --git a/lib/demo/swingx.jar b/lib/demo/swingx.jar new file mode 100644 index 0000000..484fab6 Binary files /dev/null and b/lib/demo/swingx.jar differ diff --git a/src/com/bulenkov/darcula/DarculaDefaultTableHeaderRenderer.java b/src/com/bulenkov/darcula/DarculaDefaultTableHeaderRenderer.java index 46d2a1d..3470af3 100755 --- a/src/com/bulenkov/darcula/DarculaDefaultTableHeaderRenderer.java +++ b/src/com/bulenkov/darcula/DarculaDefaultTableHeaderRenderer.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula; import javax.swing.*; diff --git a/src/com/bulenkov/darcula/DarculaLaf.java b/src/com/bulenkov/darcula/DarculaLaf.java index 9aa1e30..cd8cfdd 100755 --- a/src/com/bulenkov/darcula/DarculaLaf.java +++ b/src/com/bulenkov/darcula/DarculaLaf.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula; import com.bulenkov.iconloader.util.ColorUtil; @@ -37,6 +53,7 @@ public final class DarculaLaf extends BasicLookAndFeel { } else { final String name = UIManager.getSystemLookAndFeelClassName(); base = (BasicLookAndFeel)Class.forName(name).newInstance(); + MetalLookAndFeel.setCurrentTheme(new DarculaMetalTheme()); } } catch (Exception ignore) { diff --git a/src/com/bulenkov/darcula/DarculaLookAndFeelInfo.java b/src/com/bulenkov/darcula/DarculaLookAndFeelInfo.java index feaae1b..96b14da 100755 --- a/src/com/bulenkov/darcula/DarculaLookAndFeelInfo.java +++ b/src/com/bulenkov/darcula/DarculaLookAndFeelInfo.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula; import javax.swing.*; diff --git a/src/com/bulenkov/darcula/DarculaMetalTheme.java b/src/com/bulenkov/darcula/DarculaMetalTheme.java new file mode 100644 index 0000000..a0409b0 --- /dev/null +++ b/src/com/bulenkov/darcula/DarculaMetalTheme.java @@ -0,0 +1,98 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bulenkov.darcula; + +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.metal.DefaultMetalTheme; +import java.awt.*; + +/** + * @author Konstantin Bulenkov + */ +public class DarculaMetalTheme extends DefaultMetalTheme { + private final ColorUIResource myControlHighlightColor = new ColorUIResource(108, 111, 113); + private final ColorUIResource myControlDarkShadowColor = new ColorUIResource(39, 42, 44); + private final ColorUIResource myControlColor = new ColorUIResource(0x3c3f41); + private static final ColorUIResource white = new ColorUIResource(255, 255, 255); + private static final ColorUIResource darkBlue = new ColorUIResource(82, 108, 164); + private static final ColorUIResource lightGray = new ColorUIResource(214, 214, 214); + private final ColorUIResource mySeparatorForeground = new ColorUIResource(53, 56, 58); + + public static final ColorUIResource primary1 = new ColorUIResource(53, 56, 58); + private static final ColorUIResource primary2 = new ColorUIResource(91, 135, 206); + private static final ColorUIResource primary3 = new ColorUIResource(166, 202, 240); + + + + public String getName() { + return "Darcula theme"; + } + + public ColorUIResource getControl() { + return myControlColor; + } + + @Override + public ColorUIResource getControlHighlight() { + return myControlHighlightColor; + } + + @Override + public ColorUIResource getControlDarkShadow() { + return myControlDarkShadowColor; + } + + public ColorUIResource getSeparatorBackground() { + return getControl(); + } + + public ColorUIResource getSeparatorForeground() { + return mySeparatorForeground; + } + + public ColorUIResource getMenuBackground() { + return lightGray; + } + + public ColorUIResource getMenuSelectedBackground() { + return darkBlue; + } + + public ColorUIResource getMenuSelectedForeground() { + return white; + } + + public ColorUIResource getAcceleratorSelectedForeground() { + return white; + } + + public ColorUIResource getFocusColor() { + return new ColorUIResource(Color.black); + } + + protected ColorUIResource getPrimary1() { + return primary1; + } + + protected ColorUIResource getPrimary2() { + return primary2; + } + + protected ColorUIResource getPrimary3() { + return primary3; + } +} diff --git a/src/com/bulenkov/darcula/DarculaTableHeaderBorder.java b/src/com/bulenkov/darcula/DarculaTableHeaderBorder.java index 8c0c736..39f3991 100755 --- a/src/com/bulenkov/darcula/DarculaTableHeaderBorder.java +++ b/src/com/bulenkov/darcula/DarculaTableHeaderBorder.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula; import javax.swing.border.Border; diff --git a/src/com/bulenkov/darcula/DarculaTableHeaderUI.java b/src/com/bulenkov/darcula/DarculaTableHeaderUI.java index 58c03a4..c91b9bc 100755 --- a/src/com/bulenkov/darcula/DarculaTableHeaderUI.java +++ b/src/com/bulenkov/darcula/DarculaTableHeaderUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/DarculaUIUtil.java b/src/com/bulenkov/darcula/DarculaUIUtil.java index 93d527b..10eb795 100755 --- a/src/com/bulenkov/darcula/DarculaUIUtil.java +++ b/src/com/bulenkov/darcula/DarculaUIUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/darcula.css b/src/com/bulenkov/darcula/darcula.css index 8274b5c..d8ab161 100755 --- a/src/com/bulenkov/darcula/darcula.css +++ b/src/com/bulenkov/darcula/darcula.css @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/darcula.properties b/src/com/bulenkov/darcula/darcula.properties index 6b5944d..c1cab5c 100755 --- a/src/com/bulenkov/darcula/darcula.properties +++ b/src/com/bulenkov/darcula/darcula.properties @@ -1,3 +1,19 @@ +# +# Copyright 2000-2014 JetBrains s.r.o. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # suppress inspection "UnusedProperty" for whole file darcula.background=3c3f41 darcula.textBackground=3c3f41 diff --git a/src/com/bulenkov/darcula/darcula_linux.properties b/src/com/bulenkov/darcula/darcula_linux.properties index d523622..a9cf542 100755 --- a/src/com/bulenkov/darcula/darcula_linux.properties +++ b/src/com/bulenkov/darcula/darcula_linux.properties @@ -1,3 +1,19 @@ +# +# Copyright 2000-2014 JetBrains s.r.o. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # suppress inspection "UnusedProperty" for whole file darcula.selectionBackground=2F65CA darcula.selectionForeground=bbbbbb diff --git a/src/com/bulenkov/darcula/darcula_mac.properties b/src/com/bulenkov/darcula/darcula_mac.properties index 75a5b22..3198bbf 100755 --- a/src/com/bulenkov/darcula/darcula_mac.properties +++ b/src/com/bulenkov/darcula/darcula_mac.properties @@ -1,3 +1,19 @@ +# +# Copyright 2000-2014 JetBrains s.r.o. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # suppress inspection "UnusedProperty" for whole file darcula.selectionBackground=2F65CA #Menu.arrowIcon=AllIcons.Mac.Tree_white_right_arrow diff --git a/src/com/bulenkov/darcula/darcula_windows.properties b/src/com/bulenkov/darcula/darcula_windows.properties index 1aceeb2..a0796a6 100755 --- a/src/com/bulenkov/darcula/darcula_windows.properties +++ b/src/com/bulenkov/darcula/darcula_windows.properties @@ -1,3 +1,19 @@ +# +# Copyright 2000-2014 JetBrains s.r.o. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # suppress inspection "UnusedProperty" for whole file darcula.selectionBackground=4B6EAF darcula.selectionForeground=bbbbbb @@ -5,6 +21,12 @@ darcula.selectionForeground=bbbbbb PopupMenu.border=com.bulenkov.darcula.ui.DarculaPopupMenuBorder MenuBar.border=com.bulenkov.darcula.ui.DarculaMenuBarBorder -#InternalFrameUI=com.bulenkov.darcula.ui.DarculaInternalFrameUI -#InternalFrame.border=com.bulenkov.darcula.ui.DarculaInternalBorder -#RootPaneUI=com.bulenkov.darcula.ui.DarculaRootPaneUI \ No newline at end of file + +ToolBar.floatingBackground=3c3f41 +ToolBar.floatingForeground=bbbbbb +ToolBar.borderColor=555555 +ToolBar.shadow=555555 +menu=3c3f41 +MenuBar.gradient=null +MenuBar.borderColor=555555 +MenuBar.highlight=555555 \ No newline at end of file diff --git a/src/com/bulenkov/darcula/ui/DarculaButtonPainter.java b/src/com/bulenkov/darcula/ui/DarculaButtonPainter.java index 2531ea2..4b28e3f 100755 --- a/src/com/bulenkov/darcula/ui/DarculaButtonPainter.java +++ b/src/com/bulenkov/darcula/ui/DarculaButtonPainter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaButtonUI.java b/src/com/bulenkov/darcula/ui/DarculaButtonUI.java index cbb66dc..5404e33 100755 --- a/src/com/bulenkov/darcula/ui/DarculaButtonUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaButtonUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaCheckBoxBorder.java b/src/com/bulenkov/darcula/ui/DarculaCheckBoxBorder.java index f660dc3..813a2e8 100755 --- a/src/com/bulenkov/darcula/ui/DarculaCheckBoxBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaCheckBoxBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaCheckBoxUI.java b/src/com/bulenkov/darcula/ui/DarculaCheckBoxUI.java index 98ea002..c026fdc 100755 --- a/src/com/bulenkov/darcula/ui/DarculaCheckBoxUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaCheckBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaComboBoxUI.java b/src/com/bulenkov/darcula/ui/DarculaComboBoxUI.java index b9b64c4..0835492 100755 --- a/src/com/bulenkov/darcula/ui/DarculaComboBoxUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaComboBoxUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaEditorPaneUI.java b/src/com/bulenkov/darcula/ui/DarculaEditorPaneUI.java index 7830c60..e55dba9 100755 --- a/src/com/bulenkov/darcula/ui/DarculaEditorPaneUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaEditorPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaInternalBorder.java b/src/com/bulenkov/darcula/ui/DarculaInternalBorder.java index 3978112..a025844 100644 --- a/src/com/bulenkov/darcula/ui/DarculaInternalBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaInternalBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java b/src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java index e717470..5afd44d 100644 --- a/src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaInternalFrameUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaMenuBarBorder.java b/src/com/bulenkov/darcula/ui/DarculaMenuBarBorder.java index f013acb..c795e1b 100755 --- a/src/com/bulenkov/darcula/ui/DarculaMenuBarBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaMenuBarBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaMenuBarUI.java b/src/com/bulenkov/darcula/ui/DarculaMenuBarUI.java index 9111018..1403d15 100644 --- a/src/com/bulenkov/darcula/ui/DarculaMenuBarUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaMenuBarUI.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula.ui; import javax.swing.*; diff --git a/src/com/bulenkov/darcula/ui/DarculaMenuItemBorder.java b/src/com/bulenkov/darcula/ui/DarculaMenuItemBorder.java index de123df..9450970 100755 --- a/src/com/bulenkov/darcula/ui/DarculaMenuItemBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaMenuItemBorder.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula.ui; import javax.swing.plaf.BorderUIResource; diff --git a/src/com/bulenkov/darcula/ui/DarculaPanelUI.java b/src/com/bulenkov/darcula/ui/DarculaPanelUI.java index d04b38e..fda69cd 100755 --- a/src/com/bulenkov/darcula/ui/DarculaPanelUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaPanelUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaPasswordFieldUI.java b/src/com/bulenkov/darcula/ui/DarculaPasswordFieldUI.java index 422dd8a..4e16d3f 100755 --- a/src/com/bulenkov/darcula/ui/DarculaPasswordFieldUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaPasswordFieldUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaPopupMenuBorder.java b/src/com/bulenkov/darcula/ui/DarculaPopupMenuBorder.java index d694f49..09f2db2 100755 --- a/src/com/bulenkov/darcula/ui/DarculaPopupMenuBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaPopupMenuBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaProgressBarBorder.java b/src/com/bulenkov/darcula/ui/DarculaProgressBarBorder.java index bd24f78..4496ecd 100755 --- a/src/com/bulenkov/darcula/ui/DarculaProgressBarBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaProgressBarBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaProgressBarUI.java b/src/com/bulenkov/darcula/ui/DarculaProgressBarUI.java index 93b8bee..ad59e4c 100755 --- a/src/com/bulenkov/darcula/ui/DarculaProgressBarUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaProgressBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaRadioButtonUI.java b/src/com/bulenkov/darcula/ui/DarculaRadioButtonUI.java index 3220600..7afca21 100755 --- a/src/com/bulenkov/darcula/ui/DarculaRadioButtonUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaRadioButtonUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaRootPaneUI.java b/src/com/bulenkov/darcula/ui/DarculaRootPaneUI.java index f5d146b..46259dd 100644 --- a/src/com/bulenkov/darcula/ui/DarculaRootPaneUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaRootPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaScrollBarUI.java b/src/com/bulenkov/darcula/ui/DarculaScrollBarUI.java index dfbc71e..2a049fb 100755 --- a/src/com/bulenkov/darcula/ui/DarculaScrollBarUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaScrollBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaSpinnerBorder.java b/src/com/bulenkov/darcula/ui/DarculaSpinnerBorder.java index 92bc69e..42a9e46 100755 --- a/src/com/bulenkov/darcula/ui/DarculaSpinnerBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaSpinnerBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaSpinnerUI.java b/src/com/bulenkov/darcula/ui/DarculaSpinnerUI.java index 70fdc40..1246fa4 100755 --- a/src/com/bulenkov/darcula/ui/DarculaSpinnerUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaSpinnerUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaTabbedPaneUI.java b/src/com/bulenkov/darcula/ui/DarculaTabbedPaneUI.java index 9742183..3bd0134 100755 --- a/src/com/bulenkov/darcula/ui/DarculaTabbedPaneUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaTabbedPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaTextBorder.java b/src/com/bulenkov/darcula/ui/DarculaTextBorder.java index ff656a3..2b2b2c7 100755 --- a/src/com/bulenkov/darcula/ui/DarculaTextBorder.java +++ b/src/com/bulenkov/darcula/ui/DarculaTextBorder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaTextFieldUI.java b/src/com/bulenkov/darcula/ui/DarculaTextFieldUI.java index ecd6f5e..d2d3026 100755 --- a/src/com/bulenkov/darcula/ui/DarculaTextFieldUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaTextFieldUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaTitlePane.java b/src/com/bulenkov/darcula/ui/DarculaTitlePane.java index fb7aaec..d0a146f 100644 --- a/src/com/bulenkov/darcula/ui/DarculaTitlePane.java +++ b/src/com/bulenkov/darcula/ui/DarculaTitlePane.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/DarculaToolBarUI.java b/src/com/bulenkov/darcula/ui/DarculaToolBarUI.java index 908e7ce..e8be979 100644 --- a/src/com/bulenkov/darcula/ui/DarculaToolBarUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaToolBarUI.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula.ui; import javax.swing.*; diff --git a/src/com/bulenkov/darcula/ui/DarculaTreeUI.java b/src/com/bulenkov/darcula/ui/DarculaTreeUI.java index b7117eb..7731878 100644 --- a/src/com/bulenkov/darcula/ui/DarculaTreeUI.java +++ b/src/com/bulenkov/darcula/ui/DarculaTreeUI.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java b/src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java index 64887ba..09da330 100755 --- a/src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java +++ b/src/com/bulenkov/darcula/ui/win/DarculaWindowsInternalFrameUI.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula.ui.win; import javax.swing.*; diff --git a/src/com/bulenkov/darcula/util/Animator.java b/src/com/bulenkov/darcula/util/Animator.java index 72458b6..415ff92 100755 --- a/src/com/bulenkov/darcula/util/Animator.java +++ b/src/com/bulenkov/darcula/util/Animator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula.util; import javax.swing.*; diff --git a/src/com/bulenkov/darcula/util/DarculaColors.java b/src/com/bulenkov/darcula/util/DarculaColors.java index 26f32d9..ebf9a8d 100644 --- a/src/com/bulenkov/darcula/util/DarculaColors.java +++ b/src/com/bulenkov/darcula/util/DarculaColors.java @@ -1,3 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.bulenkov.darcula.util; import java.awt.*; diff --git a/swingset2/SwingSet2.java b/swingset2/SwingSet2.java index 24b85d7..243de06 100755 --- a/swingset2/SwingSet2.java +++ b/swingset2/SwingSet2.java @@ -46,10 +46,7 @@ import javax.swing.plaf.metal.MetalLookAndFeel; import java.awt.*; import java.awt.event.*; import java.lang.reflect.Constructor; -import java.util.Iterator; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Vector; +import java.util.*; /** * A demo that shows all of the Swing components. @@ -723,7 +720,30 @@ public class SwingSet2 extends JPanel { f.show(); numSSs++; swingSets.add(this); - } + + final UIDefaults defaults = UIManager.getDefaults(); + Enumeration keys = defaults.keys(); + final Object[][] data = new Object[defaults.size()][2]; + int i = 0; + while (keys.hasMoreElements()) { + Object key = keys.nextElement(); + data[i][0] = key; + data[i][1] = defaults.get(key); + i++; + } + + Arrays.sort(data, new Comparator() { + @Override + public int compare(Object[] o1, Object[] o2) { + return o1[0 ].toString().compareTo(o2[0].toString()); + } + }); + for (int j = 0; j < data.length; j++) { + Object[] objects = data[j]; + System.out.println(objects[0] + ": " + objects[1]); + + } + } } /** diff --git a/swingset3/META-INF/demolist b/swingset3/META-INF/demolist new file mode 100644 index 0000000..d1fa590 --- /dev/null +++ b/swingset3/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 diff --git a/swingset3/META-INF/services/javax.swing.LookAndFeel b/swingset3/META-INF/services/javax.swing.LookAndFeel new file mode 100644 index 0000000..e69de29 diff --git a/swingset3/com/sun/swingset3/AboutBox.java b/swingset3/com/sun/swingset3/AboutBox.java new file mode 100644 index 0000000..713c6fc --- /dev/null +++ b/swingset3/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) { + } + + + + + } + +} diff --git a/swingset3/com/sun/swingset3/Demo.java b/swingset3/com/sun/swingset3/Demo.java new file mode 100644 index 0000000..e3cd77d --- /dev/null +++ b/swingset3/com/sun/swingset3/Demo.java @@ -0,0 +1,350 @@ +/* + * 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.*; +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 pathURLs = new ArrayList(); + + // 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); + } + } +} diff --git a/swingset3/com/sun/swingset3/DemoPanel.java b/swingset3/com/sun/swingset3/DemoPanel.java new file mode 100644 index 0000000..cffb1a3 --- /dev/null +++ b/swingset3/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); + } + } + } +} diff --git a/swingset3/com/sun/swingset3/DemoProperties.java b/swingset3/com/sun/swingset3/DemoProperties.java new file mode 100644 index 0000000..68a7d00 --- /dev/null +++ b/swingset3/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 ""; +} diff --git a/swingset3/com/sun/swingset3/DemoSelectorPanel.java b/swingset3/com/sun/swingset3/DemoSelectorPanel.java new file mode 100644 index 0000000..74e5a9c --- /dev/null +++ b/swingset3/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 collapsePanels = new ArrayList(); + 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 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 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 categoryMap = new HashMap(); + 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); + } + } +} diff --git a/swingset3/com/sun/swingset3/IntroPanel.java b/swingset3/com/sun/swingset3/IntroPanel.java new file mode 100644 index 0000000..8041695 --- /dev/null +++ b/swingset3/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(); + } + } +} diff --git a/swingset3/com/sun/swingset3/SwingSet3.java b/swingset3/com/sun/swingset3/SwingSet3.java new file mode 100644 index 0000000..fc4a085 --- /dev/null +++ b/swingset3/com/sun/swingset3/SwingSet3.java @@ -0,0 +1,707 @@ +/* + * 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.codeview.CodeViewer; +import com.sun.swingset3.utilities.AnimatingSplitPane; +import com.sun.swingset3.utilities.RoundedBorder; +import com.sun.swingset3.utilities.RoundedPanel; +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 javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +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.*; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Amy Fowler + */ +public class SwingSet3 extends SingleFrameApplication { + static final Logger logger = Logger.getLogger(SwingSet3.class.getName()); + + private static final ServiceLoader 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 readDemoClassNames(Reader reader) throws IOException { + List demoClassNames = new ArrayList(); + + 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 demoList; + private PropertyChangeListener demoPropertyChangeListener; + private Map 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.bulenkov.darcula.DarculaLaf"); + } catch (Exception ex) { + // not catestrophic + } + resourceMap = getContext().getResourceMap(); + + title = resourceMap.getString("mainFrame.title"); + runningDemoCache = new HashMap(); + setDemoList(resourceMap.getString("demos.title"), getDemoClassNames(args)); + + IntroPanel intro = new IntroPanel(); + setDemoPlaceholder(intro); + + } + + private ListgetDemoClassNames(String args[]) { + List demoList = new ArrayList(); + 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 demoClassNamesList) { + List demoList = new ArrayList(); + 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) { + SwingUtilities.updateComponentTreeUI(window); + for(DemoPanel demoPanel : runningDemoCache.values()) { + SwingUtilities.updateComponentTreeUI(demoPanel); + } + } + } + + // hook used to detect if any components in the demo have registered a + // code snippet key for the their creation code inside the source + private void registerPopups(Component component) { + + if (component instanceof Container) { + Component children[] = ((Container)component).getComponents(); + for(Component child: children) { + if (child instanceof JComponent) { + registerPopups(child); + } + } + } + if (component instanceof JComponent) { + JComponent jcomponent = (JComponent)component; + String snippetKey = (String)jcomponent.getClientProperty("snippetKey"); + if (snippetKey != null) { + jcomponent.setComponentPopupMenu(popup); + } + } + } + + private class DemoSelectionListener implements PropertyChangeListener { + public void propertyChange(PropertyChangeEvent event) { + if (event.getPropertyName().equals("selectedDemo")) { + setCurrentDemo((Demo)event.getNewValue()); + } + } + } + + + // registered on Demo to detect when the demo component is instantiated. + // we need this because when we embed the demo inside an HTML description pane, + // we don't have control over the demo component's instantiation + private class DemoPropertyChangeListener implements PropertyChangeListener { + public void propertyChange(PropertyChangeEvent e) { + String propertyName = e.getPropertyName(); + if (propertyName.equals("demoComponent")) { + Demo demo = (Demo)e.getSource(); + JComponent demoComponent = (JComponent)e.getNewValue(); + if (demoComponent != null) { + demoComponent.putClientProperty("swingset3.demo", demo); + demoComponent.addHierarchyListener(new DemoVisibilityListener()); + registerPopups(demoComponent); + } + } + } + } + + private class DemoVisibilityListener implements HierarchyListener { + public void hierarchyChanged(HierarchyEvent event) { + if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) { + JComponent component = (JComponent)event.getComponent(); + final Demo demo = (Demo)component.getClientProperty("swingset3.demo"); + if (!component.isShowing()) { + demo.stop(); + } else { + demoContainer.revalidate(); + EventQueue.invokeLater(new Runnable() { + public void run() { + demo.start(); + } + }); + } + } + } + } + // activated when user selects/unselects checkbox menu item + private class SourceVisibilityChangeListener implements ChangeListener { + public void stateChanged(ChangeEvent event) { + setSourceCodeVisible(sourceCodeCheckboxItem.isSelected()); + } + } + + private class SwingSetPropertyListener implements PropertyChangeListener { + public void propertyChange(PropertyChangeEvent event) { + String propertyName = event.getPropertyName(); + if (propertyName.equals("sourceCodeVisible")) { + boolean sourceVisible = ((Boolean)event.getNewValue()).booleanValue(); + if (sourceVisible) { + // update codeViewer in case current demo changed while + // source was invisible + codeViewer.setSourceFiles(currentDemo != null? + currentDemo.getSourceFiles() : null); + } + demoSplitPane.setExpanded(!sourceVisible); + sourceCodeCheckboxItem.setSelected(sourceVisible); + } + } + } + + private class ViewCodeSnippetAction extends AbstractAction { + public ViewCodeSnippetAction() { + super("View Source Code"); + } + public void actionPerformed(ActionEvent actionEvent) { + Container popup = (JComponent)actionEvent.getSource(); + while(popup != null && !(popup instanceof JPopupMenu)) { + popup = popup.getParent(); + } + JComponent target = (JComponent)((JPopupMenu)popup).getInvoker(); + setSourceCodeVisible(true); + + String snippetKey = (String)target.getClientProperty("snippetKey"); + if (snippetKey != null) { + codeViewer.highlightSnippetSet(snippetKey); + } else { + logger.log(Level.WARNING, "can't find source code snippet for:" + snippetKey); + } + } + } + + private static class EditPropertiesAction extends AbstractAction { + public EditPropertiesAction() { + super("Edit Properties"); + } + public boolean isEnabled() { + return false; + } + public void actionPerformed(ActionEvent actionEvent) { + + } + } +} diff --git a/swingset3/com/sun/swingset3/codeview/CodeStyler.java b/swingset3/com/sun/swingset3/codeview/CodeStyler.java new file mode 100644 index 0000000..4ca7eaf --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/CodeStyler.java @@ -0,0 +1,410 @@ +/** + * CodeStyler.java + * + * Bill Lynch & Matt Tucker + * CoolServlets.com, October 1999 + * + * Please visit CoolServlets.com for high quality, open source Java servlets. + * + * Copyright (C) 1999 CoolServlets.com + * + * Any errors or suggested improvements to this class can be reported + * as instructed on Coolservlets.com. We hope you enjoy + * this program... your comments will encourage further development! + * + * This software is distributed under the terms of The BSD License. + * + * 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 name of CoolServlets.com 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 COOLSERVLETS.COM 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 COOLSERVLETS.COM 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. + */ + +/* + * @(#)CodeStyler.java 1.6 02/06/13 + */ +package com.sun.swingset3.codeview; + +import java.util.*; + +/** + * A class that syntax highlights Java code by turning it into html. + * + *

A CodeStyler object is created and then keeps state as + * lines are passed in. Each line passed in as java text, is returned as syntax + * highlighted html text. (note: this class was originally named CodeViewer) + * + *

Users of the class can set how the java code will be highlighted with + * setter methods. + * + *

Only valid java lines should be passed in since the object maintains + * state and may not handle illegal code gracefully. + * + *

The actual system is implemented as a series of filters that deal with + * specific portions of the java code. The filters are as follows: + * + *

+ *  htmlFilter
+ *     |__
+ *        multiLineCommentFilter
+ *           |___
+ *                inlineCommentFilter
+ *                   |___
+ *                        stringFilter
+ *                           |__
+ *                               keywordFilter
+ * 
+ * + * @author Bill Lynch, Matt Tucker, CoolServlets.com + * @version 1.6 06/13/02 + */ +public class CodeStyler { + + private final static Map RESERVED_WORDS = new HashMap(); // >= Java2 only (also, not thread-safe) + private boolean inMultiLineComment = false; + private String commentStart = ""; + private String commentEnd = ""; + private String stringStart = ""; + private String stringEnd = ""; + private String reservedWordStart = ""; + private String reservedWordEnd = ""; + + static { + loadHash(); + } + + public CodeStyler() { + } + + public void setCommentStart(String commentStart) { + this.commentStart = commentStart; + } + public void setCommentEnd(String commentEnd) { + this.commentEnd = commentEnd; + } + public void setStringStart(String stringStart) { + this.stringStart = stringStart; + } + public void setStringEnd(String stringEnd) { + this.stringEnd = stringEnd; + } + public void setReservedWordStart(String reservedWordStart) { + this.reservedWordStart = reservedWordStart; + } + public void setReservedWordEnd(String reservedWordEnd) { + this.reservedWordEnd = reservedWordEnd; + } + + public String getCommentStart() { + return commentStart; + } + public String getCommentEnd() { + return commentEnd; + } + public String getStringStart() { + return stringStart; + } + public String getStringEnd() { + return stringEnd; + } + public String getReservedWordStart() { + return reservedWordStart; + } + public String getReservedWordEnd() { + return reservedWordEnd; + } + + /** + * Passes off each line to the first filter. + * @param line The line of Java code to be highlighted. + */ + public String syntaxHighlight( String line ) { + return htmlFilter(line); + } + + /* + * Filter html tags into more benign text. + */ + private String htmlFilter( String line ) { + if( line == null || line.equals("") ) { + return ""; + } + + // replace ampersands with HTML escape sequence for ampersand; + line = replace(line, "&", "&"); + + // replace the \\ with HTML escape sequences. fixes a problem when + // backslashes preceed quotes. + line = replace(line, "\\\\", "\\" ); + + // replace \" sequences with HTML escape sequences; + line = replace(line, "" + (char)92 + (char)34, "\""); + + // replace less-than signs which might be confused + // by HTML as tag angle-brackets; + line = replace(line, "<", "<"); + // replace greater-than signs which might be confused + // by HTML as tag angle-brackets; + line = replace(line, ">", ">"); + + return multiLineCommentFilter(line); + } + + /* + * Filter out multiLine comments. State is kept with a private boolean + * variable. + */ + private String multiLineCommentFilter(String line) { + if (line == null || line.equals("")) { + return ""; + } + StringBuffer buf = new StringBuffer(); + int index; + //First, check for the end of a multi-line comment. + if (inMultiLineComment && (index = line.indexOf("*/")) > -1 && !isInsideString(line,index)) { + inMultiLineComment = false; + buf.append(line.substring(0,index)); + buf.append("*/").append(commentEnd); + if (line.length() > index+2) { + buf.append(inlineCommentFilter(line.substring(index+2))); + } + return buf.toString(); + } + //If there was no end detected and we're currently in a multi-line + //comment, we don't want to do anymore work, so return line. + else if (inMultiLineComment) { + return line; + } + //We're not currently in a comment, so check to see if the start + //of a multi-line comment is in this line. + else if ((index = line.indexOf("/*")) > -1 && !isInsideString(line,index)) { + inMultiLineComment = true; + //Return result of other filters + everything after the start + //of the multiline comment. We need to pass the through the + //to the multiLineComment filter again in case the comment ends + //on the same line. + buf.append(inlineCommentFilter(line.substring(0,index))); + buf.append(commentStart).append("/*"); + buf.append(multiLineCommentFilter(line.substring(index+2))); + return buf.toString(); + } + //Otherwise, no useful multi-line comment information was found so + //pass the line down to the next filter for processesing. + else { + return inlineCommentFilter(line); + } + } + + /* + * Filter inline comments from a line and formats them properly. + */ + private String inlineCommentFilter(String line) { + if (line == null || line.equals("")) { + return ""; + } + StringBuffer buf = new StringBuffer(); + int index; + if ((index = line.indexOf("//")) > -1 && !isInsideString(line,index)) { + buf.append(stringFilter(line.substring(0,index))); + buf.append(commentStart); + buf.append(line.substring(index)); + buf.append(commentEnd); + } + else { + buf.append(stringFilter(line)); + } + return buf.toString(); + } + + /* + * Filters strings from a line of text and formats them properly. + */ + private String stringFilter(String line) { + if (line == null || line.equals("")) { + return ""; + } + StringBuffer buf = new StringBuffer(); + if (!line.contains("\"")) { + return keywordFilter(line); + } + int start = 0; + int startStringIndex = -1; + int endStringIndex; + int tempIndex; + //Keep moving through String characters until we want to stop... + while ((tempIndex = line.indexOf("\"")) > -1) { + //We found the beginning of a string + if (startStringIndex == -1) { + startStringIndex = 0; + buf.append( stringFilter(line.substring(start,tempIndex)) ); + buf.append(stringStart).append("\""); + line = line.substring(tempIndex+1); + } + //Must be at the end + else { + startStringIndex = -1; + endStringIndex = tempIndex; + buf.append(line.substring(0,endStringIndex+1)); + buf.append(stringEnd); + line = line.substring(endStringIndex+1); + } + } + + buf.append( keywordFilter(line) ); + + return buf.toString(); + } + + /* + * Filters keywords from a line of text and formats them properly. + */ + private String keywordFilter( String line ) { + if( line == null || line.equals("") ) { + return ""; + } + StringBuffer buf = new StringBuffer(); + Map usedReservedWords = new HashMap(); // >= Java2 only (not thread-safe) + //Hashtable usedReservedWords = new Hashtable(); // < Java2 (thread-safe) + int i=0; + char ch; + StringBuffer temp = new StringBuffer(); + while( i < line.length() ) { + temp.setLength(0); + ch = line.charAt(i); + // 65-90, uppercase letters + // 97-122, lowercase letters + while( i= 65 && ch <= 90 ) + || ( ch >= 97 && ch <= 122 ) ) ) { + temp.append(ch); + i++; + if( i < line.length() ) { + ch = line.charAt(i); + } + } + String tempString = temp.toString(); + if( RESERVED_WORDS.containsKey(tempString) && !usedReservedWords.containsKey(tempString)) { + usedReservedWords.put(tempString,tempString); + line = replace( line, tempString, (reservedWordStart+tempString+reservedWordEnd) ); + i += (reservedWordStart.length() + reservedWordEnd.length()); + } + else { + i++; + } + } + buf.append(line); + return buf.toString(); + } + + /* + * All important replace method. Replaces all occurences of oldString in + * line with newString. + */ + private static String replace( String line, String oldString, String newString ) { + int i=0; + while( ( i=line.indexOf( oldString, i ) ) >= 0 ) { + line = (new StringBuffer().append(line.substring(0,i)).append(newString).append(line.substring(i+oldString.length()))).toString(); + i += newString.length(); + } + return line; + } + + /* + * Checks to see if some position in a line is between String start and + * ending characters. Not yet used in code or fully working :) + */ + private static boolean isInsideString(String line, int position) { + if (!line.contains("\"")) { + return false; + } + int index; + String left = line.substring(0,position); + String right = line.substring(position); + int leftCount = 0; + int rightCount = 0; + while ((index = left.indexOf("\"")) > -1) { + leftCount ++; + left = left.substring(index+1); + } + while ((index = right.indexOf("\"")) > -1) { + rightCount ++; + right = right.substring(index+1); + } + return rightCount % 2 != 0 && leftCount % 2 != 0; + } + + /* + * Load Hashtable (or HashMap) with Java reserved words. + */ + private static void loadHash() { + RESERVED_WORDS.put("abstract", "abstract"); + RESERVED_WORDS.put("do", "do"); + RESERVED_WORDS.put("inner", "inner"); + RESERVED_WORDS.put("public", "public"); + RESERVED_WORDS.put("var", "var"); + RESERVED_WORDS.put("boolean", "boolean"); + RESERVED_WORDS.put("continue", "continue"); + RESERVED_WORDS.put("int", "int"); + RESERVED_WORDS.put("return", "return"); + RESERVED_WORDS.put("void", "void"); + RESERVED_WORDS.put("break", "break"); + RESERVED_WORDS.put("else", "else"); + RESERVED_WORDS.put("interface", "interface"); + RESERVED_WORDS.put("short", "short"); + RESERVED_WORDS.put("volatile", "volatile"); + RESERVED_WORDS.put("byvalue", "byvalue"); + RESERVED_WORDS.put("extends", "extends"); + RESERVED_WORDS.put("long", "long"); + RESERVED_WORDS.put("static", "static"); + RESERVED_WORDS.put("while", "while"); + RESERVED_WORDS.put("case", "case"); + RESERVED_WORDS.put("final", "final"); + RESERVED_WORDS.put("naive", "naive"); + RESERVED_WORDS.put("super", "super"); + RESERVED_WORDS.put("transient", "transient"); + RESERVED_WORDS.put("cast", "cast"); + RESERVED_WORDS.put("float", "float"); + RESERVED_WORDS.put("new", "new"); + RESERVED_WORDS.put("rest", "rest"); + RESERVED_WORDS.put("catch", "catch"); + RESERVED_WORDS.put("for", "for"); + RESERVED_WORDS.put("null", "null"); + RESERVED_WORDS.put("synchronized", "synchronized"); + RESERVED_WORDS.put("char", "char"); + RESERVED_WORDS.put("finally", "finally"); + RESERVED_WORDS.put("operator", "operator"); + RESERVED_WORDS.put("this", "this"); + RESERVED_WORDS.put("class", "class"); + RESERVED_WORDS.put("generic", "generic"); + RESERVED_WORDS.put("outer", "outer"); + RESERVED_WORDS.put("switch", "switch"); + RESERVED_WORDS.put("const", "const"); + RESERVED_WORDS.put("goto", "goto"); + RESERVED_WORDS.put("package", "package"); + RESERVED_WORDS.put("throw", "throw"); + RESERVED_WORDS.put("double", "double"); + RESERVED_WORDS.put("if", "if"); + RESERVED_WORDS.put("private", "private"); + RESERVED_WORDS.put("true", "true"); + RESERVED_WORDS.put("default", "default"); + RESERVED_WORDS.put("import", "import"); + RESERVED_WORDS.put("protected", "protected"); + RESERVED_WORDS.put("try", "try"); + } +} diff --git a/swingset3/com/sun/swingset3/codeview/CodeViewer.java b/swingset3/com/sun/swingset3/codeview/CodeViewer.java new file mode 100644 index 0000000..b18ba6b --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/CodeViewer.java @@ -0,0 +1,927 @@ +/* + * 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.codeview; + +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.*; +import java.net.URL; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.text.BadLocationException; +import javax.swing.text.Highlighter; +import com.sun.swingset3.utilities.RoundedBorder; +import com.sun.swingset3.utilities.RoundedPanel; +import com.sun.swingset3.utilities.Utilities; + +/** + * GUI component for viewing a set of one or more Java source code files, + * providing the user with the ability to easily highlight specific code fragments. + * A tabbedpane is used to control which source code file is shown within the set + * if more than one file is loaded. + *

+ * Example usage: + *


+ *    CodeViewer codeViewer = new CodeViewer();
+ *    codeViewer.setSourceFiles(mySourceURLs);
+ *    frame.add(codeViewer);
+ * 
+ * + *

+ * When loading the source code, this viewer will automatically parse the files for + * any source fragments which are marked with "snippet" start/end tags that + * are embedded within Java comments. The viewer will allow the user to highlight + * these code snippets for easier inspection of specific code. + *

+ * The text following immediately after the start tag will be used + * as the key for that snippet. Multiple snippets may share the same + * key, defining a "snippet set". Snippet sets may even span across + * multiple source files. + * The key for each snippet set is displayed in a combobox to allow the user to + * select which snippet set should be highlighted. For example:

+ *


+ *    //Create dog array
+ *    ArrayList dogs = new ArrayList();
+ *    //
+ *
+ *    [other code...]
+ *
+ *    //Create dog array
+ *    dogs.add("Labrador");
+ *    dogs.add("Golden Retriever");
+ *    dogs.add("Australian Shepherd");
+ *    //
+ * 
+ * The above code would create a snippet set (containing 2 snippets) with the key + * "Create dog array". + *

+ * The viewer will allow the user to easily navigate across the currently highlighted + * snippet set by pressing the navigation buttons or using accelerator keys. + * + * @author aim + */ +public class CodeViewer extends JPanel { + public static final String SOURCES_JAVA = ".+\\.java"; + + public static final String SOURCES_TEXT = ".+\\.properties|.+\\.txt|.+\\.html|.+\\.xml"; + + public static final String SOURCES_IMAGES = ".+\\.jpg|.+\\.gif|.+\\.png"; + + private static final Color DEFAULT_HIGHLIGHT_COLOR = new Color(255,255,176); + private static BufferedImage SNIPPET_GLYPH; + private static String NO_SNIPPET_SELECTED; + + static final Logger logger = Logger.getLogger(CodeViewer.class.getName()); + + static { + try { + URL imageURL = CodeViewer.class.getResource("resources/images/snippetglyph.png"); + SNIPPET_GLYPH = ImageIO.read(imageURL); + } catch (Exception e) { + System.err.println(e); + } + } + // Cache all processed code files in case they are reloaded later + private final Map codeCache = new HashMap(); + + private JComponent codeHighlightBar; + private JComboBox snippetComboBox; + private JComponent codePanel; + private JLabel noCodeLabel; + private JTabbedPane codeTabbedPane; + + private Color highlightColor; + private Highlighter.HighlightPainter snippetPainter; + + private ResourceBundle bundle; + + // Current code file set + private Map currentCodeFilesInfo; + private List additionalSourceFiles; + + // Map of all snippets in current code file set + private final SnippetMap snippetMap = new SnippetMap(); + + private Action firstSnippetAction; + private Action nextSnippetAction; + private Action previousSnippetAction; + private Action lastSnippetAction; + + /** + * Creates a new instance of CodeViewer + */ + public CodeViewer() { + setHighlightColor(DEFAULT_HIGHLIGHT_COLOR); + + initActions(); + + setLayout(new BorderLayout()); + codeHighlightBar = createCodeHighlightBar(); + codeHighlightBar.setVisible(false); + add(codeHighlightBar, BorderLayout.NORTH); + codePanel = createCodePanel(); + add(codePanel, BorderLayout.CENTER); + + applyDefaults(); + } + + protected JComponent createCodeHighlightBar() { + GridBagLayout gridbag = new GridBagLayout(); + GridBagConstraints c = new GridBagConstraints(); + JPanel bar = new JPanel(gridbag); + + bar.setBorder(new EmptyBorder(0, 0, 10, 0)); + + NO_SNIPPET_SELECTED = getString("CodeViewer.snippets.selectOne", + "Select One"); + + JLabel snippetSetsLabel = new JLabel(getString("CodeViewer.snippets.highlightCode", + "Highlight code to: ")); + c.gridx = 0; + c.gridy = 0; + c.anchor = GridBagConstraints.WEST; + c.weightx = 0; + gridbag.addLayoutComponent(snippetSetsLabel, c); + bar.add(snippetSetsLabel); + + snippetComboBox = new JComboBox(); + snippetComboBox.setMaximumRowCount(20); + snippetComboBox.setRenderer(new SnippetCellRenderer(snippetComboBox.getRenderer())); + snippetComboBox.addActionListener(new SnippetActivator()); + snippetSetsLabel.setLabelFor(snippetComboBox); + c.gridx++; + c.weightx = 1; + gridbag.addLayoutComponent(snippetComboBox, c); + bar.add(snippetComboBox); + + SnippetNavigator snippetNavigator = new SnippetNavigator(snippetMap); + snippetNavigator.setNavigateNextAction(nextSnippetAction); + snippetNavigator.setNavigatePreviousAction(previousSnippetAction); + c.gridx++; + c.anchor = GridBagConstraints.EAST; + c.weightx = 0; + gridbag.addLayoutComponent(snippetNavigator, c); + bar.add(snippetNavigator); + + return bar; + } + + protected JComponent createCodePanel() { + + JPanel panel = new RoundedPanel(new BorderLayout(), 10); + panel.setBorder(new RoundedBorder(10)); + + noCodeLabel = new JLabel(getString("CodeViewer.noCodeLoaded", "no code loaded")); + noCodeLabel.setHorizontalAlignment(JLabel.CENTER); + panel.add(noCodeLabel, BorderLayout.CENTER); + return panel; + } + + @Override + public void updateUI() { + super.updateUI(); + applyDefaults(); + } + + protected void applyDefaults() { + if (noCodeLabel != null) { + noCodeLabel.setOpaque(false); + noCodeLabel.setFont(UIManager.getFont("Label.font").deriveFont(24f)); + noCodeLabel.setForeground( + Utilities.deriveColorAlpha(UIManager.getColor("Label.foreground"), 110)); + } + if (codePanel != null) { + Color base = UIManager.getColor("Panel.background"); + codePanel.setBackground(Utilities.deriveColorHSB(base, 0, 0, -.06f)); + } + if (snippetComboBox != null) { + // Now that the look and feel has changed, we need to wrap the new delegate + snippetComboBox.setRenderer(new SnippetCellRenderer( + new JComboBox().getRenderer())); + } + if (currentCodeFilesInfo != null) { + Collection codeFiles = currentCodeFilesInfo.values(); + for(CodeFileInfo cfi : codeFiles) { + makeSelectionTransparent(cfi.textPane, 180); + } + } + } + + private void makeSelectionTransparent(JEditorPane textPane, int alpha) { + Color c = textPane.getSelectionColor(); + textPane.setSelectionColor( + new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha)); + } + + protected String getString(String key, String fallback) { + String value = fallback; + if (bundle == null) { + String bundleName = getClass().getPackage().getName()+".resources."+getClass().getSimpleName(); + bundle = ResourceBundle.getBundle(bundleName); + } + try { + value = bundle != null? bundle.getString(key) : fallback; + + } catch (MissingResourceException e) { + logger.log(Level.WARNING, "missing String resource " + key + + "; using fallback \"" +fallback + "\""); + } + return value; + } + + protected void initActions() { + firstSnippetAction = new FirstSnippetAction(); + nextSnippetAction = new NextSnippetAction(); + previousSnippetAction = new PreviousSnippetAction(); + lastSnippetAction = new LastSnippetAction(); + + firstSnippetAction.setEnabled(false); + nextSnippetAction.setEnabled(false); + previousSnippetAction.setEnabled(false); + lastSnippetAction.setEnabled(false); + + getActionMap().put("NextSnippet", nextSnippetAction); + getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl N"),"NextSnippet"); + + getActionMap().put("PreviousSnippet", previousSnippetAction); + getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl P"),"PreviousSnippet"); + } + + public void setHighlightColor(Color highlight) { + if (!highlight.equals(highlightColor)) { + highlightColor = highlight; + snippetPainter = new SnippetHighlighter.SnippetHighlightPainter(highlightColor); + if (getCurrentSnippetKey() != null) { + repaint(); + } + } + } + + public Color getHighlightColor() { + return highlightColor; + } + + public void setSourceFiles(URL sourceFiles[]) { + if (currentCodeFilesInfo != null && additionalSourceFiles != null && sourceFiles != null && + currentCodeFilesInfo.size() + additionalSourceFiles.size() == sourceFiles.length) { + List list = Arrays.asList(sourceFiles); + + if (list.containsAll(currentCodeFilesInfo.keySet()) && list.containsAll(additionalSourceFiles)) { + // already loaded + return; + } + } + + // clear everything + clearAllSnippetHighlights(); + snippetMap.clear(); + + if (sourceFiles == null) { + // being reset to having no source files; need to clear everything + currentCodeFilesInfo = null; + additionalSourceFiles = null; + configureCodePane(false); + configureSnippetSetsComboBox(); + + } else { + // Use LinkedHashMap to save source order + currentCodeFilesInfo = new LinkedHashMap(); + additionalSourceFiles = new ArrayList(); + + boolean needProcessing = false; + for (URL sourceFile : sourceFiles) { + if (sourceFile.getFile().matches(SOURCES_JAVA)) { + // look in cache first to avoid unnecessary processing + CodeFileInfo cachedFilesInfo = codeCache.get(sourceFile); + + currentCodeFilesInfo.put(sourceFile, cachedFilesInfo); + + if (cachedFilesInfo == null) { + needProcessing = true; + } + } else { + additionalSourceFiles.add(sourceFile); + } + } + configureCodePane(true); + + if (needProcessing) { + // Do it on a separate thread + new SourceProcessor(currentCodeFilesInfo).execute(); + } else { + for (CodeFileInfo codeFileInfo : currentCodeFilesInfo.values()) { + registerSnippets(codeFileInfo); + createCodeFileTab(codeFileInfo); + } + + createAdditionalTabs(); + configureSnippetSetsComboBox(); + } + } + } + + private void createAdditionalTabs() { + JPanel pnImages = null; + + for (URL sourceFile : additionalSourceFiles) { + String sourcePath = sourceFile.getPath(); + + int i = sourcePath.indexOf('!'); + + if (i >= 0) { + sourcePath = sourcePath.substring(i + 1); + } + + if (sourceFile.getFile().matches(SOURCES_IMAGES)) { + if (pnImages == null) { + pnImages = new JPanel(); + + pnImages.setLayout(new BoxLayout(pnImages, BoxLayout.Y_AXIS)); + } + + JLabel label = new JLabel(); + + label.setIcon(new ImageIcon(sourceFile)); + label.setBorder(new EmptyBorder(10, 0, 40, 0)); + + pnImages.add(new JLabel(sourcePath)); + pnImages.add(label); + } + + if (sourceFile.getFile().matches(SOURCES_TEXT)) { + BufferedReader reader = null; + + try { + reader = new BufferedReader(new InputStreamReader(sourceFile.openStream())); + + StringBuilder content = new StringBuilder(); + + String line; + + while ((line = reader.readLine()) != null) { + content.append(line).append('\n'); + + } + + JTextArea textArea = new JTextArea(content.toString()); + Font font = textArea.getFont(); + textArea.setEditable(false); + textArea.setFont(new Font("Monospaced", font.getStyle(), font.getSize())); + + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setBorder(null); + + codeTabbedPane.addTab(Utilities.getURLFileName(sourceFile), scrollPane); + } catch (IOException e) { + System.err.println(e); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + System.err.println(e); + } + } + } + } + } + + if (pnImages != null) { + JScrollPane scrollPane = new JScrollPane(pnImages); + scrollPane.setBorder(null); + + codeTabbedPane.addTab(getString("CodeViewer.images", "Images"), scrollPane); + } + } + + private class SourceProcessor extends SwingWorker { + private final Map codeFilesInfo; + + public SourceProcessor(Map codeFilesInfo) { + this.codeFilesInfo = codeFilesInfo; + } + + public Void doInBackground() { + for (Map.Entry entry : codeFilesInfo.entrySet()) { + // if not already fetched from cache, then process source code + if (entry.getValue() == null) { + entry.setValue(initializeCodeFileInfo(entry.getKey())); + } + + // We don't publish intermediate to avoid tab mixing + codeCache.put(entry.getKey(), entry.getValue()); + } + + return null; + } + + private CodeFileInfo initializeCodeFileInfo(URL sourceFile) { + CodeFileInfo codeFileInfo = new CodeFileInfo(); + codeFileInfo.url = sourceFile; + codeFileInfo.styled = loadSourceCode(sourceFile); + codeFileInfo.textPane = new JEditorPane(); + codeFileInfo.textPane.setHighlighter(new SnippetHighlighter()); + makeSelectionTransparent(codeFileInfo.textPane, 180); + codeFileInfo.veneer = new CodeVeneer(codeFileInfo); + Stacker layers = new Stacker(codeFileInfo.textPane); + layers.add(codeFileInfo.veneer, JLayeredPane.POPUP_LAYER); + codeFileInfo.textPane.setContentType("text/html"); + codeFileInfo.textPane.setEditable(false); // HTML won't display correctly without this! + codeFileInfo.textPane.setText(codeFileInfo.styled); + codeFileInfo.textPane.setCaretPosition(0); + + // MUST parse AFTER textPane Document has been created to ensure + // snippet offsets are relative to the editor pane's Document model + codeFileInfo.snippets = SnippetParser.parse(codeFileInfo.textPane.getDocument()); + return codeFileInfo; + } + + protected void done() { + try { + // It's possible that by now another set of source files has been loaded. + // so check first before adding the source tab;' + if (currentCodeFilesInfo == codeFilesInfo) { + for (CodeFileInfo codeFileInfo : currentCodeFilesInfo.values()) { + registerSnippets(codeFileInfo); + createCodeFileTab(codeFileInfo); + } + } else { + logger.log(Level.FINEST, "source files changed before sources was processed."); + } + + createAdditionalTabs(); + configureSnippetSetsComboBox(); + } catch (Exception ex) { + System.err.println(ex); + } + } + } // SourceProcessor + + // Called from Source Processing Thread in SwingWorker + + private void configureCodePane(boolean hasCodeFiles) { + if (hasCodeFiles) { + if (codeTabbedPane == null) { + codeTabbedPane = new JTabbedPane(); + codePanel.remove(noCodeLabel); + codePanel.add(codeTabbedPane); + revalidate(); + } else { + codeTabbedPane.removeAll(); + } + } else { + // No code files + if (codeTabbedPane != null) { + codePanel.remove(codeTabbedPane); + codeTabbedPane = null; + codePanel.add(noCodeLabel); + revalidate(); + } + } + } + + private void createCodeFileTab(CodeFileInfo codeFileInfo) { + JLayeredPane layeredPane = JLayeredPane.getLayeredPaneAbove(codeFileInfo.textPane); + JScrollPane scrollPane = new JScrollPane(layeredPane); + scrollPane.setBorder(null); + JPanel tabPanel = new JPanel(); + tabPanel.setLayout(new BorderLayout()); + + tabPanel.add(scrollPane, BorderLayout.CENTER); + + codeTabbedPane.addTab(Utilities.getURLFileName(codeFileInfo.url), tabPanel); + } + + private void registerSnippets(CodeFileInfo codeFileInfo) { + for(String snippetKey: codeFileInfo.snippets.keySet()) { + List snippetCodeList = codeFileInfo.snippets.get(snippetKey); + for(Snippet snippet: snippetCodeList) { + snippetMap.add(snippetKey, codeFileInfo.url, snippet); + } + } + } + + private void configureSnippetSetsComboBox() { + TreeSet sortedSnippets = new TreeSet(snippetMap.keySet()); + String snippetSetKeys[] = (String[])sortedSnippets.toArray(new String[0]); + + DefaultComboBoxModel snippetModel = new DefaultComboBoxModel(); + for(String snippetKey : snippetSetKeys) { + snippetModel.addElement(snippetKey); + } + snippetModel.insertElementAt(NO_SNIPPET_SELECTED, 0); + snippetModel.setSelectedItem(NO_SNIPPET_SELECTED); + snippetComboBox.setModel(snippetModel); + codeHighlightBar.setVisible(snippetModel.getSize() > 1); + + } + + /** + * Reads the java source file at the specified URL and returns an + * HTML version stylized for display + */ + protected String loadSourceCode(URL sourceUrl) { + InputStreamReader isr = null; + CodeStyler cv = new CodeStyler(); + String styledCode = "

";
+        
+        try {
+            isr = new InputStreamReader(sourceUrl.openStream(), "UTF-8");
+            BufferedReader reader = new BufferedReader(isr);
+            
+            // Read one line at a time, htmlizing using super-spiffy
+            // html java code formating utility from www.CoolServlets.com
+            String line = reader.readLine();
+            while(line != null) {
+                styledCode += cv.syntaxHighlight(line) + " \n ";
+                line = reader.readLine();
+            }
+            styledCode += "
"; + + } catch (Exception ex) { + ex.printStackTrace(); + return "Could not load file from: " + sourceUrl; + } finally { + if (isr != null) { + try { + isr.close(); + } catch (IOException e) { + System.err.println(e); + } + } + } + return styledCode; + } + + public void clearAllSnippetHighlights() { + if (currentCodeFilesInfo != null) { + snippetMap.setCurrentSet(null); + for(CodeFileInfo code : currentCodeFilesInfo.values()) { + if (code != null && code.textPane != null) { + Highlighter highlighter = code.textPane.getHighlighter(); + highlighter.removeAllHighlights(); + code.textPane.repaint(); + code.veneer.repaint(); + } + } + } + } + + public void highlightSnippetSet(String snippetKey) { + + clearAllSnippetHighlights(); + snippetMap.setCurrentSet(snippetKey); + + URL files[] = snippetMap.getFilesForSet(snippetKey); + CodeFileInfo firstCodeFileInfo = null; + Snippet firstSnippet = null; + for(URL file : files) { + CodeFileInfo codeFileInfo = codeCache.get(file); + Highlighter highlighter = codeFileInfo.textPane.getHighlighter(); + // now add highlight for each snippet in this file associated + // with the key + Snippet snippets[] = snippetMap.getSnippetsForFile(snippetKey, file); + if (firstCodeFileInfo == null) { + firstCodeFileInfo = codeFileInfo; + firstSnippet = snippets[0]; + } + for (Snippet snippet : snippets) { + try { + highlighter.addHighlight(snippet.startLine, + snippet.endLine, snippetPainter ); + codeFileInfo.veneer.repaint(); + } catch (BadLocationException e) { + e.printStackTrace(); + } + } + } + scrollToSnippet(firstCodeFileInfo, firstSnippet); + snippetComboBox.setSelectedItem(snippetKey); + } + + protected void scrollToSnippet(CodeFileInfo codeFileInfo, Snippet snippet) { + if (!codeFileInfo.textPane.isShowing()) { + // Need to switch tabs to source file with first snippet + // remind: too brittle - need to find component some other way + codeTabbedPane.setSelectedComponent( + JLayeredPane.getLayeredPaneAbove(codeFileInfo.textPane).getParent().getParent().getParent()); + } + try { + Rectangle r1 = codeFileInfo.textPane.modelToView(snippet.startLine); + Rectangle r2 = codeFileInfo.textPane.modelToView(snippet.endLine); + codeFileInfo.textPane.scrollRectToVisible( + SwingUtilities.computeUnion(r1.x, r1.y, + r1.width, r1.height, r2)); + } catch (BadLocationException e) { + System.err.println(e); + } + nextSnippetAction.setEnabled(snippetMap.nextSnippetExists()); + previousSnippetAction.setEnabled(snippetMap.previousSnippetExists()); + } + + protected String getCurrentSnippetKey() { + String key = snippetMap.getCurrentSet(); + return key != null? key : NO_SNIPPET_SELECTED; + } + + protected Snippet getCurrentSnippet() { + return snippetMap.getCurrentSnippet(); + } + + protected void moveToFirstSnippet() { + Snippet firstSnippet = snippetMap.firstSnippet(); + if (firstSnippet != null) { + CodeFileInfo codeFileInfo = codeCache.get(snippetMap.getFileForSnippet(firstSnippet)); + scrollToSnippet(codeFileInfo, firstSnippet); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + + protected void moveToNextSnippet() { + Snippet nextSnippet = snippetMap.nextSnippet(); + if (nextSnippet != null) { + CodeFileInfo codeFileInfo = codeCache.get(snippetMap.getFileForSnippet(nextSnippet)); + scrollToSnippet(codeFileInfo, nextSnippet); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + + protected void moveToPreviousSnippet() { + Snippet previousSnippet = snippetMap.previousSnippet(); + if (previousSnippet != null) { + CodeFileInfo codeFileInfo = codeCache.get(snippetMap.getFileForSnippet(previousSnippet)); + scrollToSnippet(codeFileInfo, previousSnippet); + } else { + Toolkit.getDefaultToolkit().beep(); + } + + } + + protected void moveToLastSnippet() { + Snippet lastSnippet = snippetMap.lastSnippet(); + if (lastSnippet != null) { + CodeFileInfo codeFileInfo = codeCache.get(snippetMap.getFileForSnippet(lastSnippet)); + scrollToSnippet(codeFileInfo, lastSnippet); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + + private class SnippetActivator implements ActionListener { + public void actionPerformed(ActionEvent e) { + String snippetKey = (String)snippetComboBox.getSelectedItem(); + if (!snippetKey.equals(NO_SNIPPET_SELECTED)) { + logger.log(Level.FINEST, "highlighting new snippet:"+snippetKey+"."); + highlightSnippetSet(snippetKey); + } else { + clearAllSnippetHighlights(); + } + } + } + + private abstract class SnippetAction extends AbstractAction { + public SnippetAction(String name, String shortDescription) { + super(name); + putValue(AbstractAction.SHORT_DESCRIPTION, shortDescription); + } + } + private class FirstSnippetAction extends SnippetAction { + public FirstSnippetAction() { + super("FirstSnippet", + getString("CodeViewer.snippets.navigateFirst", + "move to first code snippet within highlighted set")); + } + public void actionPerformed(ActionEvent e) { + moveToFirstSnippet(); + } + } + + private class NextSnippetAction extends SnippetAction { + public NextSnippetAction() { + super("NextSnippet", + getString("CodeViewer.snippets.navigateNext", + "move to next code snippet within highlighted set")); + } + @Override + public void actionPerformed(ActionEvent e) { + moveToNextSnippet(); + } + } + + private class PreviousSnippetAction extends SnippetAction { + public PreviousSnippetAction() { + super("PreviousSnippet", + getString("CodeViewer.snippets.navigatePrevious", + "move to previous code fragment within highlighted set")); + } + @Override + public void actionPerformed(ActionEvent e) { + moveToPreviousSnippet(); + } + } + + private class LastSnippetAction extends SnippetAction { + public LastSnippetAction() { + super("LastSnippet", + getString("CodeViewer.snippets.navigateLast", + "move to last code snippet within highlighted set")); + } + public void actionPerformed(ActionEvent e) { + moveToLastSnippet(); + } + } + + private class SnippetCellRenderer implements ListCellRenderer { + private JLabel delegate; + + public SnippetCellRenderer(ListCellRenderer delegate) { + this.delegate = (JLabel)delegate; + } + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + + JLabel renderer = (JLabel)((ListCellRenderer)delegate).getListCellRendererComponent(list, + value, index, isSelected, cellHasFocus); + + int count = snippetMap.getSnippetCountForSet((String)value); + + Color foreground = renderer.getForeground(); + Color countForeground = Utilities.deriveColorHSB(foreground, + 0, 0, isSelected? .5f : .4f); + + String text = "" + value + + "" + + "" + + (count > 0? " (" + count + (count > 1? " snippets)" : " snippet)") : "") + + ""; + + renderer.setText(text); + return renderer; + } + } + + + + private static class CodeFileInfo { + public URL url; + public String styled; + public HashMap> snippets = new HashMap>(); + public JEditorPane textPane; + public JPanel veneer; + } + + private static class Stacker extends JLayeredPane { + private Component master; // dictates sizing, scrolling + + public Stacker(Component master) { + this.master = master; + setLayout(null); + add(master, JLayeredPane.DEFAULT_LAYER); + } + + public Dimension getPreferredSize() { + return master.getPreferredSize(); + } + + public void doLayout() { + // ensure all layers are sized the same + Dimension size = getSize(); + Component layers[] = getComponents(); + for(Component layer : layers) { + layer.setBounds(0, 0, size.width, size.height); + } + } + } + + private class CodeVeneer extends JPanel { + private CodeFileInfo codeFileInfo; + + public CodeVeneer(CodeFileInfo codeFileInfo) { + this.codeFileInfo = codeFileInfo; + setOpaque(false); + setLayout(null); + } + + @Override + protected void paintComponent(Graphics g) { + + String snippetKey = getCurrentSnippetKey(); + if (snippetKey != NO_SNIPPET_SELECTED) { + // Count total number of snippets for key + int snippetTotal = 0; + int snippetIndex = 0; + List snippetList = null; + URL files[] = snippetMap.getFilesForSet(snippetKey); + for(URL file : files) { + CodeFileInfo codeFileInfo = codeCache.get(file); + if (this.codeFileInfo == codeFileInfo) { + snippetList = codeFileInfo.snippets.get(snippetKey); + snippetIndex = snippetTotal + 1; + } + snippetTotal += (codeFileInfo.snippets.get(snippetKey).size()); + } + + if (snippetList != null) { + Snippet currentSnippet = snippetMap.getCurrentSnippet(); + CodeFileInfo currentSnippetCodeFileInfo = codeCache.get( + snippetMap.getFileForSnippet(currentSnippet)); + + Font font = g.getFont(); + g.setFont(font.deriveFont(10f)); + FontMetrics metrics = g.getFontMetrics(); + + g.setColor(getHighlightColor()); + + Graphics2D g2Alpha = null; // cache composite + for(Snippet snippet : snippetList) { + Graphics2D g2 = (Graphics2D)g; + + try { + if (currentSnippetCodeFileInfo != codeFileInfo || + currentSnippet != snippet) { + // if not painting the "current" snippet, then fade the glyph + if (g2Alpha == null) { + // first time, so create composite + g2Alpha = (Graphics2D)g2.create(); + g2Alpha.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, 0.6f)); + } + g2 = g2Alpha; + } + Rectangle snipRect = codeFileInfo.textPane.modelToView(snippet.startLine); + + //String glyphLabel = snippetIndex++ + "/" + snippetTotal; + String glyphLabel = "" + snippetIndex++; + Rectangle labelRect = metrics.getStringBounds(glyphLabel, g2).getBounds(); + + g2.drawImage(SNIPPET_GLYPH, 0, snipRect.y, this); + g2.setColor(Color.black); + g2.drawString(glyphLabel, + (SNIPPET_GLYPH.getWidth(this) - labelRect.width)/2, + snipRect.y + + (SNIPPET_GLYPH.getHeight(this) - labelRect.height)/2 + + metrics.getAscent()); + + } catch (BadLocationException e) { + System.err.println(e); + } + } + } + } + } + } +} diff --git a/swingset3/com/sun/swingset3/codeview/Snippet.java b/swingset3/com/sun/swingset3/codeview/Snippet.java new file mode 100644 index 0000000..9b2fcd4 --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/Snippet.java @@ -0,0 +1,51 @@ +/* + * 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.codeview; + +import javax.swing.text.Document; + +/** + * + * @author aim + */ +public class Snippet { + Document document; + String key = null; + int startLine = -1; + int endLine = -1; + + public Snippet(Document document, String key, int startLine) { + this.document = document; + this.key = key; + this.startLine = startLine; + } +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/codeview/SnippetHighlighter.java b/swingset3/com/sun/swingset3/codeview/SnippetHighlighter.java new file mode 100644 index 0000000..05a2654 --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/SnippetHighlighter.java @@ -0,0 +1,661 @@ +/* + * 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.codeview; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.Shape; +import java.util.*; +import javax.swing.SwingUtilities; +import javax.swing.plaf.TextUI; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Highlighter; +import javax.swing.text.JTextComponent; +import javax.swing.text.LayeredHighlighter; +import javax.swing.text.Position; +import javax.swing.text.View; + +/** + * Implements the Highlighter interfaces. Implements a simple highlight + * painter that renders in a solid color. + * + * @see Highlighter + */ +public class SnippetHighlighter extends LayeredHighlighter { + + /** + * Creates a new DefaultHighlighther object. + */ + public SnippetHighlighter() { + drawsLayeredHighlights = true; + } + + // ---- Highlighter methods ---------------------------------------------- + + /** + * Renders the highlights. + * + * @param g the graphics context + */ + public void paint(Graphics g) { + // PENDING(prinz) - should cull ranges not visible + int len = highlights.size(); + for (int i = 0; i < len; i++) { + HighlightInfo info = highlights.elementAt(i); + if (!(info instanceof LayeredHighlightInfo)) { + // Avoid allocing unless we need it. + Rectangle a = component.getBounds(); + Insets insets = component.getInsets(); + a.x = insets.left; + a.y = insets.top; + a.width -= insets.left + insets.right; + a.height -= insets.top + insets.bottom; + for (; i < len; i++) { + info = highlights.elementAt(i); + if (!(info instanceof LayeredHighlightInfo)) { + Highlighter.HighlightPainter p = info.getPainter(); + p.paint(g, info.getStartOffset(), info.getEndOffset(), + a, component); + } + } + } + } + } + + /** + * Called when the UI is being installed into the + * interface of a JTextComponent. Installs the editor, and + * removes any existing highlights. + * + * @param c the editor component + * @see Highlighter#install + */ + public void install(JTextComponent c) { + component = c; + removeAllHighlights(); + } + + /** + * Called when the UI is being removed from the interface of + * a JTextComponent. + * + * @param c the component + * @see Highlighter#deinstall + */ + public void deinstall(JTextComponent c) { + component = null; + } + + /** + * Adds a highlight to the view. Returns a tag that can be used + * to refer to the highlight. + * + * @param p0 the start offset of the range to highlight >= 0 + * @param p1 the end offset of the range to highlight >= p0 + * @param p the painter to use to actually render the highlight + * @return an object that can be used as a tag + * to refer to the highlight + * @exception BadLocationException if the specified location is invalid + */ + public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException { + Document doc = component.getDocument(); + HighlightInfo i = (getDrawsLayeredHighlights() && + (p instanceof LayeredHighlighter.LayerPainter)) ? + new LayeredHighlightInfo() : new HighlightInfo(); + i.painter = p; + i.p0 = doc.createPosition(p0); + i.p1 = doc.createPosition(p1); + // For snippets, we want to make sure selection is layered ON TOP + // since we add transparency to the selection color; so rather + // than append the highlight, we insert it in the front. + highlights.insertElementAt(i, 0); + safeDamageRange(p0, p1); + return i; + } + + /** + * Removes a highlight from the view. + * + * @param tag the reference to the highlight + */ + public void removeHighlight(Object tag) { + if (tag instanceof LayeredHighlightInfo) { + LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; + if (lhi.width > 0 && lhi.height > 0) { + component.repaint(lhi.x, lhi.y, lhi.width, lhi.height); + } + } + else { + HighlightInfo info = (HighlightInfo) tag; + safeDamageRange(info.p0, info.p1); + } + highlights.removeElement(tag); + } + + /** + * Removes all highlights. + */ + public void removeAllHighlights() { + TextUI mapper = component.getUI(); + if (getDrawsLayeredHighlights()) { + int len = highlights.size(); + if (len != 0) { + int minX = 0; + int minY = 0; + int maxX = 0; + int maxY = 0; + int p0 = -1; + int p1 = -1; + for (int i = 0; i < len; i++) { + HighlightInfo hi = highlights.elementAt(i); + if (hi instanceof LayeredHighlightInfo) { + LayeredHighlightInfo info = (LayeredHighlightInfo)hi; + minX = Math.min(minX, info.x); + minY = Math.min(minY, info.y); + maxX = Math.max(maxX, info.x + info.width); + maxY = Math.max(maxY, info.y + info.height); + } + else { + if (p0 == -1) { + p0 = hi.p0.getOffset(); + p1 = hi.p1.getOffset(); + } + else { + p0 = Math.min(p0, hi.p0.getOffset()); + p1 = Math.max(p1, hi.p1.getOffset()); + } + } + } + if (minX != maxX && minY != maxY) { + component.repaint(minX, minY, maxX - minX, maxY - minY); + } + if (p0 != -1) { + try { + safeDamageRange(p0, p1); + } catch (BadLocationException e) {} + } + highlights.removeAllElements(); + } + } + else if (mapper != null) { + int len = highlights.size(); + if (len != 0) { + int p0 = Integer.MAX_VALUE; + int p1 = 0; + for (int i = 0; i < len; i++) { + HighlightInfo info = highlights.elementAt(i); + p0 = Math.min(p0, info.p0.getOffset()); + p1 = Math.max(p1, info.p1.getOffset()); + } + try { + safeDamageRange(p0, p1); + } catch (BadLocationException e) {} + + highlights.removeAllElements(); + } + } + } + + /** + * Changes a highlight. + * + * @param tag the highlight tag + * @param p0 the beginning of the range >= 0 + * @param p1 the end of the range >= p0 + * @exception BadLocationException if the specified location is invalid + */ + public void changeHighlight(Object tag, int p0, int p1) throws BadLocationException { + Document doc = component.getDocument(); + if (tag instanceof LayeredHighlightInfo) { + LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; + if (lhi.width > 0 && lhi.height > 0) { + component.repaint(lhi.x, lhi.y, lhi.width, lhi.height); + } + // Mark the highlights region as invalid, it will reset itself + // next time asked to paint. + lhi.width = lhi.height = 0; + lhi.p0 = doc.createPosition(p0); + lhi.p1 = doc.createPosition(p1); + safeDamageRange(Math.min(p0, p1), Math.max(p0, p1)); + } + else { + HighlightInfo info = (HighlightInfo) tag; + int oldP0 = info.p0.getOffset(); + int oldP1 = info.p1.getOffset(); + if (p0 == oldP0) { + safeDamageRange(Math.min(oldP1, p1), + Math.max(oldP1, p1)); + } else if (p1 == oldP1) { + safeDamageRange(Math.min(p0, oldP0), + Math.max(p0, oldP0)); + } else { + safeDamageRange(oldP0, oldP1); + safeDamageRange(p0, p1); + } + info.p0 = doc.createPosition(p0); + info.p1 = doc.createPosition(p1); + } + } + + /** + * Makes a copy of the highlights. Does not actually clone each highlight, + * but only makes references to them. + * + * @return the copy + * @see Highlighter#getHighlights + */ + public Highlighter.Highlight[] getHighlights() { + int size = highlights.size(); + if (size == 0) { + return noHighlights; + } + Highlighter.Highlight[] h = new Highlighter.Highlight[size]; + highlights.copyInto(h); + return h; + } + + /** + * When leaf Views (such as LabelView) are rendering they should + * call into this method. If a highlight is in the given region it will + * be drawn immediately. + * + * @param g Graphics used to draw + * @param p0 starting offset of view + * @param p1 ending offset of view + * @param viewBounds Bounds of View + * @param editor JTextComponent + * @param view View instance being rendered + */ + public void paintLayeredHighlights(Graphics g, int p0, int p1, + Shape viewBounds, + JTextComponent editor, View view) { + for (int counter = highlights.size() - 1; counter >= 0; counter--) { + Object tag = highlights.elementAt(counter); + if (tag instanceof LayeredHighlightInfo) { + LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; + int start = lhi.getStartOffset(); + int end = lhi.getEndOffset(); + if ((p0 < start && p1 > start) || + (p0 >= start && p0 < end)) { + lhi.paintLayeredHighlights(g, p0, p1, viewBounds, + editor, view); + } + } + } + } + + /** + * Queues damageRange() call into event dispatch thread + * to be sure that views are in consistent state. + */ + private void safeDamageRange(final Position p0, final Position p1) { + safeDamager.damageRange(p0, p1); + } + + /** + * Queues damageRange() call into event dispatch thread + * to be sure that views are in consistent state. + */ + private void safeDamageRange(int a0, int a1) throws BadLocationException { + Document doc = component.getDocument(); + safeDamageRange(doc.createPosition(a0), doc.createPosition(a1)); + } + + /** + * If true, highlights are drawn as the Views draw the text. That is + * the Views will call into paintLayeredHighlight which + * will result in a rectangle being drawn before the text is drawn + * (if the offsets are in a highlighted region that is). For this to + * work the painter supplied must be an instance of + * LayeredHighlightPainter. + */ + public void setDrawsLayeredHighlights(boolean newValue) { + drawsLayeredHighlights = newValue; + } + + public boolean getDrawsLayeredHighlights() { + return drawsLayeredHighlights; + } + + // ---- member variables -------------------------------------------- + + private final static Highlighter.Highlight[] noHighlights = + new Highlighter.Highlight[0]; + private final Vector highlights = new Vector(); + private JTextComponent component; + private boolean drawsLayeredHighlights; + private final SafeDamager safeDamager = new SafeDamager(); + + + /** + * Default implementation of LayeredHighlighter.LayerPainter that can + * be used for painting highlights. + *

+ * As of 1.4 this field is final. + */ + public static LayeredHighlighter.LayerPainter SnippetPainter = new SnippetHighlightPainter(null); + + + /** + * Simple highlight painter that fills a highlighted area with + * a solid color. + */ + public static class SnippetHighlightPainter extends LayeredHighlighter.LayerPainter { + + /** + * Constructs a new highlight painter. If c is null, + * the JTextComponent will be queried for its selection color. + * + * @param c the color for the highlight + */ + public SnippetHighlightPainter(Color c) { + color = c; + } + + /** + * Returns the color of the highlight. + * + * @return the color + */ + public Color getColor() { + return color; + } + + // --- HighlightPainter methods --------------------------------------- + + /** + * Paints a highlight. + * + * @param g the graphics context + * @param offs0 the starting model offset >= 0 + * @param offs1 the ending model offset >= offs1 + * @param bounds the bounding box for the highlight + * @param c the editor + */ + public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) { + Rectangle alloc = bounds.getBounds(); + try { + // --- determine locations --- + TextUI mapper = c.getUI(); + Rectangle p0 = mapper.modelToView(c, offs0); + Rectangle p1 = mapper.modelToView(c, offs1); + + // --- render --- + Color color = getColor(); + + if (color == null) { + g.setColor(c.getSelectionColor()); + } + else { + g.setColor(color); + } + if (p0.y == p1.y) { + // same line, render a rectangle + Rectangle r = p0.union(p1); + g.fillRect(r.x, r.y, r.width, r.height); + } else { + // different lines + int p0ToMarginWidth = alloc.x + alloc.width - p0.x; + g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height); + if ((p0.y + p0.height) != p1.y) { + g.fillRect(alloc.x, p0.y + p0.height, alloc.width, + p1.y - (p0.y + p0.height)); + } + g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height); + } + } catch (BadLocationException e) { + // can't render + } + } + + // --- LayerPainter methods ---------------------------- + /** + * Paints a portion of a highlight. + * + * @param g the graphics context + * @param offs0 the starting model offset >= 0 + * @param offs1 the ending model offset >= offs1 + * @param bounds the bounding box of the view, which is not + * necessarily the region to paint. + * @param c the editor + * @param view View painting for + * @return region drawing occured in + */ + public Shape paintLayer(Graphics g, int offs0, int offs1, + Shape bounds, JTextComponent c, View view) { + Color base = getColor(); + // use transparency so selection isn't clobbered + Color color = base != null? + new Color(base.getRed(), base.getGreen(), base.getBlue(), + 255) : null; + + if (color == null) { + g.setColor(c.getSelectionColor()); + } + else { + g.setColor(color); + } + if (offs0 == view.getStartOffset() && + offs1 == view.getEndOffset()) { + // Contained in view, can just use bounds. + Rectangle alloc; + if (bounds instanceof Rectangle) { + alloc = (Rectangle)bounds; + } + else { + alloc = bounds.getBounds(); + } + // For CodeViewer Snippet painting, this is the paint block that is called. + // We want to paint the highlight on the full width of the text pane, + // so we only need to do this when the region is the beginning of a new + // line. + //g.fillRect(alloc.x, alloc.y, alloc.width, alloc.height); + g.fillRect(alloc.x, alloc.y, c.getWidth() - alloc.x, alloc.height); + + } + else { + // Should only render part of View. + try { + // --- determine locations --- + Shape shape = view.modelToView(offs0, Position.Bias.Forward, + offs1,Position.Bias.Backward, + bounds); + Rectangle r = (shape instanceof Rectangle) ? + (Rectangle)shape : shape.getBounds(); + + g.fillRect(0, r.y, c.getWidth(), r.height); + return r; + } catch (BadLocationException e) { + // can't render + } + } + // Only if exception + return null; + } + + private Color color; + + } + + + private static class HighlightInfo implements Highlighter.Highlight { + + public int getStartOffset() { + return p0.getOffset(); + } + + public int getEndOffset() { + return p1.getOffset(); + } + + public Highlighter.HighlightPainter getPainter() { + return painter; + } + + Position p0; + Position p1; + Highlighter.HighlightPainter painter; + } + + + /** + * LayeredHighlightPainter is used when a drawsLayeredHighlights is + * true. It maintains a rectangle of the region to paint. + */ + private static class LayeredHighlightInfo extends HighlightInfo { + + void union(Shape bounds) { + if (bounds == null) + return; + + Rectangle alloc; + if (bounds instanceof Rectangle) { + alloc = (Rectangle)bounds; + } + else { + alloc = bounds.getBounds(); + } + if (width == 0 || height == 0) { + x = alloc.x; + y = alloc.y; + width = alloc.width; + height = alloc.height; + } + else { + width = Math.max(x + width, alloc.x + alloc.width); + height = Math.max(y + height, alloc.y + alloc.height); + x = Math.min(x, alloc.x); + width -= x; + y = Math.min(y, alloc.y); + height -= y; + } + } + + /** + * Restricts the region based on the receivers offsets and messages + * the painter to paint the region. + */ + void paintLayeredHighlights(Graphics g, int p0, int p1, + Shape viewBounds, JTextComponent editor, + View view) { + int start = getStartOffset(); + int end = getEndOffset(); + // Restrict the region to what we represent + p0 = Math.max(start, p0); + p1 = Math.min(end, p1); + // Paint the appropriate region using the painter and union + // the effected region with our bounds. + union(((LayeredHighlighter.LayerPainter)painter).paintLayer + (g, p0, p1, viewBounds, editor, view)); + } + + int x; + int y; + int width; + int height; + } + + /** + * This class invokes mapper.damageRange in + * EventDispatchThread. The only one instance per Highlighter + * is cretaed. When a number of ranges should be damaged + * it collects them into queue and damages + * them in consecutive order in run + * call. + */ + class SafeDamager implements Runnable { + private final List p0 = new ArrayList(); + private final List p1 = new ArrayList(); + private Document lastDoc = null; + + /** + * Executes range(s) damage and cleans range queue. + */ + public synchronized void run() { + if (component != null) { + TextUI mapper = component.getUI(); + if (mapper != null && lastDoc == component.getDocument()) { + // the Document should be the same to properly + // display highlights + int len = p0.size(); + for (int i = 0; i < len; i++){ + mapper.damageRange(component, + p0.get(i).getOffset(), + p1.get(i).getOffset()); + } + } + } + p0.clear(); + p1.clear(); + + // release reference + lastDoc = null; + } + + /** + * Adds the range to be damaged into the range queue. If the + * range queue is empty (the first call or run() was already + * invoked) then adds this class instance into EventDispatch + * queue. + * + * The method also tracks if the current document changed or + * component is null. In this case it removes all ranges added + * before from range queue. + */ + private synchronized void damageRange(Position pos0, Position pos1) { + if (component == null) { + p0.clear(); + lastDoc = null; + return; + } + + boolean addToQueue = p0.isEmpty(); + Document curDoc = component.getDocument(); + if (curDoc != lastDoc) { + if (!p0.isEmpty()) { + p0.clear(); + p1.clear(); + } + lastDoc = curDoc; + } + p0.add(pos0); + p1.add(pos1); + + if (addToQueue) { + SwingUtilities.invokeLater(this); + } + } + } +} diff --git a/swingset3/com/sun/swingset3/codeview/SnippetMap.java b/swingset3/com/sun/swingset3/codeview/SnippetMap.java new file mode 100644 index 0000000..bfb129a --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/SnippetMap.java @@ -0,0 +1,339 @@ +/* + * 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.codeview; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.net.URL; +import java.util.*; + +/** + * Data structure to support maintaining Snippet information across a + * set of source code files: + * + * SnippetMap + * | + * --------------------------------------- + * | | | + * snippet key "A" Snippet key "B" Snippet key "C" + * | | | + * ---------------- ------ ------------- + * | | | | + * File1.java File3.java File2.java File3.java + * | | | | + * ---------- --- --- ----- + * | | | | | + * snipA-1 snipA-2 snipA-3 snipB-1 snipC-1 + * + * + * This class also maintains a pointer to a "current" snippet within + * a selected set. + * + * + * @author aim + */ +public class SnippetMap { + private final HashMap> snippetSets = new HashMap>(); + + private String currentKey; + private List currentSet; + private FileSnippets currentFileSnippets; + private int currentFileSnippetsIndex; + private int currentSnippetIndex; + private Snippet currentSnippet; + + private PropertyChangeSupport pcs; + + /** Creates a new instance of SnippetMap */ + public SnippetMap() { + pcs = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener pcl) { + pcs.addPropertyChangeListener(pcl); + } + + public void add(String key, URL codeFile, Snippet snippet) { + List fileSnippetList = snippetSets.get(key); + if (fileSnippetList == null) { + // new key! so create new set... + fileSnippetList = new ArrayList(); + snippetSets.put(key, fileSnippetList); + } + + FileSnippets fileSnippets = findFileSnippetsForFile(fileSnippetList, codeFile); + if (fileSnippets == null) { + // found first snippet in this file + fileSnippets = new FileSnippets(key, codeFile); + fileSnippetList.add(fileSnippets); + } + if (!fileSnippets.snippets.contains(snippet)) { + fileSnippets.snippets.add(snippet); + } + + } + + public Set keySet() { + return snippetSets.keySet(); + } + + public int getSnippetCountForSet(String key) { + int count = 0; + URL files[] = getFilesForSet(key); + for(URL file : files) { + Snippet snippets[] = getSnippetsForFile(key, file); + count += snippets.length; + } + return count; + } + + public URL[] getFilesForSet(String key) { + List fileSnippetList = snippetSets.get(key); + URL files[]; + if (fileSnippetList != null) { + files = new URL[fileSnippetList.size()]; + int i = 0; + for(FileSnippets fileSnippets : fileSnippetList) { + files[i++] = fileSnippets.file; + } + } else { + files = new URL[0]; + } + return files; + } + + public Snippet[] getSnippetsForFile(String key, URL file) { + List fileSnippetList = snippetSets.get(key); + FileSnippets fileSnippets = findFileSnippetsForFile(fileSnippetList, file); + if (fileSnippets != null) { + if (fileSnippets.snippets != null) { + return fileSnippets.snippets.toArray(new Snippet[0]); + } + } + return new Snippet[0]; + } + + public int getIndexForSnippet(Snippet snippet) { + List fileSnippetList = snippetSets.get(snippet.key); + if (fileSnippetList != null) { + int index = 1; + for(FileSnippets fileSnippets : fileSnippetList) { + for(Snippet snippetInFile : fileSnippets.snippets) { + if (snippetInFile == snippet) { + return index; + } else { + index++; + } + } + } + } + return -1; + } + + public URL getFileForSnippet(Snippet snippet) { + List fileSnippetList = snippetSets.get(snippet.key); + if (fileSnippetList != null) { + for(FileSnippets fileSnippets : fileSnippetList) { + for(Snippet snippetInFile : fileSnippets.snippets) { + if (snippetInFile == snippet) { + return fileSnippets.file; + } + } + } + } + return null; + } + + public boolean isEmpty() { + return snippetSets.isEmpty(); + } + + public int getSize() { + return snippetSets.size(); + } + + public void clear() { + snippetSets.clear(); + setCurrentSnippet(null); + setCurrentSet(null); + } + + public void setCurrentSet(String key) { + String oldKey = currentKey; + + if (key == null) { + // current snippet being cleared + currentKey = null; + currentSet = null; + currentFileSnippets = null; + currentFileSnippetsIndex = -1; + currentSnippetIndex = -1; + } else { + List fileSnippetList = snippetSets.get(key); + if (fileSnippetList == null) { + throw new IllegalArgumentException("snippet key " + key + " does not exist."); + } + currentKey = key; + currentSet = fileSnippetList; + currentFileSnippetsIndex = 0; + currentFileSnippets = currentSet.get(currentFileSnippetsIndex); + currentSnippetIndex = 0; + currentSnippet = currentFileSnippets.snippets.get(currentSnippetIndex); + } + pcs.firePropertyChange("currentSet", oldKey, currentKey); + pcs.firePropertyChange("currentSnippet", null, currentSnippet); + + } + + public String getCurrentSet() { + return currentKey; + } + + public Snippet getCurrentSnippet() { + return currentSnippet; + } + + protected void setCurrentSnippet(Snippet snippet) { + Snippet oldCurrentSnippet = currentSnippet; + currentSnippet = snippet; + pcs.firePropertyChange("currentSnippet", oldCurrentSnippet, snippet); + } + + public Snippet firstSnippet() { + if (currentKey != null) { + currentFileSnippetsIndex = 0; + currentFileSnippets = currentSet.get(currentFileSnippetsIndex); + currentSnippetIndex = 0; + Snippet firstSnippet = currentFileSnippets.snippets.get(currentSnippetIndex); + setCurrentSnippet(firstSnippet); + return getCurrentSnippet(); + } + return null; + } + + public boolean nextSnippetExists() { + if (currentKey != null) { + if (currentSnippetIndex+1 < currentFileSnippets.snippets.size()) { + // There is a next snippet in the current file + return true; + } + if (currentFileSnippetsIndex+1 < currentSet.size()) { + // There is another file containing the next snippet + return true; + } + } + return false; + } + + public Snippet nextSnippet() { + if (currentKey != null) { + if (currentSnippetIndex+1 < currentFileSnippets.snippets.size()) { + // There is a next snippet in the current file + setCurrentSnippet(currentFileSnippets.snippets.get(++currentSnippetIndex)); + return getCurrentSnippet(); + } + if (currentFileSnippetsIndex+1 < currentSet.size()) { + // The next snippet is contained in the next file + currentFileSnippets = currentSet.get(++currentFileSnippetsIndex); + currentSnippetIndex = 0; + setCurrentSnippet(currentFileSnippets.snippets.get(currentSnippetIndex)); + return getCurrentSnippet(); + } + } + return null; + } + + public boolean previousSnippetExists() { + if (currentKey != null) { + if (currentSnippetIndex-1 >= 0) { + // There is a previous snippet in the current file + return true; + } + if (currentFileSnippetsIndex-1 >= 0) { + // There is a previous file containing the previous snippet + return true; + } + } + return false; + } + + public Snippet previousSnippet() { + if (currentKey != null) { + if (currentSnippetIndex-1 >= 0) { + // There is a previous snippet in the current file + setCurrentSnippet(currentFileSnippets.snippets.get(--currentSnippetIndex)); + return getCurrentSnippet(); + } + if (currentFileSnippetsIndex-1 >= 0) { + // The previous snippet is contained in the previous file + currentFileSnippets = currentSet.get(--currentFileSnippetsIndex); + currentSnippetIndex = currentFileSnippets.snippets.size() - 1; + setCurrentSnippet(currentFileSnippets.snippets.get(currentSnippetIndex)); + return getCurrentSnippet(); + } + } + return null; + } + + public Snippet lastSnippet() { + if (currentKey != null) { + currentFileSnippetsIndex = currentSet.size() - 1; + currentFileSnippets = currentSet.get(currentFileSnippetsIndex); + currentSnippetIndex = currentFileSnippets.snippets.size() - 1; + setCurrentSnippet(currentFileSnippets.snippets.get(currentSnippetIndex)); + return getCurrentSnippet(); + } + return null; + } + + private static FileSnippets findFileSnippetsForFile(List fileSnippetList, URL file) { + for(FileSnippets fileSnippets : fileSnippetList) { + if (fileSnippets.file == file) { + return fileSnippets; + } + } + return null; + } + + // data structure for keeping track of a particular snippet set's snippets within one file' + private static class FileSnippets { + public final String key; + public final URL file; + public final ArrayList snippets; + + public FileSnippets(String key, URL file) { + this.key = key; + this.file = file; + snippets = new ArrayList(); + } + } +} diff --git a/swingset3/com/sun/swingset3/codeview/SnippetNavigator.java b/swingset3/com/sun/swingset3/codeview/SnippetNavigator.java new file mode 100644 index 0000000..8ed52cb --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/SnippetNavigator.java @@ -0,0 +1,322 @@ +/* + * 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.codeview; + +import com.sun.swingset3.utilities.ArrowIcon; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Insets; +import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.logging.Level; +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.border.Border; +import org.jdesktop.swingx.graphics.GraphicsUtilities; + +/** + * + * @author Amy Fowler + */ +// This is more complicated thn it needs to be because it was an attempt to +// create a seamless control where the label was integrated into the buttons; +// this integration is temporarily turned off due to visual problems with focus +// and enabled state of the buttons +public class SnippetNavigator extends JPanel { + private String NO_SNIPPET; + private SnippetMap snippetMap; + private JLabel statusLabel; + private JButton prevButton; + private JButton nextButton; + private int arrowSize = 8; + private int overlap = 0; + private int labelPad = 6; + private boolean needLabelBorder = true; + + public SnippetNavigator(SnippetMap snippetMap) { + this.snippetMap = snippetMap; + snippetMap.addPropertyChangeListener(new SnippetHighlightListener()); + + setLayout(null); + + NO_SNIPPET = getString("CodeViewer.snippets.noCodeHighlighted", + "No Code highlight selected"); + + statusLabel = new JLabel(NO_SNIPPET); + statusLabel.setHorizontalAlignment(JLabel.CENTER); + add(statusLabel); + + prevButton = (JButton) add(new NavButton()); + prevButton.setDefaultCapable(false); + prevButton.setVisible(false); + + nextButton = (JButton) add(new NavButton()); + nextButton.setDefaultCapable(false); + nextButton.setVisible(false); + + applyDefaults(); + + } + + protected String getString(String key, String fallback) { + String value = fallback; + String bundleName = getClass().getPackage().getName()+".resources.CodeViewer"; + ResourceBundle bundle = ResourceBundle.getBundle(bundleName); + try { + value = bundle != null? bundle.getString(key) : fallback; + + } catch (MissingResourceException e) { + CodeViewer.logger.log(Level.WARNING, "missing String resource " + key + + "; using fallback \"" +fallback + "\""); + } + return value; + } + + @Override + public void doLayout() { + Dimension size = getSize(); + Insets insets = getInsets(); + Dimension labelSize = statusLabel.getPreferredSize(); + + if (prevButton.isVisible()) { + if (needLabelBorder) { + matchLabelBorderToButtons(); + } + Dimension buttonSize = prevButton.getPreferredSize(); + + prevButton.setBounds(insets.left, insets.top, + buttonSize.width, size.height - insets.top - insets.bottom); + + statusLabel.setBounds(insets.left + buttonSize.width - overlap, + insets.top, + labelSize.width + (2 * overlap) + labelPad, + size.height - insets.top - insets.bottom); + + nextButton.setBounds(size.width - buttonSize.width, + insets.top, + buttonSize.width, size.height - insets.top - insets.bottom); + } else { + statusLabel.setBounds(insets.left, insets.top, + size.width - insets.left - insets.right, + size.height - insets.top - insets.bottom); + } + } + + @Override + public Dimension getPreferredSize() { + Dimension prefSize; + Insets insets = getInsets(); + Dimension buttonSize = prevButton.getPreferredSize(); + Dimension labelSize = statusLabel.getPreferredSize(); + if (prevButton.isVisible()) { + prefSize = new Dimension(buttonSize.width * 2 + labelSize.width + + labelPad + + insets.left + insets.right, + buttonSize.height + insets.top + insets.bottom); + } else { + prefSize = new Dimension(labelSize.width + insets.left + insets.right, + buttonSize.height + insets.top + insets.bottom); + } + return prefSize; + } + + @Override + public void updateUI() { + super.updateUI(); + applyDefaults(); + } + + protected void applyDefaults() { + if (prevButton != null) { + Color arrowColor = UIManager.getColor("Label.foreground"); + Color inactiveColor = UIManager.getColor("Label.disabledText"); + Dimension buttonSize = new Dimension(arrowSize + 12 + overlap, + arrowSize + 12); + + prevButton.setIcon(new ArrowIcon(ArrowIcon.WEST, arrowSize, arrowColor)); + prevButton.setDisabledIcon(new ArrowIcon(ArrowIcon.WEST, arrowSize, inactiveColor)); + prevButton.setPreferredSize(buttonSize); + nextButton.setIcon(new ArrowIcon(ArrowIcon.EAST, arrowSize, arrowColor)); + nextButton.setDisabledIcon(new ArrowIcon(ArrowIcon.EAST, arrowSize, inactiveColor)); + nextButton.setPreferredSize(buttonSize); + + statusLabel.setOpaque(true); + statusLabel.setFont(UIManager.getFont("Label.font").deriveFont(12f)); + + //needLabelBorder = true; + needLabelBorder = false; + } + } + // this doesn't get called because label integration is disabled + private void matchLabelBorderToButtons() { + Insets insets = new Insets(4, 6, 4, 6); + Dimension buttonSize = prevButton.getPreferredSize(); + prevButton.setSize(buttonSize); + + BufferedImage image = GraphicsUtilities. + createCompatibleTranslucentImage( + buttonSize.width, buttonSize.height); + prevButton.paint(image.getGraphics()); + BufferedImage labelTopImage = GraphicsUtilities. + createCompatibleTranslucentImage( + buttonSize.width - insets.left - insets.right, + insets.top); + labelTopImage.getGraphics().drawImage(image, 0, 0, + buttonSize.width - insets.left - insets.right, + insets.top, + insets.left, 0, + buttonSize.width - insets.right, insets.top, + null, + null); + + BufferedImage labelBottomImage = GraphicsUtilities.createCompatibleTranslucentImage(buttonSize.width - insets.left - insets.right, + insets.bottom); + labelBottomImage.getGraphics().drawImage(image, 0, 0, + buttonSize.width - insets.left - insets.right, insets.top, + insets.left, buttonSize.height - insets.bottom, + buttonSize.width - insets.right, buttonSize.height, + null, + null); + + statusLabel.setBorder(new CenterLabelBorder(labelTopImage, labelBottomImage)); + needLabelBorder = false; + } + + public void setNavigatePreviousAction(Action action) { + setButtonAction(prevButton, action); + } + + public void setNavigateNextAction(Action action) { + setButtonAction(nextButton, action); + } + + private void setButtonAction(JButton button, Action action) { + Icon icon = button.getIcon(); + button.setAction(action); + button.setHideActionText(true); + button.setIcon(icon); // icon gets obliterated when action set! + } + + private class SnippetHighlightListener implements PropertyChangeListener { + + public void propertyChange(PropertyChangeEvent e) { + String propertyName = e.getPropertyName(); + if (propertyName.equals("currentSet")) { + String key = (String) e.getNewValue(); + setComponentState(key); + + } else if (propertyName.equals("currentSnippet")) { + setComponentState(snippetMap.getCurrentSet()); + } + } + + private void setComponentState(String currentKey) { + if (currentKey == null) { + statusLabel.setText(NO_SNIPPET); + + } else { + + String place = "" + + snippetMap.getIndexForSnippet(snippetMap.getCurrentSnippet()) + + "" + + " of " + snippetMap.getSnippetCountForSet(currentKey) + ""; + statusLabel.setText(place); + + } + boolean moreThanOne = snippetMap.getSnippetCountForSet(currentKey) > 1; + + prevButton.setVisible(moreThanOne); + nextButton.setVisible(moreThanOne); + } + } + + private class NavButton extends JButton { + public NavButton() { + super(); + } + protected void paintComponent(Graphics g) { + // need to make sure overlapping label paints after buttons otherwise + // the buttons paint over the label when they gain focus (which is really + // a Swing bug, as the clip should be properly set based on zorder + // within the container) + super.paintComponent(g); + statusLabel.repaint(); + } + } + + private class CenterLabelBorder implements Border { + private Image topImage; + private Image bottomImage; + + public CenterLabelBorder(Image topImage, Image bottomImage) { + this.topImage = topImage; + this.bottomImage = bottomImage; + } + + public Insets getBorderInsets(Component c) { + return new Insets(topImage.getHeight(null), + 0, bottomImage.getHeight(null), 0); + } + + public boolean isBorderOpaque() { + return false; + } + + public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { + if (prevButton.isVisible()) { + int xx = x; + int imageWidth = topImage.getWidth(c); + while (xx < x + w) { + g.drawImage(topImage, xx, y, c); + xx += imageWidth; + } + xx = x; + imageWidth = bottomImage.getWidth(c); + while (xx < x + w) { + g.drawImage(bottomImage, xx, y + h - bottomImage.getHeight(c), c); + xx += imageWidth; + } + } + } + } +} + \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/codeview/SnippetParser.java b/swingset3/com/sun/swingset3/codeview/SnippetParser.java new file mode 100644 index 0000000..ce0af6d --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/SnippetParser.java @@ -0,0 +1,143 @@ +/* + * 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.codeview; + +import java.text.CharacterIterator; +import java.util.*; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Segment; + +/** + * Parses a source code document, looking for blocks of code + * bracketed by comments including start and ending "snippet" markers. + * + * @author aim + */ +public class SnippetParser { + private final static String START_MARKER = ""; + private final static String END_MARKER = ""; + + protected SnippetParser() { + // never instantiate + } + + public static HashMap> parse(Document document) { + + return parse(document, START_MARKER, END_MARKER); + } + + private static HashMap> parse(Document document, + String startMarker, String endMarker) { + HashMap> snippetMap = new HashMap>(); + Stack stack = new Stack(); // snippets may be nested + char startMarkerChars[] = startMarker.toCharArray(); + char endMarkerChars[] = endMarker.toCharArray(); + int nleft = document.getLength(); + Segment segment = new Segment(); + int offset = 0; + int lineStart = 0; + int charCount = 0; + int startMarkerIndex = 0; + int endMarkerIndex = 0; + StringBuffer keyBuf = new StringBuffer(); + + segment.setPartialReturn(true); + try { + while (nleft > 0) { + + document.getText(offset, nleft, segment); + + for(char c = segment.first(); c != CharacterIterator.DONE; + c = segment.next()) { + + if (!stack.isEmpty()) { + // already found a begin marker, so looking for end marker + if (c == endMarkerChars[endMarkerIndex]) { + endMarkerIndex++; + if (endMarkerIndex == endMarkerChars.length) { + // found end marker, so register snippet + Snippet snippet = stack.pop(); + if (snippet.key.equals("tempkey")) { + // haven't stored key yet + snippet.key = keyBuf.toString().trim(); + } + snippet.endLine = charCount + 1; + List snippetList = snippetMap.get(snippet.key); + + if (snippetList == null) { + snippetList = new ArrayList(); + snippetMap.put(snippet.key, snippetList); + } + snippetList.add(snippet); + endMarkerIndex = 0; + } + } else { + endMarkerIndex = 0; + + if (stack.peek().startLine == lineStart){ + // build snippet key + keyBuf.append(c); + } + } + } + if (c == startMarkerChars[startMarkerIndex]) { + startMarkerIndex++; + if (startMarkerIndex == startMarkerChars.length) { + // found new begin marker + if (!stack.isEmpty()) { + // nested snippet, save previous key before pushing new one + Snippet snippet = stack.peek(); + snippet.key = keyBuf.toString().trim(); + } + stack.push(new Snippet(document, "tempkey", lineStart)); + keyBuf.setLength(0); + startMarkerIndex = 0; + } + + } else { + startMarkerIndex = 0; + } + charCount++; + if (c == '\n') { + lineStart = charCount; + } + } + nleft -= segment.count; + offset += segment.count; + } + } catch (BadLocationException e) { + System.err.println(e); + } + return snippetMap; + } +} diff --git a/swingset3/com/sun/swingset3/codeview/resources/CodeViewer.properties b/swingset3/com/sun/swingset3/codeview/resources/CodeViewer.properties new file mode 100644 index 0000000..dc613a6 --- /dev/null +++ b/swingset3/com/sun/swingset3/codeview/resources/CodeViewer.properties @@ -0,0 +1,16 @@ +# CodeViewer ResourceBundle properties file + +CodeViewer.images=Images +CodeViewer.noCodeLoaded=no code loaded +CodeViewer.noCodeAvailable=no code available + +CodeViewer.snippets.highlightCode=Highlight code to: +CodeViewer.snippets.selectOne=Select One +CodeViewer.snippets.navigateFirst=move to first code snippet within highlighted set +CodeViewer.snippets.navigateNext=move to next code snippet within highlighted set +CodeViewer.snippets.navigatePrevious=move to previous code fragment within highlighted set +CodeViewer.snippets.navigateLast=move to last code snippet within highlighted set + +CodeViewer.snippets.noCodeHighlighted=No highlight selected + + diff --git a/swingset3/com/sun/swingset3/codeview/resources/images/snippetglyph.png b/swingset3/com/sun/swingset3/codeview/resources/images/snippetglyph.png new file mode 100644 index 0000000..d485571 Binary files /dev/null and b/swingset3/com/sun/swingset3/codeview/resources/images/snippetglyph.png differ diff --git a/swingset3/com/sun/swingset3/codeview/resources/images/snippetglyph.psd b/swingset3/com/sun/swingset3/codeview/resources/images/snippetglyph.psd new file mode 100644 index 0000000..250ae91 Binary files /dev/null and b/swingset3/com/sun/swingset3/codeview/resources/images/snippetglyph.psd differ diff --git a/swingset3/com/sun/swingset3/demos/DemoUtilities.java b/swingset3/com/sun/swingset3/demos/DemoUtilities.java new file mode 100644 index 0000000..92bbffe --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/DemoUtilities.java @@ -0,0 +1,129 @@ +/* + * 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.demos; + +import java.awt.*; +import java.net.URI; +import java.io.IOException; +import javax.swing.*; +import javax.jnlp.*; + +/** + * @author Pavel Porvatov + */ +public class DemoUtilities { + private DemoUtilities() { + // Hide constructor + } + + public static void setToplevelLocation(Window toplevel, Component component, + int relativePosition) { + + Rectangle compBounds = component.getBounds(); + + // Convert component location to screen coordinates + Point p = new Point(); + SwingUtilities.convertPointToScreen(p, component); + + int x; + int y; + + // Set frame location to be centered on panel + switch (relativePosition) { + case SwingConstants.NORTH: { + x = (p.x + (compBounds.width / 2)) - (toplevel.getWidth() / 2); + y = p.y - toplevel.getHeight(); + break; + } + case SwingConstants.EAST: { + x = p.x + compBounds.width; + y = (p.y + (compBounds.height / 2)) - (toplevel.getHeight() / 2); + break; + } + case SwingConstants.SOUTH: { + x = (p.x + (compBounds.width / 2)) - (toplevel.getWidth() / 2); + y = p.y + compBounds.height; + break; + } + case SwingConstants.WEST: { + x = p.x - toplevel.getWidth(); + y = (p.y + (compBounds.height / 2)) - (toplevel.getHeight() / 2); + break; + } + case SwingConstants.NORTH_EAST: { + x = p.x + compBounds.width; + y = p.y - toplevel.getHeight(); + break; + } + case SwingConstants.NORTH_WEST: { + x = p.x - toplevel.getWidth(); + y = p.y - toplevel.getHeight(); + break; + } + case SwingConstants.SOUTH_EAST: { + x = p.x + compBounds.width; + y = p.y + compBounds.height; + break; + } + case SwingConstants.SOUTH_WEST: { + x = p.x - toplevel.getWidth(); + y = p.y + compBounds.height; + break; + } + default: + case SwingConstants.CENTER: { + x = (p.x + (compBounds.width / 2)) - (toplevel.getWidth() / 2); + y = (p.y + (compBounds.height / 2)) - (toplevel.getHeight() / 2); + } + } + toplevel.setLocation(x, y); + } + + public static boolean browse(URI uri) throws IOException, UnavailableServiceException { + // Try using the Desktop api first + try { + Desktop desktop = Desktop.getDesktop(); + desktop.browse(uri); + + return true; + } catch (SecurityException e) { + // Running in sandbox, try using WebStart service + BasicService basicService = + (BasicService) ServiceManager.lookup("javax.jnlp.BasicService"); + + if (basicService.isWebBrowserSupported()) { + return basicService.showDocument(uri.toURL()); + } + } + + return false; + } +} diff --git a/swingset3/com/sun/swingset3/demos/JGridPanel.java b/swingset3/com/sun/swingset3/demos/JGridPanel.java new file mode 100644 index 0000000..121d9b2 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/JGridPanel.java @@ -0,0 +1,238 @@ +/* + * 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.demos; + +import java.awt.*; +import javax.swing.*; + +/** + * JGridPanel + * + * @author Pavel Porvatov + */ +public class JGridPanel extends JPanel { + public static final int DEFAULT_GAP = 5; + + public enum Layout { + FIRST, + CENTER, + LAST, + FILL + } + + private enum ComponentType { + NO_RESIZABLE, + HORIZONTAL_FILL, + FULL + } + + private final int cols; + + private int bigCol = -1; + + private int bigRow = -1; + + private int vGap = -1; + + private int hGap = -1; + + public JGridPanel(int cols) { + this(cols, -1, -1); + } + + public JGridPanel(int cols, int bigCol) { + this(cols, bigCol, -1); + } + + public JGridPanel(int cols, int bigCol, int bigRow) { + super(new GridBagLayout()); + + assert cols > 0; + assert bigCol >= -1 && bigCol < cols; + assert bigRow >= -1; + + this.cols = cols; + this.bigCol = bigCol; + this.bigRow = bigRow; + } + + public void setVGap(int vGap) { + this.vGap = vGap; + } + + public void setHGap(int hGap) { + this.hGap = hGap; + } + + public JGridPanel cell() { + return cell(null, getHLayout(null), getVLayout(null), null); + } + + public JGridPanel cell(Component component) { + return cell(component, getHLayout(component), getVLayout(component), null); + } + + public JGridPanel cell(Component component, Layout hLayout) { + return cell(component, hLayout, getVLayout(component), null); + } + + public JGridPanel cell(Component component, Layout hLayout, Layout vLayout) { + return cell(component, hLayout, vLayout, null); + } + + public JGridPanel cell(Component component, Insets insets) { + assert insets != null; + + return cell(component, getHLayout(component), getVLayout(component), insets); + } + + private JGridPanel cell(Component component, Layout hLayout, Layout vLayout, Insets insets) { + int componentCount = getComponentCount(); + int x = componentCount % cols; + int y = componentCount / cols; + + int weightx = x == bigCol || (bigCol < 0 && hLayout == Layout.FILL) ? 1 : 0; + int weighty = y == bigRow || (bigRow < 0 && vLayout == Layout.FILL) ? 1 : 0; + + if (insets == null) { + int topGap = y == 0 ? 0 : vGap; + int leftGap = x == 0 ? 0 : hGap; + + insets = new Insets(topGap < 0 ? DEFAULT_GAP : topGap, + leftGap < 0 ? DEFAULT_GAP : leftGap, 0, 0); + } + + add(component == null ? createSeparator() : component, + new GridBagConstraints(x, y, + 1, 1, + weightx, weighty, + getAnchor(hLayout, vLayout), getFill(hLayout, vLayout), + insets, 0, 0)); + + return this; + } + + public void setComponent(Component component, int col, int row) { + assert col >= 0 && col < cols; + assert row >= 0; + + GridBagLayout layout = (GridBagLayout) getLayout(); + + for (int i = 0; i < getComponentCount(); i++) { + Component oldComponent = getComponent(i); + + GridBagConstraints constraints = layout.getConstraints(oldComponent); + + if (constraints.gridx == col && constraints.gridy == row) { + remove(i); + + add(component == null ? createSeparator() : component, constraints); + + validate(); + repaint(); + + return; + } + } + + // Cell not found + assert false; + } + + private static JComponent createSeparator() { + return new JLabel(); + } + + private static int getFill(Layout hLayout, Layout vLayout) { + if (hLayout == Layout.FILL) { + return vLayout == Layout.FILL ? GridBagConstraints.BOTH : GridBagConstraints.HORIZONTAL; + } + + return vLayout == Layout.FILL ? GridBagConstraints.VERTICAL : GridBagConstraints.NONE; + } + + private static ComponentType getComponentType(Component component) { + if (component == null || + component instanceof JLabel || + component instanceof JRadioButton || + component instanceof JCheckBox || + component instanceof JButton) { + return ComponentType.NO_RESIZABLE; + } + + if (component instanceof JComboBox || + component instanceof JTextField) { + return ComponentType.HORIZONTAL_FILL; + } + + return ComponentType.FULL; + } + + private static Layout getHLayout(Component component) { + if (getComponentType(component) == ComponentType.NO_RESIZABLE) { + return Layout.FIRST; + } else { + return Layout.FILL; + } + } + + private static Layout getVLayout(Component component) { + if (getComponentType(component) == ComponentType.FULL) { + return Layout.FILL; + } else { + return Layout.CENTER; + } + } + + private static final int[][] ANCHORS = new int[][]{ + {GridBagConstraints.NORTHWEST, GridBagConstraints.NORTH, GridBagConstraints.NORTHEAST}, + {GridBagConstraints.WEST, GridBagConstraints.CENTER, GridBagConstraints.EAST}, + {GridBagConstraints.SOUTHWEST, GridBagConstraints.SOUTH, GridBagConstraints.SOUTHEAST} + }; + + private static int getAnchorIndex(Layout layout) { + if (layout == Layout.CENTER) { + return 1; + } else if (layout == Layout.LAST) { + return 2; + } else { + return 0; + } + } + + private static int getAnchor(Layout hLayout, Layout vLayout) { + return ANCHORS[getAnchorIndex(vLayout)][getAnchorIndex(hLayout)]; + } + + public void setBorderEqual(int border) { + setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); + } +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/JHyperlink.java b/swingset3/com/sun/swingset3/demos/JHyperlink.java new file mode 100644 index 0000000..418f7a2 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/JHyperlink.java @@ -0,0 +1,244 @@ +/* + * 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.demos; + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.net.URI; +import java.net.URISyntaxException; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + + +/** + * + * @author aim + */ +//Create HTML hyperlink +//Create HTML image hyperlink +public class JHyperlink extends JButton { + private static final BrowseAction defaultBrowseAction = new BrowseAction(); + + private URI targetURI; + private boolean visited; + + private final transient Rectangle viewRect = new Rectangle(); + private final transient Rectangle iconRect = new Rectangle(); + private final transient Rectangle textRect = new Rectangle(); + + //remind(aim): lookup colors instead of hardcoding them + private Color normalForeground; + private Color activeForeground; + private Color visitedForeground; + private boolean drawUnderline = true; + + static { + UIManager.put("Hyperlink.foreground", Color.blue); + UIManager.put("Hyperlink.activeForeground", Color.red); + UIManager.put("Hyperlink.visitedForeground", new Color(85, 145, 90)); + } + + /** + * Creates a new instance of JHyperlink + */ + public JHyperlink() { + super(); + normalForeground = UIManager.getColor("Hyperlink.foreground"); + activeForeground = UIManager.getColor("Hyperlink.activeForeground"); + visitedForeground = UIManager.getColor("Hyperlink.visitedForeground"); + setBorderPainted(false); + setContentAreaFilled(false); + setForeground(normalForeground); + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + setMargin(new Insets(0,0,0,0)); + setAction(defaultBrowseAction); + } + + /** + * Creates a new instance of JHyperlink + */ + public JHyperlink(String text) { + this(); + setText(text); // override the inheritence of the action's name + } + + public JHyperlink(String text, String targetURI) throws URISyntaxException { + this(text, new URI(targetURI)); + } + + public JHyperlink(String text, URI target) { + this(text); + setTarget(target); + } + + public JHyperlink(String text, Action action) { + this(text); + setAction(action); // replaces default browse action + setText(text); // override the inheritence of the action's name + } + + public JHyperlink(String text, Icon icon) { + this(text); + setIcon(icon); + } + + public JHyperlink(Icon icon, String targetURI) throws URISyntaxException { + this(null, icon, targetURI); + } + + public JHyperlink(String text, Icon icon, String targetURI) throws URISyntaxException { + this(text, new URI(targetURI)); + setIcon(icon); + } + + public JHyperlink(String text, Icon icon, URI target) { + this(text); + setIcon(icon); + setTarget(target); + } + + public void setTarget(URI target) { + this.targetURI = target; + setToolTipText(target.toASCIIString()); + } + + public URI getTarget() { + return targetURI; + } + + public void setVisited(boolean visited) { + this.visited = visited; + } + + public boolean isVisited() { + return visited; + } + + @Override + public void setForeground(Color foreground) { + normalForeground = foreground; + super.setForeground(foreground); + } + + public void setVisitedForeground(Color visited) { + visitedForeground = visited; + } + + public void setDrawUnderline(boolean drawUnderline) { + this.drawUnderline = drawUnderline; + } + + public boolean getDrawUnderline() { + return drawUnderline; + } + + @Override + protected void paintComponent(Graphics g) { + // Set the foreground on the fly to ensure the text is painted + // with the proper color in super.paintComponent + ButtonModel model = getModel(); + if (model.isArmed()) { + super.setForeground(activeForeground); + } else if (visited) { + super.setForeground(visitedForeground); + } else { + super.setForeground(normalForeground); + } + super.paintComponent(g); + + if (drawUnderline) { + Insets insets = getInsets(); + viewRect.x = insets.left; + viewRect.y = insets.top; + viewRect.width = getWidth() - insets.left - insets.right; + viewRect.height = getHeight() - insets.top - insets.bottom; + int baseline = getBaseline(viewRect.width, viewRect.height); + + iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; + textRect.x = textRect.y = textRect.width = textRect.height = 0; + SwingUtilities.layoutCompoundLabel(g.getFontMetrics(), getText(), + getIcon(), getVerticalAlignment(), getHorizontalAlignment(), + getVerticalTextPosition(), getHorizontalTextPosition(), + viewRect, iconRect, textRect, getIconTextGap()); + + // getBaseline not returning correct results, so workaround for now + if (UIManager.getLookAndFeel().getName().equals("Nimbus")) { + baseline += 7; + } else { + baseline += 3; + } + + g.setColor(getForeground()); + g.drawLine(textRect.x, + baseline, + textRect.x + textRect.width, + baseline); + } + + } + + // This action is stateless and hence can be shared across hyperlinks + private static class BrowseAction extends AbstractAction { + public BrowseAction() { + super(); + } + public void actionPerformed(ActionEvent e) { + JHyperlink hyperlink = (JHyperlink)e.getSource(); + + URI targetURI = hyperlink.getTarget(); + if (targetURI != null) { + try { + DemoUtilities.browse(targetURI); + hyperlink.setVisited(true); + } catch (Exception ex) { + ex.printStackTrace(); + System.err.println(ex); + } + + } + } + + } +// +// + +} + diff --git a/swingset3/com/sun/swingset3/demos/ResourceManager.java b/swingset3/com/sun/swingset3/demos/ResourceManager.java new file mode 100644 index 0000000..90cc6be --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/ResourceManager.java @@ -0,0 +1,84 @@ +/* + * 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.demos; + +import java.net.URL; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.*; + +/** + * @author Pavel Porvatov + */ +public class ResourceManager { + private static final Logger logger = Logger.getLogger(ResourceManager.class.getName()); + + private final Class demoClass; + + // Resource bundle for internationalized and accessible text + private ResourceBundle bundle = null; + + public ResourceManager(Class demoClass) { + this.demoClass = demoClass; + + String bundleName = demoClass.getPackage().getName() + ".resources." + demoClass.getSimpleName(); + + try { + bundle = ResourceBundle.getBundle(bundleName); + } catch (MissingResourceException e) { + logger.log(Level.SEVERE, "Couldn't load bundle: " + bundleName); + } + } + + public String getString(String key) { + return bundle != null ? bundle.getString(key) : key; + } + + public char getMnemonic(String key) { + return (getString(key)).charAt(0); + } + + public ImageIcon createImageIcon(String filename, String description) { + String path = "resources/images/" + filename; + + URL imageURL = demoClass.getResource(path); + + if (imageURL == null) { + logger.log(Level.SEVERE, "unable to access image file: " + path); + + return null; + } else { + return new ImageIcon(imageURL, description); + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/Stacker.java b/swingset3/com/sun/swingset3/demos/Stacker.java new file mode 100644 index 0000000..67d15a9 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/Stacker.java @@ -0,0 +1,132 @@ +/* + * 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.demos; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import javax.swing.JComponent; +import javax.swing.JLayeredPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import org.jdesktop.animation.timing.Animator; +import org.jdesktop.animation.timing.interpolation.PropertySetter; +import org.jdesktop.swingx.JXPanel; + +/** + * Container class which extends JLayeredPane to ensure its sizing + * tracks its "master" child component and supported fading a message + * component in/out of the top layer + * @author Amy Fowler + */ +public class Stacker extends JLayeredPane { + private Component master; // dictates sizing, scrolling + private JPanel messageLayer; + private JXPanel messageAlpha; + + public Stacker(Component master) { + this.master = master; + setLayout(null); + add(master, JLayeredPane.DEFAULT_LAYER); + } + + @Override + public Dimension getPreferredSize() { + return master.getPreferredSize(); + } + + @Override + public void doLayout() { + // ensure all layers are sized the same + Dimension size = getSize(); + Component layers[] = getComponents(); + for (Component layer : layers) { + layer.setBounds(0, 0, size.width, size.height); + } + } + + /** + * Fades in the specified message component in the top layer of this + * layered pane. + * @param message the component to be displayed in the message layer + * @param finalAlpha the alpha value of the component when fade in is complete + */ + public void showMessageLayer(JComponent message, final float finalAlpha) { + messageLayer = new JPanel(); + messageLayer.setOpaque(false); + GridBagLayout gridbag = new GridBagLayout(); + messageLayer.setLayout(gridbag); + GridBagConstraints c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + + messageAlpha = new JXPanel(); + messageAlpha.setOpaque(false); + messageAlpha.setAlpha(0.0f); + gridbag.addLayoutComponent(messageAlpha, c); + messageLayer.add(messageAlpha); + messageAlpha.add(message); + + add(messageLayer, JLayeredPane.POPUP_LAYER); + revalidate(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + Animator animator = new Animator(2000, + new PropertySetter(messageAlpha, "alpha", 0.0f, finalAlpha)); + animator.setStartDelay(200); + animator.setAcceleration(.2f); + animator.setDeceleration(.5f); + animator.start(); + } + }); + } + + /** + * Fades out and removes the current message component + */ + public void hideMessageLayer() { + if (messageLayer != null && messageLayer.isShowing()) { + Animator animator = new Animator(500, + new PropertySetter(messageAlpha, "alpha", messageAlpha.getAlpha(), 0.0f) { + public void end() { + remove(messageLayer); + revalidate(); + } + }); + animator.setStartDelay(300); + animator.setAcceleration(.2f); + animator.setDeceleration(.5f); + animator.start(); + } + } + +} diff --git a/swingset3/com/sun/swingset3/demos/button/ButtonDemo.java b/swingset3/com/sun/swingset3/demos/button/ButtonDemo.java new file mode 100644 index 0000000..f0ee3c0 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/button/ButtonDemo.java @@ -0,0 +1,226 @@ +/* + * 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.demos.button; + + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URISyntaxException; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.JHyperlink; + +/** + * + * @author aim + */ +@DemoProperties( + value = "JButton Demo", + category = "Controls", + description = "Demonstrates the many uses of JButton, Swing's push button component.", + sourceFiles = { + "com/sun/swingset3/demos/button/ButtonDemo.java", + "com/sun/swingset3/demos/JHyperlink.java", + "com/sun/swingset3/demos/button/resources/ButtonDemo.html", + "com/sun/swingset3/demos/button/resources/images/blogs.png", + "com/sun/swingset3/demos/button/resources/images/ButtonDemo.gif", + "com/sun/swingset3/demos/button/resources/images/document-print.png", + "com/sun/swingset3/demos/button/resources/images/earth_day.gif", + "com/sun/swingset3/demos/button/resources/images/earth_night.gif", + "com/sun/swingset3/demos/button/resources/images/edit-find.png", + "com/sun/swingset3/demos/button/resources/images/redbutton.png", + "com/sun/swingset3/demos/button/resources/images/redbutton_dark.png", + "com/sun/swingset3/demos/button/resources/images/redbutton_glow.png" + } +) +public class ButtonDemo extends JPanel { + + public ButtonDemo() { + setToolTipText("Demonstrates JButton, Swing's push button component."); + initComponents(); + setOpaque(false); + } + + protected void initComponents() { + setLayout(new GridLayout(0, 1)); + + add(createSimpleButtonPanel()); + add(createCreativeButtonPanel()); + } + + protected JPanel createSimpleButtonPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 8)); + panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), + "Simple Buttons")); + + //Create simple button + final JButton simpleButton = new JButton("Do it"); + simpleButton.setToolTipText("simple button"); + // + //Add action listener using anonymous inner class + // This style is useful when the action code is tied to a + // single button instance and it's useful for simplicity + // sake to keep the action code located near the button. + // More global application actions should be implemented + // using Action classes instead. + simpleButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + simpleButton.setText("Do it again"); + // Need to force toplevel to relayout to accommodate new button size + SwingUtilities.getWindowAncestor(simpleButton).validate(); + } + }); + // + simpleButton.putClientProperty("snippetKey", "Create simple button"); + panel.add(simpleButton); + + //Create image button + // Image is from the Java Look and Feel Graphics Repository: + // http://java.sun.com/developer/techDocs/hi/repository + JButton button = new JButton(new ImageIcon(getClass(). + getResource("resources/images/document-print.png"))); + button.setToolTipText("image button"); + // + button.putClientProperty("snippetKey", "Create image button"); + panel.add(button); + + //Create button with text and image + // Image is from the Java Look and Feel Graphics Repository: + // http://java.sun.com/developer/techDocs/hi/repository + button = new JButton("Find", + new ImageIcon(getClass(). + getResource("resources/images/edit-find.png"))); + button.setToolTipText("button with text and image"); + button.setHorizontalTextPosition(JButton.LEADING); + button.setIconTextGap(6); + // + button.putClientProperty("snippetKey", "Create button with text and image"); + panel.add(button); + + //Create button with background color + button = new JButton("Go"); + button.setBackground(Color.green); + button.setContentAreaFilled(true); + button.setOpaque(false); + button.setToolTipText("button with background color"); + // + button.putClientProperty("snippetKey", "Create button with background color"); + panel.add(button); + + return panel; + } + + protected JPanel createCreativeButtonPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.CENTER, 16, 8)); + panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), + "More Interesting Buttons")); + + //Create button with no border + JButton button = new JButton(); + button.setText("Connect"); + button.setIcon(new ImageIcon(getClass().getResource("resources/images/earth_day.gif"))); + button.setPressedIcon(new ImageIcon(getClass().getResource("resources/images/earth_night.gif"))); + button.setBorderPainted(false); + button.setContentAreaFilled(false); + button.setVerticalTextPosition(JButton.BOTTOM); + button.setHorizontalTextPosition(JButton.CENTER); + button.setIconTextGap(0); + button.setToolTipText("button with no border"); + // + button.putClientProperty("snippetKey", "Create button with no border"); + panel.add(button); + + //Create image button with rollover image + button = new JButton(); + button.setBorderPainted(false); + button.setContentAreaFilled(false); + button.setIcon(new ImageIcon(getClass().getResource("resources/images/redbutton.png"))); + button.setRolloverEnabled(true); + button.setRolloverIcon(new ImageIcon(getClass().getResource("resources/images/redbutton_glow.png"))); + button.setPressedIcon(new ImageIcon(getClass().getResource("resources/images/redbutton_dark.png"))); + button.setToolTipText("button with rollover image"); + // + button.putClientProperty("snippetKey", "Create image button with rollover image"); + panel.add(button); + + //Create HTML hyperlink + JHyperlink hyperlink; + try { + hyperlink = new JHyperlink("Get More Info", "http://java.sun.com/j2se"); + } catch (URISyntaxException use) { + use.printStackTrace(); + hyperlink = new JHyperlink("Get More Info"); + } + // + hyperlink.putClientProperty("snippetKey", "Create HTML hyperlink"); + panel.add(hyperlink); + + //Create HTML image hyperlink + try { + hyperlink = new JHyperlink( + new ImageIcon(getClass().getResource("resources/images/blogs.png")), + "http://weblogs.java.net"); + } catch (URISyntaxException use) { + use.printStackTrace(); + } + // + button.putClientProperty("snippetKey", "Create HTML image hyperlink"); + panel.add(hyperlink); + + return panel; + } + + public static void main(String args[]) { + final ButtonDemo buttonDemo = new ButtonDemo(); + + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + JFrame frame = new JFrame("JButton Demo"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.add(buttonDemo); + frame.pack(); + frame.setVisible(true); + } + }); + } +} diff --git a/swingset3/com/sun/swingset3/demos/button/resources/ButtonDemo.html b/swingset3/com/sun/swingset3/demos/button/resources/ButtonDemo.html new file mode 100644 index 0000000..998e8e2 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/button/resources/ButtonDemo.html @@ -0,0 +1 @@ +

Today's modern GUIs often use buttons which don't look like the traditional "push" button. Swing's button component, javax.swing.JButton, can be used to create both ordinary and more creative button visuals. In the end, they all perform an action when clicked.

To highlight the source code used to create a particular button, popup the context menu over that button.

\ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/ButtonDemo.gif b/swingset3/com/sun/swingset3/demos/button/resources/images/ButtonDemo.gif new file mode 100644 index 0000000..9f400fe Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/ButtonDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/blogs.png b/swingset3/com/sun/swingset3/demos/button/resources/images/blogs.png new file mode 100644 index 0000000..cde6b94 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/blogs.png differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/document-print.png b/swingset3/com/sun/swingset3/demos/button/resources/images/document-print.png new file mode 100644 index 0000000..99abfb5 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/document-print.png differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/earth_day.gif b/swingset3/com/sun/swingset3/demos/button/resources/images/earth_day.gif new file mode 100644 index 0000000..01d61f7 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/earth_day.gif differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/earth_night.gif b/swingset3/com/sun/swingset3/demos/button/resources/images/earth_night.gif new file mode 100644 index 0000000..649a389 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/earth_night.gif differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/edit-find.png b/swingset3/com/sun/swingset3/demos/button/resources/images/edit-find.png new file mode 100644 index 0000000..44376a6 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/edit-find.png differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton.png b/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton.png new file mode 100644 index 0000000..b07c818 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton.png differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton_dark.png b/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton_dark.png new file mode 100644 index 0000000..64539c9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton_dark.png differ diff --git a/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton_glow.png b/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton_glow.png new file mode 100644 index 0000000..b2e9922 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/button/resources/images/redbutton_glow.png differ diff --git a/swingset3/com/sun/swingset3/demos/colorchooser/BezierAnimationPanel.java b/swingset3/com/sun/swingset3/demos/colorchooser/BezierAnimationPanel.java new file mode 100644 index 0000000..4bff060 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/colorchooser/BezierAnimationPanel.java @@ -0,0 +1,270 @@ +/* + * 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.demos.colorchooser; + +import java.awt.*; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; +import java.awt.geom.GeneralPath; +import java.awt.image.BufferedImage; +import java.util.Hashtable; +import java.util.Map; +import javax.swing.*; + +import static com.sun.swingset3.demos.colorchooser.BezierAnimationPanel.BezierColor.*; + + +/** + * BezierAnimationPanel + * + * @author Jim Graham + * @author Jeff Dinkins (removed dynamic setting changes, made swing friendly) + * @version 1.16 11/17/05 + */ +class BezierAnimationPanel extends JPanel implements Runnable { + public enum BezierColor { + BACKGROUND, + OUTER, + GRADIENT_A, + GRADIENT_B + } + + private final Map colors = new Hashtable(); + + private GradientPaint gradient = null; + + private static final int NUMPTS = 6; + + private final float[] animpts = new float[NUMPTS * 2]; + + private final float[] deltas = new float[NUMPTS * 2]; + + private BufferedImage img; + + private Thread anim; + + private final Object lock = new Object(); + + /** + * BezierAnimationPanel Constructor + */ + public BezierAnimationPanel() { + setOpaque(true); + + colors.put(BACKGROUND, new Color(0, 0, 153)); + colors.put(OUTER, new Color(255, 255, 255)); + colors.put(GRADIENT_A, new Color(255, 0, 101)); + colors.put(GRADIENT_B, new Color(255, 255, 0)); + + addHierarchyListener(new HierarchyListener() { + public void hierarchyChanged(HierarchyEvent e) { + if (isShowing()) { + start(); + } else { + stop(); + } + } + } + ); + } + + public Color getBezierColor(BezierColor bezierColor) { + return colors.get(bezierColor); + } + + public void setBezierColor(BezierColor bezierColor, Color value) { + if (value != null) { + colors.put(bezierColor, value); + } + } + + public void start() { + Dimension size = getSize(); + for (int i = 0; i < animpts.length; i += 2) { + animpts[i] = (float) (Math.random() * size.width); + animpts[i + 1] = (float) (Math.random() * size.height); + deltas[i] = (float) (Math.random() * 4.0 + 2.0); + deltas[i + 1] = (float) (Math.random() * 4.0 + 2.0); + if (animpts[i] > size.width / 6.0f) { + deltas[i] = -deltas[i]; + } + if (animpts[i + 1] > size.height / 6.0f) { + deltas[i + 1] = -deltas[i + 1]; + } + } + anim = new Thread(this); + anim.setPriority(Thread.MIN_PRIORITY); + anim.start(); + } + + public synchronized void stop() { + anim = null; + notify(); + } + + private static void animate(float[] pts, float[] deltas, int index, int limit) { + float newpt = pts[index] + deltas[index]; + if (newpt <= 0) { + newpt = -newpt; + deltas[index] = (float) (Math.random() * 3.0 + 2.0); + } else if (newpt >= (float) limit) { + newpt = 2.0f * limit - newpt; + deltas[index] = -(float) (Math.random() * 3.0 + 2.0); + } + pts[index] = newpt; + } + + public void run() { + Thread me = Thread.currentThread(); + while (getSize().width <= 0) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + return; + } + } + + Graphics2D g2d = null; + Graphics2D bufferG2D = null; + BasicStroke solid = new BasicStroke(9.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 9.0f); + GeneralPath gp = new GeneralPath(GeneralPath.WIND_NON_ZERO); + int rule = AlphaComposite.SRC_OVER; + AlphaComposite opaque = AlphaComposite.SrcOver; + AlphaComposite blend = AlphaComposite.getInstance(rule, 0.9f); + AlphaComposite set = AlphaComposite.Src; + Dimension oldSize = getSize(); + Shape clippath = null; + while (anim == me) { + Dimension size = getSize(); + if (size.width != oldSize.width || size.height != oldSize.height) { + img = null; + clippath = null; + if (bufferG2D != null) { + bufferG2D.dispose(); + bufferG2D = null; + } + } + oldSize = size; + + if (img == null) { + img = (BufferedImage) createImage(size.width, size.height); + } + + if (bufferG2D == null) { + bufferG2D = img.createGraphics(); + bufferG2D.setRenderingHint(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_DEFAULT); + bufferG2D.setClip(clippath); + } + g2d = bufferG2D; + + float[] ctrlpts; + for (int i = 0; i < animpts.length; i += 2) { + animate(animpts, deltas, i, size.width); + animate(animpts, deltas, i + 1, size.height); + } + ctrlpts = animpts; + int len = ctrlpts.length; + gp.reset(); + float prevx = ctrlpts[len - 2]; + float prevy = ctrlpts[len - 1]; + float curx = ctrlpts[0]; + float cury = ctrlpts[1]; + float midx = (curx + prevx) / 2.0f; + float midy = (cury + prevy) / 2.0f; + gp.moveTo(midx, midy); + for (int i = 2; i <= ctrlpts.length; i += 2) { + float x1 = (midx + curx) / 2.0f; + float y1 = (midy + cury) / 2.0f; + prevx = curx; + prevy = cury; + if (i < ctrlpts.length) { + curx = ctrlpts[i]; + cury = ctrlpts[i + 1]; + } else { + curx = ctrlpts[0]; + cury = ctrlpts[1]; + } + midx = (curx + prevx) / 2.0f; + midy = (cury + prevy) / 2.0f; + float x2 = (prevx + midx) / 2.0f; + float y2 = (prevy + midy) / 2.0f; + gp.curveTo(x1, y1, x2, y2, midx, midy); + } + gp.closePath(); + + synchronized (lock) { + g2d.setComposite(set); + g2d.setBackground(getBezierColor(BACKGROUND)); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + + // g2d.clearRect(bounds.x-5, bounds.y-5, bounds.x + bounds.width + 5, bounds.y + bounds.height + 5); + g2d.clearRect(0, 0, getWidth(), getHeight()); + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setColor(getBezierColor(OUTER)); + g2d.setComposite(opaque); + g2d.setStroke(solid); + g2d.draw(gp); + g2d.setPaint(gradient); + + Rectangle bounds = gp.getBounds(); + + gradient = new GradientPaint(bounds.x, bounds.y, getBezierColor(GRADIENT_A), + bounds.x + bounds.width, bounds.y + bounds.height, + getBezierColor(GRADIENT_B), true); + + g2d.setComposite(blend); + g2d.fill(gp); + } + + repaint(); + + Thread.yield(); + } + if (g2d != null) { + g2d.dispose(); + } + } + + public void paint(Graphics g) { + synchronized (lock) { + Graphics2D g2d = (Graphics2D) g; + if (img != null) { + g2d.setComposite(AlphaComposite.Src); + g2d.drawImage(img, null, 0, 0); + } + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/colorchooser/ColorChooserDemo.java b/swingset3/com/sun/swingset3/demos/colorchooser/ColorChooserDemo.java new file mode 100644 index 0000000..7ded85d --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/colorchooser/ColorChooserDemo.java @@ -0,0 +1,186 @@ +/* + * 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.demos.colorchooser; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import javax.swing.border.EmptyBorder; + +import com.sun.swingset3.demos.JGridPanel; +import com.sun.swingset3.demos.ResourceManager; +import com.sun.swingset3.DemoProperties; + + +/** + * JColorChooserDemo + * + * @author Jeff Dinkins + * @version 1.1 07/16/99 + */ +@DemoProperties( + value = "JColorChooser Demo", + category = "Choosers", + description = "Demonstrates JColorChooser, a component which allows the user to pick a color.", + sourceFiles = { + "com/sun/swingset3/demos/colorchooser/ColorChooserDemo.java", + "com/sun/swingset3/demos/colorchooser/BezierAnimationPanel.java", + "com/sun/swingset3/demos/JGridPanel.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/colorchooser/resources/ColorChooserDemo.properties", + "com/sun/swingset3/demos/colorchooser/resources/images/ColorChooserDemo.gif" + } +) +public class ColorChooserDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final BezierAnimationPanel bezAnim = new BezierAnimationPanel(); + + private final JButton outerColorButton = new JButton(resourceManager.getString("ColorChooserDemo.outer_line")); + + private final JButton backgroundColorButton = new JButton(resourceManager.getString("ColorChooserDemo.background")); + + private final JButton gradientAButton = new JButton(resourceManager.getString("ColorChooserDemo.grad_a")); + + private final JButton gradientBButton = new JButton(resourceManager.getString("ColorChooserDemo.grad_b")); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ColorChooserDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ColorChooserDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + + /** + * ColorChooserDemo Constructor + */ + public ColorChooserDemo() { + setLayout(new BorderLayout()); + + outerColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.OUTER)); + + backgroundColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.BACKGROUND)); + + gradientAButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_A)); + + gradientBButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_B)); + + ActionListener l = new ActionListener() { + public void actionPerformed(ActionEvent e) { + JButton button = (JButton) e.getSource(); + + final BezierAnimationPanel.BezierColor bezierColor = + ((ColorSwatch) button.getIcon()).getBezierColor(); + + Color current = bezAnim.getBezierColor(bezierColor); + + final JColorChooser chooser = new JColorChooser(current != null ? + current : + Color.WHITE); + + ActionListener colorChooserListener = new ActionListener() { + public void actionPerformed(ActionEvent ae) { + bezAnim.setBezierColor(bezierColor, chooser.getColor()); + } + }; + + JDialog dialog = JColorChooser.createDialog(ColorChooserDemo.this, + resourceManager.getString("ColorChooserDemo.chooser_title"), + true, + chooser, + colorChooserListener, + null); + + dialog.setVisible(true); + } + }; + + outerColorButton.addActionListener(l); + backgroundColorButton.addActionListener(l); + gradientAButton.addActionListener(l); + gradientBButton.addActionListener(l); + + // Add control buttons + JPanel buttonPanel = new JPanel(new GridLayout(1, 4, 15, 0)); + + buttonPanel.add(backgroundColorButton); + buttonPanel.add(gradientAButton); + buttonPanel.add(gradientBButton); + buttonPanel.add(outerColorButton); + + // Add everything to the panel + JGridPanel pnContent = new JGridPanel(1, 0, 1); + + pnContent.cell(buttonPanel, JGridPanel.Layout.CENTER). + cell(bezAnim); + + pnContent.setBorder(new EmptyBorder(10, 0, 0, 0)); + + add(pnContent); + } + + private class ColorSwatch implements Icon { + private final BezierAnimationPanel.BezierColor bezierColor; + + public ColorSwatch(BezierAnimationPanel.BezierColor bezierColor) { + this.bezierColor = bezierColor; + } + + public int getIconWidth() { + return 11; + } + + public int getIconHeight() { + return 11; + } + + public BezierAnimationPanel.BezierColor getBezierColor() { + return bezierColor; + } + + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(Color.black); + g.fillRect(x, y, getIconWidth(), getIconHeight()); + g.setColor(bezAnim.getBezierColor(bezierColor)); + g.fillRect(x + 2, y + 2, getIconWidth() - 4, getIconHeight() - 4); + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/colorchooser/resources/ColorChooserDemo.properties b/swingset3/com/sun/swingset3/demos/colorchooser/resources/ColorChooserDemo.properties new file mode 100644 index 0000000..3993479 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/colorchooser/resources/ColorChooserDemo.properties @@ -0,0 +1,11 @@ +### ColorChooser Demo ### + +ColorChooserDemo.accessible_description=The ColorChooser allows a user to pick a color either from a pallete or by choosing RGB or HSB values +ColorChooserDemo.tooltip=JColorChooser demo +ColorChooserDemo.name=ColorChooser Demo +ColorChooserDemo.chooser_title=Choose a Color +ColorChooserDemo.background=Background +ColorChooserDemo.grad_a=Gradient 1 +ColorChooserDemo.grad_b=Gradient 2 +ColorChooserDemo.outer_line=Perimeter +ColorChooserDemo.cup=Image of the Java Trademark Coffee Cup diff --git a/swingset3/com/sun/swingset3/demos/colorchooser/resources/images/ColorChooserDemo.gif b/swingset3/com/sun/swingset3/demos/colorchooser/resources/images/ColorChooserDemo.gif new file mode 100644 index 0000000..64a0530 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/colorchooser/resources/images/ColorChooserDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/ComboBoxDemo.java b/swingset3/com/sun/swingset3/demos/combobox/ComboBoxDemo.java new file mode 100644 index 0000000..cbe9d26 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/combobox/ComboBoxDemo.java @@ -0,0 +1,445 @@ +/* + * 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.demos.combobox; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.Map; +import javax.accessibility.AccessibleRelation; +import javax.swing.*; +import javax.swing.border.BevelBorder; + +import com.sun.swingset3.demos.ResourceManager; +import com.sun.swingset3.DemoProperties; + +/** + * JComboBox Demo + * + * @author Jeff Dinkins + * @version 1.13 11/17/05 + */ +@DemoProperties( + value = "JComboBox Demo", + category = "Controls", + description = "Demonstrates JComboBox, a control which allows the user to make a selection from a popup list", + sourceFiles = { + "com/sun/swingset3/demos/combobox/ComboBoxDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/combobox/resources/ComboBoxDemo.properties", + "com/sun/swingset3/demos/combobox/resources/images/brenteyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/brenthair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/brentmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/ComboBoxDemo.gif", + "com/sun/swingset3/demos/combobox/resources/images/georgeseyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/georgeshair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/georgesmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/hanseyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/hanshair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/hansmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/howardeyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/howardhair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/howardmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jameseyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jameshair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jamesmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jeffeyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jeffhair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jeffmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/joneyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jonhair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/jonmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/laraeyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/larahair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/laramouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/larryeyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/larryhair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/larrymouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/lisaeyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/lisahair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/lisamouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/michaeleyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/michaelhair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/michaelmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/philipeyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/philiphair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/philipmouth.jpg", + "com/sun/swingset3/demos/combobox/resources/images/scotteyes.jpg", + "com/sun/swingset3/demos/combobox/resources/images/scotthair.jpg", + "com/sun/swingset3/demos/combobox/resources/images/scottmouth.jpg" + } +) +public class ComboBoxDemo extends JPanel implements ActionListener { + private static final Dimension VGAP15 = new Dimension(1, 15); + private static final Dimension HGAP20 = new Dimension(20, 1); + private static final Dimension VGAP20 = new Dimension(1, 20); + private static final Dimension HGAP30 = new Dimension(30, 1); + private static final Dimension VGAP30 = new Dimension(1, 30); + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private Face face; + private JLabel faceLabel; + + private JComboBox hairCB; + private JComboBox eyesCB; + private JComboBox mouthCB; + + private JComboBox presetCB; + + private final Map parts = new HashMap(); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ComboBoxDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ComboBoxDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * ComboBoxDemo Constructor + */ + public ComboBoxDemo() { + createComboBoxDemo(); + } + + private void createComboBoxDemo() { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + JPanel innerPanel = new JPanel(); + innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS)); + + add(Box.createRigidArea(VGAP20)); + add(innerPanel); + add(Box.createRigidArea(VGAP20)); + + innerPanel.add(Box.createRigidArea(HGAP20)); + + // Create a panel to hold buttons + JPanel comboBoxPanel = new JPanel() { + public Dimension getMaximumSize() { + return new Dimension(getPreferredSize().width, super.getMaximumSize().height); + } + }; + comboBoxPanel.setLayout(new BoxLayout(comboBoxPanel, BoxLayout.Y_AXIS)); + + comboBoxPanel.add(Box.createRigidArea(VGAP15)); + + JLabel l = (JLabel) comboBoxPanel.add(new JLabel(resourceManager.getString("ComboBoxDemo.presets"))); + l.setAlignmentX(JLabel.LEFT_ALIGNMENT); + presetCB = (JComboBox) comboBoxPanel.add(createPresetComboBox()); + presetCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); + l.setLabelFor(presetCB); + comboBoxPanel.add(Box.createRigidArea(VGAP30)); + + l = (JLabel) comboBoxPanel.add(new JLabel(resourceManager.getString("ComboBoxDemo.hair_description"))); + l.setAlignmentX(JLabel.LEFT_ALIGNMENT); + hairCB = (JComboBox) comboBoxPanel.add(createHairComboBox()); + hairCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); + l.setLabelFor(hairCB); + comboBoxPanel.add(Box.createRigidArea(VGAP15)); + + l = (JLabel) comboBoxPanel.add(new JLabel(resourceManager.getString("ComboBoxDemo.eyes_description"))); + l.setAlignmentX(JLabel.LEFT_ALIGNMENT); + eyesCB = (JComboBox) comboBoxPanel.add(createEyesComboBox()); + eyesCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); + l.setLabelFor(eyesCB); + comboBoxPanel.add(Box.createRigidArea(VGAP15)); + + l = (JLabel) comboBoxPanel.add(new JLabel(resourceManager.getString("ComboBoxDemo.mouth_description"))); + l.setAlignmentX(JLabel.LEFT_ALIGNMENT); + mouthCB = (JComboBox) comboBoxPanel.add(createMouthComboBox()); + mouthCB.setAlignmentX(JComboBox.LEFT_ALIGNMENT); + l.setLabelFor(mouthCB); + comboBoxPanel.add(Box.createRigidArea(VGAP15)); + + // Fill up the remaining space + comboBoxPanel.add(new JPanel(new BorderLayout())); + + // Create and place the Face. + + face = new Face(); + JPanel facePanel = new JPanel(); + facePanel.setLayout(new BorderLayout()); + facePanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); + + faceLabel = new JLabel(face); + facePanel.add(faceLabel, BorderLayout.CENTER); + // Indicate that the face panel is controlled by the hair, eyes and + // mouth combo boxes. + Object[] controlledByObjects = new Object[3]; + controlledByObjects[0] = hairCB; + controlledByObjects[1] = eyesCB; + controlledByObjects[2] = mouthCB; + AccessibleRelation controlledByRelation = + new AccessibleRelation(AccessibleRelation.CONTROLLED_BY_PROPERTY, + controlledByObjects); + facePanel.getAccessibleContext().getAccessibleRelationSet().add(controlledByRelation); + + // Indicate that the hair, eyes and mouth combo boxes are controllers + // for the face panel. + AccessibleRelation controllerForRelation = + new AccessibleRelation(AccessibleRelation.CONTROLLER_FOR_PROPERTY, + facePanel); + hairCB.getAccessibleContext().getAccessibleRelationSet().add(controllerForRelation); + eyesCB.getAccessibleContext().getAccessibleRelationSet().add(controllerForRelation); + mouthCB.getAccessibleContext().getAccessibleRelationSet().add(controllerForRelation); + + // add buttons and image panels to inner panel + innerPanel.add(comboBoxPanel); + innerPanel.add(Box.createRigidArea(HGAP30)); + innerPanel.add(facePanel); + innerPanel.add(Box.createRigidArea(HGAP20)); + + // load up the face parts + addFace("brent", resourceManager.getString("ComboBoxDemo.brent")); + addFace("georges", resourceManager.getString("ComboBoxDemo.georges")); + addFace("hans", resourceManager.getString("ComboBoxDemo.hans")); + addFace("howard", resourceManager.getString("ComboBoxDemo.howard")); + addFace("james", resourceManager.getString("ComboBoxDemo.james")); + addFace("jeff", resourceManager.getString("ComboBoxDemo.jeff")); + addFace("jon", resourceManager.getString("ComboBoxDemo.jon")); + addFace("lara", resourceManager.getString("ComboBoxDemo.lara")); + addFace("larry", resourceManager.getString("ComboBoxDemo.larry")); + addFace("lisa", resourceManager.getString("ComboBoxDemo.lisa")); + addFace("michael", resourceManager.getString("ComboBoxDemo.michael")); + addFace("philip", resourceManager.getString("ComboBoxDemo.philip")); + addFace("scott", resourceManager.getString("ComboBoxDemo.scott")); + + // set the default face + presetCB.setSelectedIndex(0); + } + + private void addFace(String name, String i18n_name) { + ImageIcon i; + String i18n_hair = resourceManager.getString("ComboBoxDemo.hair"); + String i18n_eyes = resourceManager.getString("ComboBoxDemo.eyes"); + String i18n_mouth = resourceManager.getString("ComboBoxDemo.mouth"); + + parts.put(i18n_name, name); // i18n name lookup + parts.put(name, i18n_name); // reverse name lookup + + i = resourceManager.createImageIcon(name + "hair.jpg", i18n_name + i18n_hair); + parts.put(name + "hair", i); + + i = resourceManager.createImageIcon(name + "eyes.jpg", i18n_name + i18n_eyes); + parts.put(name + "eyes", i); + + i = resourceManager.createImageIcon(name + "mouth.jpg", i18n_name + i18n_mouth); + parts.put(name + "mouth", i); + } + + private JComboBox createHairComboBox() { + JComboBox cb = new JComboBox(); + fillComboBox(cb); + cb.addActionListener(this); + return cb; + } + + private JComboBox createEyesComboBox() { + JComboBox cb = new JComboBox(); + fillComboBox(cb); + cb.addActionListener(this); + return cb; + } + + private JComboBox createMouthComboBox() { + JComboBox cb = new JComboBox(); + fillComboBox(cb); + cb.addActionListener(this); + return cb; + } + + private JComboBox createPresetComboBox() { + JComboBox cb = new JComboBox(); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset1")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset2")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset3")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset4")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset5")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset6")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset7")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset8")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset9")); + cb.addItem(resourceManager.getString("ComboBoxDemo.preset10")); + cb.addActionListener(this); + return cb; + } + + private void fillComboBox(JComboBox cb) { + cb.addItem(resourceManager.getString("ComboBoxDemo.brent")); + cb.addItem(resourceManager.getString("ComboBoxDemo.georges")); + cb.addItem(resourceManager.getString("ComboBoxDemo.hans")); + cb.addItem(resourceManager.getString("ComboBoxDemo.howard")); + cb.addItem(resourceManager.getString("ComboBoxDemo.james")); + cb.addItem(resourceManager.getString("ComboBoxDemo.jeff")); + cb.addItem(resourceManager.getString("ComboBoxDemo.jon")); + cb.addItem(resourceManager.getString("ComboBoxDemo.lara")); + cb.addItem(resourceManager.getString("ComboBoxDemo.larry")); + cb.addItem(resourceManager.getString("ComboBoxDemo.lisa")); + cb.addItem(resourceManager.getString("ComboBoxDemo.michael")); + cb.addItem(resourceManager.getString("ComboBoxDemo.philip")); + cb.addItem(resourceManager.getString("ComboBoxDemo.scott")); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == hairCB) { + String name = (String) parts.get((String) hairCB.getSelectedItem()); + face.setHair((ImageIcon) parts.get(name + "hair")); + faceLabel.repaint(); + } else if (e.getSource() == eyesCB) { + String name = (String) parts.get((String) eyesCB.getSelectedItem()); + face.setEyes((ImageIcon) parts.get(name + "eyes")); + faceLabel.repaint(); + } else if (e.getSource() == mouthCB) { + String name = (String) parts.get((String) mouthCB.getSelectedItem()); + face.setMouth((ImageIcon) parts.get(name + "mouth")); + faceLabel.repaint(); + } else if (e.getSource() == presetCB) { + String hair = null; + String eyes = null; + String mouth = null; + switch (presetCB.getSelectedIndex()) { + case 0: + hair = (String) parts.get("philip"); + eyes = (String) parts.get("howard"); + mouth = (String) parts.get("jeff"); + break; + case 1: + hair = (String) parts.get("jeff"); + eyes = (String) parts.get("larry"); + mouth = (String) parts.get("philip"); + break; + case 2: + hair = (String) parts.get("howard"); + eyes = (String) parts.get("scott"); + mouth = (String) parts.get("hans"); + break; + case 3: + hair = (String) parts.get("philip"); + eyes = (String) parts.get("jeff"); + mouth = (String) parts.get("hans"); + break; + case 4: + hair = (String) parts.get("brent"); + eyes = (String) parts.get("jon"); + mouth = (String) parts.get("scott"); + break; + case 5: + hair = (String) parts.get("lara"); + eyes = (String) parts.get("larry"); + mouth = (String) parts.get("lisa"); + break; + case 6: + hair = (String) parts.get("james"); + eyes = (String) parts.get("philip"); + mouth = (String) parts.get("michael"); + break; + case 7: + hair = (String) parts.get("philip"); + eyes = (String) parts.get("lisa"); + mouth = (String) parts.get("brent"); + break; + case 8: + hair = (String) parts.get("james"); + eyes = (String) parts.get("philip"); + mouth = (String) parts.get("jon"); + break; + case 9: + hair = (String) parts.get("lara"); + eyes = (String) parts.get("jon"); + mouth = (String) parts.get("scott"); + break; + } + if (hair != null) { + hairCB.setSelectedItem(hair); + eyesCB.setSelectedItem(eyes); + mouthCB.setSelectedItem(mouth); + faceLabel.repaint(); + } + } + } + + private static class Face implements Icon { + private ImageIcon hair; + private ImageIcon eyes; + private ImageIcon mouth; + + void setHair(ImageIcon i) { + hair = i; + } + + void setEyes(ImageIcon i) { + eyes = i; + } + + void setMouth(ImageIcon i) { + mouth = i; + } + + public void paintIcon(Component c, Graphics g, int x, int y) { + int height = y; + x = c.getWidth() / 2 - getIconWidth() / 2; + + if (hair != null) { + hair.paintIcon(c, g, x, height); + height += hair.getIconHeight(); + } + + if (eyes != null) { + eyes.paintIcon(c, g, x, height); + height += eyes.getIconHeight(); + } + + if (mouth != null) { + mouth.paintIcon(c, g, x, height); + } + } + + public int getIconWidth() { + return 344; + } + + public int getIconHeight() { + return 455; + } + } +} + diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/ComboBoxDemo.properties b/swingset3/com/sun/swingset3/demos/combobox/resources/ComboBoxDemo.properties new file mode 100644 index 0000000..51ee144 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/combobox/resources/ComboBoxDemo.properties @@ -0,0 +1,42 @@ +### ComboBox Demo ### + +ComboBoxDemo.accessible_description=This demo shows an example of using the JComboBox component. +ComboBoxDemo.tooltip=JComboBox demo +ComboBoxDemo.name=ComboBox Demo + +ComboBoxDemo.hair=hair +ComboBoxDemo.eyes=eyes +ComboBoxDemo.mouth=mouth +ComboBoxDemo.presets=Presets: + +ComboBoxDemo.preset1=Philip, Howard, Jeff +ComboBoxDemo.preset2=Jeff, Larry, Philip +ComboBoxDemo.preset3=Howard, Scott, Hans +ComboBoxDemo.preset4=Philip, Jeff, Hans +ComboBoxDemo.preset5=Brent, Jon, Scott +ComboBoxDemo.preset6=Lara, Larry, Lisa +ComboBoxDemo.preset7=James, Philip, Michael +ComboBoxDemo.preset8=Philip, Lisa, Brent +ComboBoxDemo.preset9=James, Philip, Jon +ComboBoxDemo.preset10=Lara, Jon, Scott + + +ComboBoxDemo.hair_description=Hair: +ComboBoxDemo.eyes_description=Eyes & Nose: +ComboBoxDemo.mouth_description=Mouth: + +ComboBoxDemo.amy=Amy +ComboBoxDemo.brent=Brent +ComboBoxDemo.georges=Georges +ComboBoxDemo.hans=Hans +ComboBoxDemo.howard=Howard +ComboBoxDemo.james=James +ComboBoxDemo.jeff=Jeff +ComboBoxDemo.jon=Jon +ComboBoxDemo.lara=Lara +ComboBoxDemo.larry=Larry +ComboBoxDemo.lisa=Lisa +ComboBoxDemo.michael=Michael +ComboBoxDemo.philip=Philip +ComboBoxDemo.scott=Scott + diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/ComboBoxDemo.gif b/swingset3/com/sun/swingset3/demos/combobox/resources/images/ComboBoxDemo.gif new file mode 100644 index 0000000..f8e971f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/ComboBoxDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/brenteyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/brenteyes.jpg new file mode 100644 index 0000000..6f7d0f4 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/brenteyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/brenthair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/brenthair.jpg new file mode 100644 index 0000000..cfde575 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/brenthair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/brentmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/brentmouth.jpg new file mode 100644 index 0000000..6b3c525 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/brentmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgeseyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgeseyes.jpg new file mode 100644 index 0000000..224cef6 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgeseyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgeshair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgeshair.jpg new file mode 100644 index 0000000..7071dde Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgeshair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgesmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgesmouth.jpg new file mode 100644 index 0000000..b917e51 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/georgesmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/hanseyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/hanseyes.jpg new file mode 100644 index 0000000..e7001ad Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/hanseyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/hanshair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/hanshair.jpg new file mode 100644 index 0000000..bf46bb6 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/hanshair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/hansmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/hansmouth.jpg new file mode 100644 index 0000000..09eb9e0 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/hansmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardeyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardeyes.jpg new file mode 100644 index 0000000..b5f1ba5 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardeyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardhair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardhair.jpg new file mode 100644 index 0000000..b0cdb19 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardhair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardmouth.jpg new file mode 100644 index 0000000..ebc85f0 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/howardmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jameseyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jameseyes.jpg new file mode 100644 index 0000000..a53f922 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jameseyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jameshair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jameshair.jpg new file mode 100644 index 0000000..52d2ca5 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jameshair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jamesmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jamesmouth.jpg new file mode 100644 index 0000000..7b0e35c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jamesmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffeyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffeyes.jpg new file mode 100644 index 0000000..0608e07 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffeyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffhair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffhair.jpg new file mode 100644 index 0000000..b67834a Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffhair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffmouth.jpg new file mode 100644 index 0000000..8a31349 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jeffmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/joneyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/joneyes.jpg new file mode 100644 index 0000000..f744084 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/joneyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jonhair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jonhair.jpg new file mode 100644 index 0000000..59a1824 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jonhair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/jonmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jonmouth.jpg new file mode 100644 index 0000000..9f39f0b Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/jonmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/laraeyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/laraeyes.jpg new file mode 100644 index 0000000..24c8778 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/laraeyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/larahair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larahair.jpg new file mode 100644 index 0000000..8c23d01 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larahair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/laramouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/laramouth.jpg new file mode 100644 index 0000000..b00407c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/laramouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/larryeyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larryeyes.jpg new file mode 100644 index 0000000..a2b771e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larryeyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/larryhair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larryhair.jpg new file mode 100644 index 0000000..5366c15 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larryhair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/larrymouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larrymouth.jpg new file mode 100644 index 0000000..d0642d2 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/larrymouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisaeyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisaeyes.jpg new file mode 100644 index 0000000..4a9cc86 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisaeyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisahair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisahair.jpg new file mode 100644 index 0000000..3eb7d4f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisahair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisamouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisamouth.jpg new file mode 100644 index 0000000..ac56502 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/lisamouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaeleyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaeleyes.jpg new file mode 100644 index 0000000..ae8487f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaeleyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaelhair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaelhair.jpg new file mode 100644 index 0000000..271d20c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaelhair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaelmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaelmouth.jpg new file mode 100644 index 0000000..02119ed Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/michaelmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/philipeyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/philipeyes.jpg new file mode 100644 index 0000000..1d30807 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/philipeyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/philiphair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/philiphair.jpg new file mode 100644 index 0000000..18988df Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/philiphair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/philipmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/philipmouth.jpg new file mode 100644 index 0000000..dcf4b96 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/philipmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/scotteyes.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/scotteyes.jpg new file mode 100644 index 0000000..fa7ead7 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/scotteyes.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/scotthair.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/scotthair.jpg new file mode 100644 index 0000000..ef237cb Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/scotthair.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/combobox/resources/images/scottmouth.jpg b/swingset3/com/sun/swingset3/demos/combobox/resources/images/scottmouth.jpg new file mode 100644 index 0000000..9eea453 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/combobox/resources/images/scottmouth.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/dialog/DialogDemo.java b/swingset3/com/sun/swingset3/demos/dialog/DialogDemo.java new file mode 100644 index 0000000..40cbc7a --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/dialog/DialogDemo.java @@ -0,0 +1,164 @@ +/* + * 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.demos.dialog; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.DemoUtilities; + +/** + * + * @author aim + */ +@DemoProperties( + value = "JDialog Demo", + category = "Toplevel Containers", + description = "Demonstrates JDialog, Swing's top-level dialog container.", + sourceFiles = { + "com/sun/swingset3/demos/dialog/DialogDemo.java", + "com/sun/swingset3/demos/DemoUtilities.java", + "com/sun/swingset3/demos/dialog/resources/DialogDemo.html", + "com/sun/swingset3/demos/dialog/resources/images/DialogDemo.gif" + } +) +public class DialogDemo extends JPanel { + + private JDialog dialog; + + private JComponent dialogSpaceholder; + + public DialogDemo() { + initComponents(); + } + + protected void initComponents() { + dialog = createDialog(); + + setLayout(new BorderLayout()); + + add(createControlPanel(), BorderLayout.WEST); + dialogSpaceholder = createDialogSpaceholder(dialog); + add(dialogSpaceholder, BorderLayout.CENTER); + } + + private static JComponent createDialogSpaceholder(JDialog dialog) { + // Create placeholder panel to provide space in which to + // display the toplevel dialog so that the control panel is not + // obscured by it. + JPanel placeholder = new JPanel(); + Dimension prefSize = dialog.getPreferredSize(); + prefSize.width += 12; + prefSize.height += 12; + placeholder.setPreferredSize(prefSize); + return placeholder; + } + + protected JComponent createControlPanel() { + // Create control panel on Left + Box panel = Box.createVerticalBox(); + panel.setBorder(new EmptyBorder(8, 8, 8, 8)); + + // Create button to control visibility of frame + JButton showButton = new JButton("Show JDialog..."); + showButton.addActionListener(new ShowActionListener()); + panel.add(showButton); + + return panel; + } + + private static JDialog createDialog() { + + //Create dialog + JDialog dialog = new JDialog(new JFrame(), "Demo JDialog", false); + // + + //Add dialog's content + JLabel label = new JLabel("I'm content."); + label.setHorizontalAlignment(JLabel.CENTER); + label.setPreferredSize(new Dimension(200,140)); + dialog.add(label); + // + + //Initialize dialog's size + // which will shrink-to-fit its contents + dialog.pack(); + // + + return dialog; + } + + public void start() { + DemoUtilities.setToplevelLocation(dialog, dialogSpaceholder, SwingConstants.CENTER); + showDialog(); + } + + public void stop() { + //Hide dialog + dialog.setVisible(false); + // + } + + public void showDialog() { + //Show dialog + // if dialog already visible, then bring to the front + if (dialog.isShowing()) { + dialog.toFront(); + } else { + dialog.setVisible(true); + } + // + } + + private class ShowActionListener implements ActionListener { + public void actionPerformed(ActionEvent actionEvent) { + showDialog(); + } + } + + public static void main(String args[]) { + EventQueue.invokeLater(new Runnable() { + public void run() { + JFrame frame = new JFrame(); + DialogDemo demo = new DialogDemo(); + frame.add(demo); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + demo.start(); + } + }); + } +} diff --git a/swingset3/com/sun/swingset3/demos/dialog/resources/DialogDemo.html b/swingset3/com/sun/swingset3/demos/dialog/resources/DialogDemo.html new file mode 100644 index 0000000..75d28c9 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/dialog/resources/DialogDemo.html @@ -0,0 +1 @@ +

Show how Swing's top-level GUI container, JDialog, can be used to build secondary windows, such as property sheets and wizards.

Dialogs can be either modal or modeless. Modal dialogs block input from other windows in the application, thereby forcing the user to acknowledge the dialog before interacting with other parts of the application. Modeless dialogs do not block input.

For more information on using JDialogs, see The Java Tutorial: JDialog trail.

\ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/dialog/resources/images/DialogDemo.gif b/swingset3/com/sun/swingset3/demos/dialog/resources/images/DialogDemo.gif new file mode 100644 index 0000000..b4614ee Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/dialog/resources/images/DialogDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/EditorPaneDemo.java b/swingset3/com/sun/swingset3/demos/editorpane/EditorPaneDemo.java new file mode 100644 index 0000000..0078340 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/EditorPaneDemo.java @@ -0,0 +1,153 @@ +/* + * 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.demos.editorpane; + +import java.awt.*; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import javax.swing.*; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLFrameHyperlinkEvent; + +import com.sun.swingset3.DemoProperties; + +/** + * EditorPane Demo (was HTMLDemo in SwingSet2) + * + * @version 1.12 05/11/17 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JEditorPane Demo", + category = "Text", + description = "Demonstrates JEditorPane, a text component which supports display and editing of rich text formats (such as HTML)", + sourceFiles = { + "com/sun/swingset3/demos/editorpane/EditorPaneDemo.java", + "com/sun/swingset3/demos/editorpane/book/ant.html", + "com/sun/swingset3/demos/editorpane/book/bug.html", + "com/sun/swingset3/demos/editorpane/book/index.html", + "com/sun/swingset3/demos/editorpane/book/king.html", + "com/sun/swingset3/demos/editorpane/book/preface.html", + "com/sun/swingset3/demos/editorpane/book/seaweed.html", + "com/sun/swingset3/demos/editorpane/book/title.html", + "com/sun/swingset3/demos/editorpane/book/editorpane/back.jpg", + "com/sun/swingset3/demos/editorpane/book/editorpane/forward.jpg", + "com/sun/swingset3/demos/editorpane/book/editorpane/header.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/ant.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/book.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/bug.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/bug2.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/COPYRIGHT", + "com/sun/swingset3/demos/editorpane/book/Octavo/crest.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/king.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/micro.jpg", + "com/sun/swingset3/demos/editorpane/book/Octavo/seaweed.jpg", + "com/sun/swingset3/demos/editorpane/resources/EditorPaneDemo.properties", + "com/sun/swingset3/demos/editorpane/resources/images/EditorPaneDemo.gif" + } +) +public class EditorPaneDemo extends JPanel { + + private JEditorPane html; + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(EditorPaneDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new EditorPaneDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * EditorPaneDemo Constructor + */ + public EditorPaneDemo() { + setLayout(new BorderLayout()); + + try { + URL url; + // System.getProperty("user.dir") + + // System.getProperty("file.separator"); + String path = null; + try { + path = "book/index.html"; + url = getClass().getResource(path); + } catch (Exception e) { + System.err.println("Failed to open " + path); + url = null; + } + + if (url != null) { + html = new JEditorPane(url); + html.setEditable(false); + html.addHyperlinkListener(createHyperLinkListener()); + + JScrollPane scroller = new JScrollPane(); + JViewport vp = scroller.getViewport(); + vp.add(html); + add(scroller, BorderLayout.CENTER); + } + } catch (MalformedURLException e) { + System.out.println("Malformed URL: " + e); + } catch (IOException e) { + System.out.println("IOException: " + e); + } + } + + private HyperlinkListener createHyperLinkListener() { + return new HyperlinkListener() { + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (e instanceof HTMLFrameHyperlinkEvent) { + ((HTMLDocument) html.getDocument()).processHTMLFrameHyperlinkEvent( + (HTMLFrameHyperlinkEvent) e); + } else { + try { + html.setPage(e.getURL()); + } catch (IOException ioe) { + System.out.println("IOE: " + ioe); + } + } + } + } + }; + } +} diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/COPYRIGHT b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/COPYRIGHT new file mode 100644 index 0000000..02c3111 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/COPYRIGHT @@ -0,0 +1,15 @@ +Images and text in the SwingSet html demo used by permission of Octavo +Corporation (www.octavo.com), (c) 1999 by Octavo Corporation. All +rights reserved. + +Octavo Corporation (www.octavo.com) is a publisher of rare books and +manuscripts with digital tools and formats through partnerships with +libraries, museums, and individuals. Using high-resolution digital imaging +technology, Octavo releases digital rare books on CD-ROM as Adobe PDF files +which can be viewed on and printed from almost any computing platform. You +can view each page and the binding on your computer screen, zoom in to view +detail up to 800% in some cases, and search, copy and paste the "live" text +placed invisibly behind the page images which is available for selected +Editions. Also included in each edition is the work's collation and +provenance, as well as commentary by a noted expert in its field. + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/ant.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/ant.jpg new file mode 100644 index 0000000..5ec7350 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/ant.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/book.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/book.jpg new file mode 100644 index 0000000..001baa8 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/book.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/bug.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/bug.jpg new file mode 100644 index 0000000..7df9c1e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/bug.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/bug2.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/bug2.jpg new file mode 100644 index 0000000..18adf73 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/bug2.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/crest.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/crest.jpg new file mode 100644 index 0000000..46f68f1 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/crest.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/king.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/king.jpg new file mode 100644 index 0000000..dfed852 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/king.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/micro.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/micro.jpg new file mode 100644 index 0000000..8b7f197 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/micro.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/seaweed.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/seaweed.jpg new file mode 100644 index 0000000..340bae3 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/Octavo/seaweed.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/ant.html b/swingset3/com/sun/swingset3/demos/editorpane/book/ant.html new file mode 100644 index 0000000..64e9219 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/ant.html @@ -0,0 +1,121 @@ + + +Untitled Document + + + + +


+ Observ. XLIX. Of an Ant or Pismire.
+

+

+

 

+
+
+

This was a creature, more troublesom to be drawn, then any + of the rest, for I could not, for a good while, think of a way to make it + suffer its body to ly quiet in a natural posture; but whil'st it was alive, + if its feet were fetter'd in Wax or Glew, it would so twist and wind its body, + that I could not any wayes get a good view of it; and if I killed it, its + body was so little, that I did often spoile the shape of it, before I could + throughly view it: for this is the nature of these minute Bodies, that as + soon, almost, as ever their life is destroy'd, their parts immediately shrivel, + and lose their beauty; and so is it also with small Plants, as I instanced + before, in the description of Moss.

+

And thence also is the reason of the variations in the beards + of wild Oats, and in those of Muskgrass seed, that their bodies, being exceeding + small, those small variations which are made in the surfaces of all bodies, + almost upon every change of Air, especially if the body be porous, do here + become sensible, where the whole body is so small, that it is almost nothing + but surface; for as in vegetable substances, I see no great reason to think, + that the moisture of the Aire (that, sticking to a wreath'd beard, does make + it untwist) should evaporate, or exhale away, any faster then the moisture + of other bodies, but rather that the avolation from, or access of moisture + to, the surfaces of bodies being much the same, those bodies become most + sensible of it, which have the least proportion of body to their surface. +

+

So is it also with Animal substances; the dead body of an + Ant, or such little creature, does almost instantly shrivel and dry, and + your object shall be quite another thing, before you can half delineate + it, which proceeds not from the extraordinary exhalation, but from the small + proportion of body and juices, to the usual drying of bodies in the Air, + especially if warm.

+

For which inconvenience, where I could not otherwise remove + it, I thought of this expedient. I took the creature, I had design'd to delineate, + and put it into a drop of very well rectified spirit of Wine, this I found + would presently dispatch, as it were, the Animal, and being taken out of + it, and lay'd on a paper,the spirit of Wine would immediately fly away, + and leave the Animal dry, in its natural posture, or at least, in a constitution, + that it might easily with a pin be plac'd, in what posture you desired to + draw it, and the limbs would so remain, without either moving, or shriveling. +

+

And thus I dealt with this Ant, which I have here delineated, + which was one of many, of a very large kind, that inhabited under the Roots + of a Tree, from whence they would sally out in great parties, and make most + grievous havock of the Flowers and Fruits, in the ambient Garden, and return back + again very expertly, by the same wayes and paths they went.

+

It was more then half the bigness of an Earwig, of a dark + brown, or reddish colour, with long legs, on the hinder of which it would + stand up, and raise its head as high as it could above the ground, that it + might stare the further about it, just after the same manner as I have also + observ'd a hunting Spider to do: and putting my finger towards them, they + have at first all run towards it, till almost at it; and then they would stand + round about it, at a certain distance, and smell, as it were, and consider + whether they should any of them venture any further, till one more bold then + the rest venturing to climb it, all the rest, if I would have suffered them, + would have immediately followed : much such other seemingly rational actions + I have observ'd in this little Vermine with much pleasure, which would be + too long to be here related; those that desire more of them may satisfie + their curiosity in Ligons History of the Barbadoes.

+

Having insnar'd several of these into a small Box, I made + choice of the tallest grown among them, and separating it from the rest, + I gave it a Gill of Brandy, or Spirit of Wine, which after a while e'en knock'd + him down dead drunk, so that he became moveless, though at first putting + in he struggled for a pretty while very much, till at last, certain bubbles + issuing out of his mouth, it ceased to move; this (because I had before found + them quickly to recover again, if they were taken out presently) I suffered + to lye above an hour in the Spirit; and after I had taken it out, and put + its body and legs into a natural posture, remained moveless about an hour; + but then, upon a sudden, as if it had been awaken out of a drunken sleep, + it suddenly reviv'd and ran away; being caught, and serv'd as before, he + for a while continued struggling and striving, till at last there issued + several bubbles out of its mouth, and then, tanquam animam expirasset, he + remained moveless for a good while ; but at length again recovering, it was + again redipt, and suffered to lye some hours in the Spirit; notwithstanding + which, after it had layen dry some three or four hours, it again recovered + life and motion: Which kind of Experiments, if prosecuted, which they highly + deserve, seem to me of no inconsiderable use towards the invention of the + Latent Scheme, (as the Noble Ve rulam calls it) or the hidden, unknown Texture + of Bodies.

+

Of what Figure this Creature appear'd through the Microscope, + the 32. Scheme (though not so carefully graven as it ought) will represent + to the eye, namely, That it had a large head A A, at the upper end of which + were two protuberant eyes, pearl'd like those of a Fly, but smaller B B; + of the Nose, or foremost part, issued two horns C C, of a shape sufficiently + differing from those of a blew Fly, though indeed they seem to be both the + same kind of Organ, and to serve for a kind of smelling; beyond these were + two indented jaws D D, which he open'd sideways, and was able to gape them + asunder very wide; and the ends of them being armed with teeth, which meeting + went between each other, it was able to grasp and hold a heavy body, three + or four times the bulk and weight of its own body: It had only six legs, + shap'd like those of a Fly, which, as I shewed before, is an Argument that + it is a winged Insect, and though I could not perceive any sign of them in + the middle part of its body (which seem'd to consist of three joints or pieces + E F G, out of which sprung two legs, yet 'tis known that there are of them + that have long wings, and fly up and down in the air.

+

The third and last part of its body I I I was bigger and + larger then the other two, unto which it was joyn'd by a very small middle, + and had a kind of loose shell, or another distinct part of its body H, which + seem'd to be interpos'd, and to keep the thorax and belly from touching. + The whole body was cas'd over with a very strong armour, and the belly I + I I was covered likewise with multitudes of small white shining brisles; + the legs, horns, head, and middle parts of its body were bestruck with hairs + also, but smaller and darker.

+
+

 

+

+

 

+

 

+
+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/bug.html b/swingset3/com/sun/swingset3/demos/editorpane/book/bug.html new file mode 100644 index 0000000..71a1bb7 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/bug.html @@ -0,0 +1,128 @@ + + +Untitled Document + + + + +
+

Observ. LIV. Of a Louse.
+

+

+

 

+
+
+

This is a Creature so officious, that 'twill be known to + every one at one time or other, so busie, and so impudent, that it will + be intruding it self in every ones company, and so proud and aspiring withall, + that it fears not to trample on the best, and affects nothing so much as + a Crown; feeds and lives very high, and that makes it so saucy, as to pull + any one by the ears that comes in its way, and will never be quiet till + it has drawn blood: it is troubled at nothing so much as at a man that scratches + his head, as knowing that man is plotting and contriving some mischief against + it, and that makes it oftentime sculk into some meaner and lower place, and + run behind a mans back, though it go very much against the hair; which ill + conditions of it having made it better known then trusted, would exempt me + from making any further description of it, did not my faithful Mercury, my + Microscope, bring me other information of it.

+

For this has discovered to me, by means of a very bright light + cast on it, that it is a Creature of a very odd shape ; it has a head shap'd + like that exprest in 35. Scheme marked with A, which seems almost Conical, + but is a little flatted on the upper and under sides, at the biggest part + of which, on either side behind the head (as it were, being the place where + other Creatures ears stand) are placed its two black shining goggle eyes + B B, looking backwards, and fenced round with several small cilia or hairs + that incompass it, so that it seems this Creature has no very good foresight: + It does not seem to have any eyelids, and therefore perhaps its eyes were + so placed, that it might the better cleanse them with its forelegs; and perhaps + this may be the reason, why they so much avoid and run from the light behind + them, for being made to live in the shady and dark recesses of the hair, + and thence probably their eye having a great aperture, the open and clear + light, especially that of the Sun, must needs very much offend them; to secure + these eyes from receiving any injury from the hairs through which it passes, + it has two horns that grow before it, in the place where one would have thought + the eyes should be; each of these C C have four joynts, which are fringed, + as 'twere, with small brisles, from which to the tip of its snout D, the + head seems very round and tapering, ending in a very sharp nose D, which + seems to have a small hole, and to be the passage through which he sucks + the blood.

+

 

+

+

Now whereas it if be plac'd on its back, with its belly + upwards, as it is in the 35. Scheme, it seems in several Positions to have + a resemblance of chaps, or jaws, as is represented in the Figure by E E, + yet in other postures those dark strokes disappear; and having kept several + of them in a box for two or three dayes, so that for all that time they had + nothing to feed on, I found, upon letting onecreep on my hand, that it immediately + fell to sucking, and did neither seem to thrust its nose very deep into the + skin, nor to open any kind of mouth, but I could plainly perceive a small + current of blood, which came directly from its snout, and past into its belly; + and about A there seem'd a contrivance, somewhat resembling a Pump, pair + of Bellows, or Heart, for by a very swift systole and diastole the blood + seem'd drawn from the nose, and forced into the body.

+

It did not seem at all, though I viewed it a good while as + it was sucking, to thrust more of its nose into the skin then the very snout + D, nor did it cause the least discernable pain, and yet the blood seem'd + to run through its head very quick and freely, so that it seems there is + no part of the skin but the blood is dispers'd into, nay, even into the + cuticula; for had it thrust its whole nose in from D to C C, it would not + have amounted to the supposed thickness of that tegument, the length of + the nose being not more then a three hundredth part of an inch.

+

It has six legs, covered with a very transparent shell, + and joynted exactly like a Crab's, or Lobster's; each leg is divided into + six parts by these joynts, and those have here and there several small hairs; + and at the end of each leg it has two claws, very properly adapted for its + peculiar use, being thereby inabled to walk very securely both on the skin + and hair; and indeed this contrivance of the feet is very curious, and could + not be made more commodiously and compendiously, for performing both these + requisite motions, of walking and climbing up the hair of a mans head, then + it is : for, by having the lesser claw (a) set so much short of the bigger + (b) when it walks on the skin the shorter touches not, and then the feet + are the same with those of a Mite, and several other small Insects, but by + means of the small joynts of the longer claw it can bend it round, and so + with both claws take hold of a hair, in the manner represented in the Figure, + the long transparent Cylinder F F F, being a Man's hair held by it.

+

The Thorax seem'd cas'd with another kind of substance then + the belly, namely, with a thin transparent horny substance, which upon the fasting + of the Creature did not grow flaccid; through this I could plainly see the + blood, suck'd from my hand, to be variously distributed, and mov'd to and + fro; and about G there seem'd a pretty big white substance, which seem'd + to be moved within its thorax; besides, there appear'd very many small milk-white + vessels, which crost over the breast between the legs, out of which, on + either side, are many small branchings, these seem'd to be the veins and + arteries, for that which is analogus to blood in all Insects is milk-white. +

+

The belly is covered with a transparent substance likewise, + but more resembling a skin then a shell, for 'tis grain'd all over the belly + just like the skin in the palms of a man's hand, and when the belly is empty, + grows very flaccid and wrinkled ; at the upper end of this is placed the + stomach H H, and perhaps also the white spot I I may be the liver, or pancreas, + which by the peristaltick motion of the guts, is a little mov'd to and fro, + not with a systole and diastole, but rather with a thronging or justling + motion.

+

Viewing one of these Creatures, after it had fasted two + dayes, all the hinder part was lank and flaccid, and the white spot I I + hardly mov'd, most of the white branchings disappear'd, and most also of + the redness or sucked blood in the guts, the peristaltick motion of which + was scarce discernable; but upon the suffering it to suck, it presently + fill'd the skin of the belly, and of the six scolop'd embosments on either side, + as full as it could be stuft ; the stomach and guts were as full as they + could hold; the peristaltick motion of the gut grew quick, and the justling + motion of I I accordingly ; multitudes of milk-white vessels seem'd quickly + filled, and turgid, which were perhaps the veins and arteries, and the Creature + was so greedy, that though it could not contain more, yet it continued sucking + as fast as ever, and as fast emptying it self behind : the digestion of this + Creature must needs be very quick, for though I perceiv'd the blood thicker + and blacker when suck'd, yet, when in the guts, it was of a very lovely + ruby colour, and that part of it, which was digested into the veins, seemed + white; whence it appears, that a further digestion of blood may make it + milk, at least of a resembling colour : What is else observable in the figure + of this Creature, maybe seen by the 35. Scheme.

+
+

 

+

+

 

+

 

+
+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/back.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/back.jpg new file mode 100644 index 0000000..eb20ab7 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/back.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/forward.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/forward.jpg new file mode 100644 index 0000000..465b996 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/forward.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/header.jpg b/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/header.jpg new file mode 100644 index 0000000..d69cc0f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/book/editorpane/header.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/index.html b/swingset3/com/sun/swingset3/demos/editorpane/book/index.html new file mode 100644 index 0000000..cfcc4fa --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/index.html @@ -0,0 +1,42 @@ + + +Untitled Document + + + + +

 

+

+

+

 

+

 

+
+

Title Page

+

To The King

+

The Preface

+

Of the curious texture of Sea-weeds

+

Of an Ant or Pismire

+

Of a Louse
+
+
+

+

Images and text used by permission of Octavo + Corporation (www.octavo.com),
+
(c) 1999 Octavo Corporation. All + rights reserved.
+
+
+ Octavo Corporation is a publisher of rare + books and manuscripts with digital tools and formats through partnerships + with libraries, museums, and individuals. Using high-resolution digital imaging + technology, Octavo releases digital rare books on CD-ROM as Adobe PDF files + which can be viewed on and printed from almost any computing platform. You + can view each page and the binding on your computer screen, zoom in to view + detail up to 800% in some cases, and search, copy and paste the "live" text + placed invisibly behind the page images which is available for selected Editions. + Also included in each edition is the work's collation and provenance, as well + as commentary by a noted expert in its field.

+
+

 

+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/king.html b/swingset3/com/sun/swingset3/demos/editorpane/book/king.html new file mode 100644 index 0000000..c8a615e --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/king.html @@ -0,0 +1,45 @@ + + +Untitled Document + + + + +

+

+

 

+
Do here most humbly lay this small Present at Your + Majesties Royal feet. And though it comes accompany'd with two disadvantages, + the meanness of the Author, and of the Subject; yet in both I am incouraged + by the greatness of your Mercy and your Knowledge. +

By the one I am taught , that you can forgive the most presumptuous + Offendors: And by the other, that you will not esteem the least work of Nature, + or Art, unworthy your Observation.

+

Amidst the many felicities that have accompani'd your Majesties + happy Restauration and Government, it is none of the least considerable, that + Philosophy and Experimental Learning have prosper'd under your Royal Patronage.

+

And as the calm prosperity of your Reign has given us the + leisure to follow these Studies of quiet and retirement, so it is just, that + the Fruits of them should, by way of acknowledgement, be return'd to your + Majesty. There are, Sir, several other of your Subjects, of your Royal Society, + now busie about Nobler matters: The Improvement of Manufactures and Agriculture, + the Increase of Commerce, the Advantage of Navigation: In all which they are + assisted by your Majesties Incouragement and Example.

+

Amidst all those greater Designs, I here presume to bring + in that which is more proportionable to the smalness of my Abilities, and + to offer some of the least of all visible things, to that Mighty King, that + has establisht an Empire over the best of all Invisible things of this World, + the Minds o f Men.

+
+

 

+
+

Your Majesties most humble

+

and most obedient

+

Subject and Servant,

+

 

+

ROBERT HOOKE .

+

 

+

+
+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/preface.html b/swingset3/com/sun/swingset3/demos/editorpane/book/preface.html new file mode 100644 index 0000000..73108fd --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/preface.html @@ -0,0 +1,115 @@ + + +Untitled Document + + + + +
+

 

+

THE PREFACE

+
+
+

 

+

 

+
+
+
+

It is the great prerogative of Mankind above + other Creatures, that we are not only able to behold the works of Nature, + or barely to sustein our lives by them, but we have also the power of considering, + comparing, altering, assisting, and improving them to various uses.

+

And as this is the peculiar priviledge of humane Nature + in general, so is it capable of being so far advanced by the helps of Art, + and Experience, as to make some Men excel others in their Observations, + and Deductions, almost as much as they do Beasts.

+

By the addition of such artificial Instruments and methods, + there may be, in some manner, a reparation made for the mischiefs, and imperfection, + mankind has drawn upon itself, by negligence, and intemperance, and a wilful + and superstitious deserting the Prescripts and Rules of Nature, whereby + every man, both from a deriv'd corruption, innate and born with him, and + from his breeding and converse with men, is very subject to slip into all + sorts of errors.

+

The only way which now remains for us to recover some degree + of those former perfections, seems to be, by rectifying the operations of + the Sense, the Memory, and Reason, since upon the evidence, the strength, + the integrity, and the right correspondence of all these, all the light, + by which our actions are to be guided, is to be renewed, and all our command + over things is to be establisht.

+

It is therefore most worthy of our consideration, to recollect + their several defects, that so we may the better understand how to supply + them, and by what assistances we may inlarge their power, and secure them + in performing their particular duties.

+

As for the actions of our Senses, we cannot but observe + them to be in many particulars much outdone by those of other Creatures, + and when at best, to be far short of the perfection they seem capable of + : And these infirmities of the Senses arise from a double cause, either + from the disproportion of the Object to the Organ, whereby an infinite number + of things can never enter into them, or else from error in the Perception, + that many things, which come within their reach, are not received in a right + manner.

+

The like frailties are to be found in the Memory; we often + let many things slip away from us, which deserve to be retain'd; and of + those which we treasure up, a great part is either frivolous or false ; + and if good, and substantial, either in tract of time obliterated, or at + best so overwhelmed and buried under more frothy notions, that when there + is need of them, they are in vain sought for.

+

The two main foundations being so deceivable, it is no wonder, + that all the succeeding works which we build upon them, of arguing, concluding, + defining, judging, and all the other degrees of Reason, are lyable to the + same imperfection, being, at best, either vain, or uncertain: So that the + errors of the understanding are answerable to the two other, being defective + both in the quantity and goodness of its knowledge; for the limits, to which + our thoughts are confind, are small in respect of the vast extent of Nature + it self; some parts of it are too large to be comprehended, and some too + little to be perceived.

+

And from thence it must follow, that not having a full sensation + of the Object, we must be very lame and imperfect in our conceptions about + it, and in all the propositions which we build upon it; hence we often take + the shadow of things for the substance, small appearances for good similitudes, + similitudes for definitions; and even many of those, which we think to be + the most solid definitions, are rather expressions of our own misguided + apprehensions then of the true nature of the things themselves.

+

The effects of these imperfections are manifested in different + ways, according to the temper and disposition of the several minds of men, + some they incline to gross ignorance and stupidity, and others to a presumptuous + imposing on other mens Opinions, and a confident dogmatizing on matters, + whereof there is no assurance to be given.

+

Thus all the uncertainty, and mistakes of humane actions, + proceed either from the narrowness and wandring of our Senses, from the + slipperiness or delusion of our Memory, from the confinement or rashness + of our Understanding, so that 'tis no wonder, that our power over natural + causes and effects is so slowly improvd, seeing we are not only to contend + with the obscurity and difficulty of the things whereon we work and think, + but even the forces of our own minds conspire to betray us.

+

These being the dangers in the process of humane Reason, + the remedies of them all can only proceed from the real, the mechanical, + the experimental Philosophy, which has this advantage over the Philosophy + of discourse and disputation, that whereas that chiefly aims at the subtilty + of its Deductions and Conclusions, without much regard to the first groundwork, + which ought to be well laid on the Sense and Memory ; so this intends the + right ordering of them all, and the making them serviceable to each other. +

+

The first thing to be undertaken in this weighty work, is + a watchfulness over the failings and an inlargement of the dominion, of + the Senses. To which end it is requisite, first, That there should be a + scrupulous choice, and a strict examination, of the reality, constancy, + and certainty of the Particulars that we admit: This is the first rise whereon + truth is to begin, and here the most severe, and most impartial diligence, + must be imployed ; the storing up of all, without any regard to evidence + or use, will only tend to darkness and confusion.

+

We must not therefore esteem the riches of our Philosophical + treasure by the number only, but chiefly by the weight; the most vulgar + Instances are not to be neglected, but above all, the most instructive are + to be entertain'd: the footsteps of Nature are to be trac'd, not only in + her ordinary course,but when she seems to be put to her shifts, to make + many doublings and turnings, and to use some kind of art in indeavouring + to avoid our discovery.

+

 

+

+

 

+

 

+
+
+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/seaweed.html b/swingset3/com/sun/swingset3/demos/editorpane/book/seaweed.html new file mode 100644 index 0000000..c1fa75b --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/seaweed.html @@ -0,0 +1,62 @@ + + +Untitled Document + + + + +


+ Observ. XXIII. Of the curious texture of Sea-weeds.
+

+

+

 

+
+

For curiosity and beauty, I have not among all the Plants + or Vegetables I have yet observ'd, seen any one comparable to this Sea-weed + I have here describ'd, of which I am able to say very little more then what + is represented by the second Figure of the ninth Scheme: Namely, that it is + a Plant which grows upon the Rocks under the water, and increases and spreads + it self into a great tuft, which is not onely handsomely branch'd into several + leaves, but the whole surface of the Plant is cover'd over with a most curious + kind of carv'd work, which consists of a texture much resembling a Honeycomb; + for the whole surface on both sides is cover'd over with a multitude of very + small holes, being no bigger then so many holes made with the point of a small + Pinn, and rang'd in the neatest and most delicate order imaginable, they being + plac'd in the manner of a Quincunx, or very much like the rows of the eyes + of a Fly, the rows or orders being very regular, which way soever they are + observ'd: what the texture was, as it appear'd through a pretty bigg Magnifying + Microscope, I have here adjoin'd in the first Figure of the 14. Scheme. which + round Area A B C D represents a part of the surface about one eighth part + of an Inch in Diameter: Those little holes, which to the eye look'd round, + like so many little spots, here appear'd very regularly shap'd holes, representing + almost the shape of the sole of a round toed shoe, the hinder part of which, + is, as it were, trod on or cover'd by the toe of that next below it; these + holes seem'd wall'd about with a very thin and transparent substance, looking + of a pale straw-colour; from the edge of which, against the middle of each + hole, were sprouted out four small transparent straw-colour'd Thorns, which + seem'd to protect and cover those cavities, from either side two; neer the + root of this Plant, were sprouted out several small branches of a kind of + bastard Coralline, curiously branch'd, though small.

+

And to confirm this, having lately the opportunity of viewing + the large Plant (if I may so call it) of a Sponge petrify'd, of which I made + mention in the last Observation, I found, that each of the Branches or Figures + of it, did, by the range of its pores, exhibit just such a texture, the rows + of pores crossing one another, much after the manner as the rows of eyes do + which are describ'd in the 26. Scheme : Coralline also, and several sorts of + white Coral, I have with a Microscope observ'd very curiously shap'd. And + I doubt not, but that he that shall observe these several kinds of Plants that + grow upon Rocks, which the Sea sometimes overflows, and those heaps of others + which are vomited out of it upon the shore, may find multitudes of little + Plants, and other bodies, which like this will afford very beautifull objects + for the Microscope ; and this Specimen here is adjoin'd onely to excite their + curiosities who have opportunity of observing to examine and collect what + they find worthy their notice; for the Sea, among terrestrial bodies, is also + a prolifick mother, and affords as many Instances of spontaneous generations + as either the Air or Earth.

+

 

+

+

 

+

 

+
+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/book/title.html b/swingset3/com/sun/swingset3/demos/editorpane/book/title.html new file mode 100644 index 0000000..efdc15b --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/book/title.html @@ -0,0 +1,37 @@ + + +Untitled Document + + + + +


+ MICROGRAPHIA:

+

OR SOME

+

Physiological Descriptions

+

O F

+

MINUTE BODIES

+

MADE BY

+

MAGNIFYING GLASSES.

+

WITH

+

OBSERVATIONS and INQUIRIES + thereupon.

+

By R. HOOKE + , Fellow of the ROYAL SOCIETY .

+

+
+
+
+

LONDON, Printed by Jo. + Martyn, and Ja. Allestry, + Printers to the ROYAL SOCIETY , and are to + be sold at their Shop at the Bell in S. Paul's Church-yard. M + D C L X V.

+


+

+
+

+
+
+ + diff --git a/swingset3/com/sun/swingset3/demos/editorpane/resources/EditorPaneDemo.properties b/swingset3/com/sun/swingset3/demos/editorpane/resources/EditorPaneDemo.properties new file mode 100644 index 0000000..fa2a38f --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/editorpane/resources/EditorPaneDemo.properties @@ -0,0 +1,6 @@ +### Html Demo ### + +EditorPaneDemo.accessible_description=This demo shows how to display html text using the JEditorPane component. +EditorPaneDemo.tooltip=JEditorPane HTML demo +EditorPaneDemo.name=JEditorPane HTML Demo +EditorPaneDemo.filename=swing.html diff --git a/swingset3/com/sun/swingset3/demos/editorpane/resources/images/EditorPaneDemo.gif b/swingset3/com/sun/swingset3/demos/editorpane/resources/images/EditorPaneDemo.gif new file mode 100644 index 0000000..ce007e2 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/editorpane/resources/images/EditorPaneDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/filechooser/FileChooserDemo.java b/swingset3/com/sun/swingset3/demos/filechooser/FileChooserDemo.java new file mode 100644 index 0000000..7174ae3 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/filechooser/FileChooserDemo.java @@ -0,0 +1,563 @@ +/* + * 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.demos.filechooser; + +import java.awt.*; +import java.awt.color.ColorSpace; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.AffineTransform; +import java.awt.image.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.*; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; + +import com.sun.swingset3.demos.JGridPanel; +import com.sun.swingset3.demos.ResourceManager; +import com.sun.swingset3.DemoProperties; + +/** + * JFileChooserDemo + * + * @author Pavel Porvatov + */ +@DemoProperties( + value = "JFileChooser Demo", + category = "Choosers", + description = "Demonstrates JFileChooser, a component which allows the user to open and save files.", + sourceFiles = { + "com/sun/swingset3/demos/filechooser/FileChooserDemo.java", + "com/sun/swingset3/demos/DemoUtilities.java", + "com/sun/swingset3/demos/filechooser/resources/FileChooserDemo.properties", + "com/sun/swingset3/demos/filechooser/resources/images/apply.png", + "com/sun/swingset3/demos/filechooser/resources/images/FileChooserDemo.gif", + "com/sun/swingset3/demos/filechooser/resources/images/fliphor.png", + "com/sun/swingset3/demos/filechooser/resources/images/flipvert.png", + "com/sun/swingset3/demos/filechooser/resources/images/rotateleft.png", + "com/sun/swingset3/demos/filechooser/resources/images/rotateright.png" + } +) +public class FileChooserDemo extends JPanel { + private enum State { + EMPTY, + IMAGE_LOADED, + IMAGE_CHANGED + } + + private static final int MIN_FILTER_ID = 0; + + private static final int MAX_FILTER_ID = 7; + + private static final String[] FILTER_NAMES = { + "FileChooserDemo.filter.blur", + "FileChooserDemo.filter.edge", + "FileChooserDemo.filter.sharpen", + "FileChooserDemo.filter.darken", + "FileChooserDemo.filter.brighten", + "FileChooserDemo.filter.lesscontrast", + "FileChooserDemo.filter.morecontrast", + "FileChooserDemo.filter.gray" + }; + + private static final BufferedImageOp[] FILTER_OPERATIONS = { + new ConvolveOp(new Kernel(3, 3, + new float[]{.1111f, .1111f, .1111f, .1111f, .1111f, .1111f, .1111f, .1111f, .1111f}), + ConvolveOp.EDGE_NO_OP, null), + new ConvolveOp(new Kernel(3, 3, + new float[]{0.0f, -1.0f, 0.0f, -1.0f, 4.f, -1.0f, 0.0f, -1.0f, 0.0f}), + ConvolveOp.EDGE_NO_OP, null), + new ConvolveOp(new Kernel(3, 3, + new float[]{0.0f, -1.0f, 0.0f, -1.0f, 5.f, -1.0f, 0.0f, -1.0f, 0.0f}), + ConvolveOp.EDGE_NO_OP, null), + new RescaleOp(1, -5.0f, null), + new RescaleOp(1, 5.0f, null), + new RescaleOp(0.9f, 0, null), + new RescaleOp(1.1f, 0, null), + new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null) + }; + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final JLabel lbImage = new JLabel(resourceManager.getString("FileChooserDemo.image.text"), JLabel.CENTER); + + private final JScrollPane pnImage = new JScrollPane(lbImage); + + private final JButton btnSelect = new JButton(resourceManager.getString("FileChooserDemo.select.text")); + + private final JButton btnSelectWithPreview = new JButton(resourceManager.getString("FileChooserDemo.selectwithpreview.text")); + + private final JComboBox cbFilters = new JComboBox(); + + private final JButton btnApplyFilter = createButton("apply.png", "FileChooserDemo.applyfilter.tooltip"); + + private final JButton btnRotateLeft = createButton("rotateleft.png", "FileChooserDemo.rotateleft.tooltip"); + + private final JButton btnRotateRight = createButton("rotateright.png", "FileChooserDemo.rotateright.tooltip"); + + private final JButton btnFlipHorizontal = createButton("fliphor.png", "FileChooserDemo.fliphorizontal.tooltip"); + + private final JButton btnFlipVertical = createButton("flipvert.png", "FileChooserDemo.flipvertical.tooltip"); + + private final JButton btnSave = new JButton(resourceManager.getString("FileChooserDemo.save.text")); + + private final JButton btnCancel = new JButton(resourceManager.getString("FileChooserDemo.cancel.text")); + + private final JFileChooser externalChooser = new JFileChooser(); + + private final JFileChooser embeddedChooser = new JFileChooser(); + + private final JGridPanel pnContent = new JGridPanel(1, 0, 0); + + private State state; + + private boolean fileChoosing; + + private File file; + + private BufferedImage image; + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(FileChooserDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new FileChooserDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * FileChooserDemo Constructor + */ + public FileChooserDemo() { + setLayout(new BorderLayout()); + + initUI(); + + embeddedChooser.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (JFileChooser.APPROVE_SELECTION.equals(e.getActionCommand())) { + loadFile(embeddedChooser.getSelectedFile()); + } + + if (JFileChooser.CANCEL_SELECTION.equals(e.getActionCommand())) { + setState(state, false); + } + } + }); + + btnSelect.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (fileChoosing) { + loadFile(embeddedChooser.getSelectedFile()); + } else { + setState(state, true); + } + } + }); + + btnSelectWithPreview.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (externalChooser.showOpenDialog(FileChooserDemo.this) == JFileChooser.APPROVE_OPTION) { + loadFile(externalChooser.getSelectedFile()); + } + } + }); + + btnApplyFilter.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doFilter(FILTER_OPERATIONS[((FilterItem) cbFilters.getSelectedItem()).getId()]); + } + }); + + btnRotateLeft.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAffineTransform(image.getHeight(), image.getWidth(), + new AffineTransform(0, -1, 1, 0, 0, image.getWidth())); + } + }); + + btnRotateRight.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAffineTransform(image.getHeight(), image.getWidth(), + new AffineTransform(0, 1, -1, 0, image.getHeight(), 0)); + } + }); + + btnFlipHorizontal.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAffineTransform(image.getWidth(), image.getHeight(), + new AffineTransform(-1, 0, 0, 1, image.getWidth(), 0)); + } + }); + + btnFlipVertical.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAffineTransform(image.getWidth(), image.getHeight(), + new AffineTransform(1, 0, 0, -1, 0, image.getHeight())); + } + }); + + btnSave.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (JOptionPane.showConfirmDialog(FileChooserDemo.this, + resourceManager.getString("FileChooserDemo.savequiestion.message"), + resourceManager.getString("FileChooserDemo.savequiestion.title"), + JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { + return; + } + + String fileName = file.getName(); + + int i = fileName.lastIndexOf('.'); + + try { + ImageIO.write(image, fileName.substring(i + 1), file); + + setState(State.IMAGE_LOADED, false); + } catch (IOException e1) { + JOptionPane.showMessageDialog(FileChooserDemo.this, + MessageFormat.format(resourceManager.getString("FileChooserDemo.errorsavefile.message"), e1), + resourceManager.getString("FileChooserDemo.errorsavefile.title"), + JOptionPane.ERROR_MESSAGE); + } + } + }); + + btnCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + loadFile(file); + } + }); + } + + private void initUI() { + externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg")); + externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("All supported images", + ImageIO.getWriterFormatNames())); + + final FilePreview filePreview = new FilePreview(); + + externalChooser.setAccessory(filePreview); + externalChooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + filePreview.loadFileInfo(externalChooser.getSelectedFile()); + } + }); + + embeddedChooser.setControlButtonsAreShown(false); + + embeddedChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg")); + + FileNameExtensionFilter filter = new FileNameExtensionFilter("All supported images", + ImageIO.getWriterFormatNames()); + + embeddedChooser.addChoosableFileFilter(filter); + embeddedChooser.setFileFilter(filter); + + for (int i = MIN_FILTER_ID; i <= MAX_FILTER_ID; i++) { + cbFilters.addItem(new FilterItem(i, resourceManager.getString(FILTER_NAMES[i]))); + } + + JGridPanel pnFilter = new JGridPanel(2, 0); + + pnFilter.cell(cbFilters). + cell(btnApplyFilter); + + JGridPanel pnRotateButtons = new JGridPanel(4, 3); + + pnRotateButtons.cell(btnRotateLeft). + cell(btnRotateRight). + cell(btnFlipHorizontal). + cell(btnFlipVertical); + + JGridPanel pnBottom = new JGridPanel(4, 1); + + pnBottom.setHGap(JGridPanel.DEFAULT_GAP * 4); + + pnBottom.cell(btnSelect, JGridPanel.Layout.FILL). + cell(). + cell(pnFilter). + cell(btnSave, JGridPanel.Layout.FILL). + cell(btnSelectWithPreview, JGridPanel.Layout.FILL). + cell(). + cell(pnRotateButtons). + cell(btnCancel, JGridPanel.Layout.FILL); + + pnContent.cell(pnImage); + pnContent.cell(pnBottom, new Insets(10, 10, 10, 10)); + + add(pnContent); + + setState(State.EMPTY, false); + } + + private JButton createButton(String image, String toolTip) { + JButton res = new JButton(resourceManager.createImageIcon(image, null)); + + res.setPreferredSize(new Dimension(26, 26)); + res.setMinimumSize(new Dimension(26, 26)); + res.setToolTipText(resourceManager.getString(toolTip)); + + return res; + } + + private void doAffineTransform(int width, int height, AffineTransform transform) { + BufferedImage newImage = new BufferedImage(image.getColorModel(), + image.getRaster().createCompatibleWritableRaster(width, height), + image.isAlphaPremultiplied(), new Hashtable()); + + ((Graphics2D) newImage.getGraphics()).drawRenderedImage(image, transform); + + image = newImage; + + lbImage.setIcon(new ImageIcon(image)); + + setState(State.IMAGE_CHANGED, false); + } + + private void doFilter(BufferedImageOp imageOp) { + BufferedImage newImage = new BufferedImage(image.getColorModel(), + image.getRaster().createCompatibleWritableRaster(image.getWidth(), image.getHeight()), + image.isAlphaPremultiplied(), new Hashtable()); + + imageOp.filter(image, newImage); + + image = newImage; + + lbImage.setIcon(new ImageIcon(image)); + + setState(State.IMAGE_CHANGED, false); + } + + private void loadFile(File file) { + if (file == null) { + JOptionPane.showMessageDialog(this, + resourceManager.getString("FileChooserDemo.selectfile.message"), + resourceManager.getString("FileChooserDemo.selectfile.title"), + JOptionPane.INFORMATION_MESSAGE); + + return; + } + + try { + image = ImageIO.read(file); + + if (image != null) { + lbImage.setText(null); + lbImage.setIcon(new ImageIcon(image)); + + this.file = file; + + setState(State.IMAGE_LOADED, false); + + return; + } + } catch (IOException e1) { + // Do nothing + } + + JOptionPane.showMessageDialog(this, + resourceManager.getString("FileChooserDemo.errorloadfile.message"), + resourceManager.getString("FileChooserDemo.errorloadfile.title"), + JOptionPane.ERROR_MESSAGE); + } + + private void setState(State state, boolean fileChoosing) { + if (this.fileChoosing != fileChoosing) { + pnContent.setComponent(fileChoosing ? embeddedChooser : pnImage, 0, 0); + } + + this.state = state; + this.fileChoosing = fileChoosing; + + btnSelectWithPreview.setEnabled(!fileChoosing); + + boolean isImageLoaded = !fileChoosing && state != State.EMPTY; + + cbFilters.setEnabled(isImageLoaded); + btnApplyFilter.setEnabled(isImageLoaded); + btnRotateRight.setEnabled(isImageLoaded); + btnRotateLeft.setEnabled(isImageLoaded); + btnFlipHorizontal.setEnabled(isImageLoaded); + btnFlipVertical.setEnabled(isImageLoaded); + + boolean isImageChanged = !fileChoosing && state == State.IMAGE_CHANGED; + + btnSave.setEnabled(isImageChanged); + btnCancel.setEnabled(isImageChanged); + } + + private static class FilterItem { + /** + * 0 - blur + * 1 - edge + * 2 - sharpen + * 3 - darken + * 4 - brighten + * 5 - less contrast + * 6 - more contrast + * 7 - gray + */ + private final int id; + + private final String name; + + private FilterItem(int id, String name) { + assert id >= MIN_FILTER_ID && id <= MAX_FILTER_ID; + + this.id = id; + this.name = name; + } + + public int getId() { + return id; + } + + public String toString() { + return name; + } + } + + private enum FileType { + IMAGE + } + + private class FilePreview extends JGridPanel { + private static final int SIZE = 200; + + private final JLabel lbType = new JLabel(); + + private final JLabel lbSize = new JLabel(); + + private final JLabel lbPreview = new JLabel(resourceManager.getString("FileChooserDemo.preview.emptytext"), JLabel.CENTER); + + private final Map knownTypes = new HashMap(); + + public FilePreview() { + super(1, 0, 1); + + for (String s : ImageIO.getWriterFormatNames()) { + knownTypes.put(s.toLowerCase(), FileType.IMAGE); + } + + initUI(); + } + + public void loadFileInfo(File file) { + boolean emptyPreview = true; + + if (file == null) { + lbType.setText(null); + lbSize.setText(null); + } else { + lbType.setText(externalChooser.getFileSystemView().getSystemTypeDescription(file)); + lbSize.setText(Long.toString(file.length())); + + String fileName = file.getName(); + + int i = fileName.lastIndexOf("."); + + String ext = i < 0 ? null : fileName.substring(i + 1); + + FileType fileType = knownTypes.get(ext.toLowerCase()); + + if (fileType != null) { + switch (fileType) { + case IMAGE: + try { + BufferedImage image = ImageIO.read(file); + + double coeff = Math.min(((double) SIZE) / image.getWidth(), + ((double) SIZE) / image.getHeight()); + + BufferedImage scaledImage = new BufferedImage( + (int) Math.round(image.getWidth() * coeff), + (int) Math.round(image.getHeight() * coeff), + BufferedImage.TYPE_INT_RGB); + + Graphics2D g = (Graphics2D) scaledImage.getGraphics(); + + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.drawImage(image, 0, 0, scaledImage.getWidth(), scaledImage.getHeight(), null); + + lbPreview.setText(null); + lbPreview.setIcon(new ImageIcon(scaledImage)); + + setComponent(lbPreview, 0, 1); + + emptyPreview = false; + } catch (IOException e) { + // Empty preview + } + + break; + } + } + } + + if (emptyPreview) { + lbPreview.setIcon(null); + lbPreview.setText(resourceManager.getString("FileChooserDemo.preview.emptytext")); + + setComponent(lbPreview, 0, 1); + } + } + + private void initUI() { + setPreferredSize(new Dimension(SIZE, -1)); + + setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + + JGridPanel pnInfo = new JGridPanel(2, 1); + + pnInfo.cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.type"))). + cell(lbType). + cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.size"))). + cell(lbSize); + + cell(pnInfo); + cell(lbPreview, Layout.FILL, Layout.FILL); + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/FileChooserDemo.properties b/swingset3/com/sun/swingset3/demos/filechooser/resources/FileChooserDemo.properties new file mode 100644 index 0000000..39e3db2 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/filechooser/resources/FileChooserDemo.properties @@ -0,0 +1,38 @@ +### FileChooser Demo ### + +FileChooserDemo.image.text = Click the Select image button to select an image +FileChooserDemo.select.text = Select image +FileChooserDemo.selectwithpreview.text = Select with preview +FileChooserDemo.save.text = Save +FileChooserDemo.cancel.text = Cancel + +FileChooserDemo.filter.blur = blur +FileChooserDemo.filter.edge = edge +FileChooserDemo.filter.sharpen = sharpen +FileChooserDemo.filter.darken = darken +FileChooserDemo.filter.brighten = brighten +FileChooserDemo.filter.lesscontrast = less contrast +FileChooserDemo.filter.morecontrast = more contrast +FileChooserDemo.filter.gray = gray + +FileChooserDemo.applyfilter.tooltip = Apply filter +FileChooserDemo.rotateleft.tooltip = Rotate left +FileChooserDemo.rotateright.tooltip = Rotate right +FileChooserDemo.fliphorizontal.tooltip = Flip horizontal +FileChooserDemo.flipvertical.tooltip = Flip vertical + +FileChooserDemo.preview.type = Type: +FileChooserDemo.preview.size = Size: +FileChooserDemo.preview.emptytext = Preview area + +FileChooserDemo.selectfile.title = Information +FileChooserDemo.selectfile.message = Select a valid image file please + +FileChooserDemo.savequiestion.title = Confirmation +FileChooserDemo.savequiestion.message = Do you really want to save changes? + +FileChooserDemo.errorloadfile.title = Error +FileChooserDemo.errorloadfile.message = Cannot load file + +FileChooserDemo.errorsavefile.title = Error +FileChooserDemo.errorsavefile.message = Cannot save file: {0} diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/images/FileChooserDemo.gif b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/FileChooserDemo.gif new file mode 100644 index 0000000..80ac6b4 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/FileChooserDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/images/apply.png b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/apply.png new file mode 100644 index 0000000..508c46e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/apply.png differ diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/images/fliphor.png b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/fliphor.png new file mode 100644 index 0000000..4ccda9a Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/fliphor.png differ diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/images/flipvert.png b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/flipvert.png new file mode 100644 index 0000000..8a18a3d Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/flipvert.png differ diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/images/rotateleft.png b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/rotateleft.png new file mode 100644 index 0000000..d70b07d Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/rotateleft.png differ diff --git a/swingset3/com/sun/swingset3/demos/filechooser/resources/images/rotateright.png b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/rotateright.png new file mode 100644 index 0000000..9bd2354 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/filechooser/resources/images/rotateright.png differ diff --git a/swingset3/com/sun/swingset3/demos/frame/BusyGlass.java b/swingset3/com/sun/swingset3/demos/frame/BusyGlass.java new file mode 100644 index 0000000..7cffcb2 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/frame/BusyGlass.java @@ -0,0 +1,84 @@ +/* + * 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.demos.frame; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Graphics; +import javax.swing.JPanel; + +/** + * GlassPane component which can be set on toplevel + * containers to makes those containers "busy" be disabling input. + * + * Example usage: + *

+ *    // Install glasspane
+ *    frame.setGlassPane(new BusyGlass());
+ *
+ *    // Make frame busy
+ *    frame.getGlassPane().setVisible(true);
+ * 
+ * + * Caution: A well-written client should rarely need to make + * a window "busy" because the app should be as responsive as possible; + * long-winded operations should be off-loaded to non-GUI threads + * whenever possible. + * + * @author aim + */ +//Make toplevel "busy" +public class BusyGlass extends JPanel { + + /** + * Create GlassPane component to block input on toplevel + */ + public BusyGlass() { + setLayout(new BorderLayout()); + setVisible(false); //initially invisible + setOpaque(false); + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + protected void paintComponent(Graphics g) { + // Render partially opaque to 'veil' the frame's contents so + // that the user has visual feedback that the components + // arn't responsive. + Color bgColor = getBackground(); + g.setColor(new Color(bgColor.getRed(), + bgColor.getGreen(), + bgColor.getBlue(), 150)); + g.fillRect(0, 0, getWidth(), getHeight()); + } +} +// \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java b/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java new file mode 100644 index 0000000..fe9d369 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/frame/FrameDemo.java @@ -0,0 +1,252 @@ +/* + * 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.demos.frame; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URL; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.DemoUtilities; + +/** + * Demo for Swing's JFrame toplevel component. + * + * @author aim + */ +@DemoProperties( + value = "JFrame Demo", + category = "Toplevel Containers", + description = "Demonstrates JFrame, Swing's top-level primary window container.", + sourceFiles = { + "com/sun/swingset3/demos/frame/BusyGlass.java", + "com/sun/swingset3/demos/frame/FrameDemo.java", + "com/sun/swingset3/demos/DemoUtilities.java", + "com/sun/swingset3/demos/frame/resources/FrameDemo.html", + "com/sun/swingset3/demos/frame/resources/images/FrameDemo.gif" + } +) +public class FrameDemo extends JPanel { + //Ensure system menubar is used on Mac OSX + static { + // Property must be set *early* due to Apple Bug#3909714 + // ignored on other platforms + if (System.getProperty("os.name").equals("Mac OS X")) { + System.setProperty("apple.laf.useScreenMenuBar", "true"); + } + } + // + + // Toplevel frame component + private JFrame frame; + + private JComponent frameSpaceholder; + + public FrameDemo() { + initComponents(); + } + + protected void initComponents() { + frame = createFrame(); + + setLayout(new BorderLayout()); + add(createControlPanel(), BorderLayout.WEST); + frameSpaceholder = createFrameSpaceholder(frame); + add(frameSpaceholder, BorderLayout.CENTER); + } + + protected JComponent createControlPanel() { + Box controlPanel = Box.createVerticalBox(); + controlPanel.setBorder(new EmptyBorder(8, 8, 8, 8)); + + // Create button to control visibility of frame + JButton showButton = new JButton("Show JFrame..."); + showButton.addActionListener(new ShowActionListener()); + controlPanel.add(showButton); + + // Create checkbox to control busy state of frame + JCheckBox busyCheckBox = new JCheckBox("Frame busy"); + busyCheckBox.setSelected(false); + busyCheckBox.addChangeListener(new BusyChangeListener()); + controlPanel.add(busyCheckBox); + + return controlPanel; + } + + private static JComponent createFrameSpaceholder(JFrame frame) { + JPanel framePlaceholder = new JPanel(); + Dimension prefSize = frame.getPreferredSize(); + prefSize.width += 12; + prefSize.height += 12; + framePlaceholder.setPreferredSize(prefSize); + + return framePlaceholder; + } + + private static JFrame createFrame() { + + //Create frame and set simple properties + JFrame frame = new JFrame("Demo JFrame"); + frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); + // + + //Set Minimized/titlebar icon Image + //Note: How the image is used is platform-dependent + Image iconImage = null; + try { + // todo: swingingduke.gif doesn't exist + URL imageURL = FrameDemo.class.getResource("resources/images/swingingduke.gif"); + iconImage = ImageIO.read(imageURL); + } catch (Exception e) { + // handle image IO exception + } + frame.setIconImage(iconImage); + // + + //Make toplevel "busy" + // busy glasspane is initially invisible + frame.setGlassPane(new BusyGlass()); + // + + //Add a menubar + JMenuBar menubar = new JMenuBar(); + frame.setJMenuBar(menubar); + JMenu menu = new JMenu("File"); + menubar.add(menu); + menu.add("Open"); + menu.add("Save"); + // + + //Add a horizontal toolbar + JToolBar toolbar = new JToolBar(); + frame.add(toolbar, BorderLayout.NORTH); + toolbar.add(new JButton("Toolbar Button")); + // + + //Add the content area + JLabel label = new JLabel("I'm content but a little blue."); + label.setHorizontalAlignment(JLabel.CENTER); + label.setPreferredSize(new Dimension(300, 160)); + label.setBackground(new Color(197, 216, 236)); + label.setOpaque(true); // labels non-opaque by default + frame.add(label); + //snip + + //Add a statusbar + JLabel statusLabel = new JLabel("I show status."); + statusLabel.setBorder(new EmptyBorder(4, 4, 4, 4)); + statusLabel.setHorizontalAlignment(JLabel.LEADING); + frame.add(statusLabel, BorderLayout.SOUTH); + // + + //Initialize frame's size to fit it's content + frame.pack(); + // + + return frame; + } + + public void start() { + DemoUtilities.setToplevelLocation(frame, frameSpaceholder, SwingConstants.CENTER); + showFrame(); + } + + public void stop() { + //Hide frame + frame.setVisible(false); + // + } + + public void showFrame() { + //Show frame + // if frame already visible, then bring to the front + if (frame.isShowing()) { + frame.toFront(); + } else { + frame.setVisible(true); + } + // + } + + //Make toplevel "busy" + public void setFrameBusy(boolean busy) { + frame.getGlassPane().setVisible(busy); + // Must explicitly disable the menubar because on OSX it will be + // in the system menubar and not covered by the glasspane + frame.getJMenuBar().setEnabled(!busy); + } + + public boolean isFrameBusy() { + return frame.getGlassPane().isVisible(); + } + // -->

Show how Swing's top-level GUI container, JFrame, can be used to build primary application windows which contain a menubar, toolbar, statusbar, and a content area. Additionally, a glass pane can be easily overlaid on top to implement transparent overlay effects.

For more information on using JFrames, see The Java Tutorial: JFrame trail.

\ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/frame/resources/images/FrameDemo.gif b/swingset3/com/sun/swingset3/demos/frame/resources/images/FrameDemo.gif new file mode 100644 index 0000000..e5eadb3 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/frame/resources/images/FrameDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/gridbaglayout/Calculator.java b/swingset3/com/sun/swingset3/demos/gridbaglayout/Calculator.java new file mode 100644 index 0000000..c830306 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/gridbaglayout/Calculator.java @@ -0,0 +1,438 @@ +/* + * 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.demos.gridbaglayout; + +import java.awt.*; +import java.awt.event.*; +import java.util.HashMap; +import java.util.Map; +import javax.swing.*; + +/** + * Calculator + * + * @author Pavel Porvatov + */ +public class Calculator extends JComponent { + private static final String ZERO = "0"; + + private static final char DECIMAL_SEPARATOR = ','; + + private final JTextField tfScreen = new JTextField(); + + private enum State { + INPUT_X, + INPUT_X_FINISHED, + INPUT_Y, + INPUT_Y_FINISHED + } + + private enum Operator { + ADDITION, + SUBTRACTION, + MULTIPLICATION, + DIVISION, + SQRT, + INVERSE, + EQUALS + } + + private final Map keyMapping = new HashMap(); + + private String operand_x; + + private Operator operator; + + private State state; + + public Calculator() { + keyMapping.put('/', Operator.DIVISION); + keyMapping.put('*', Operator.MULTIPLICATION); + keyMapping.put('+', Operator.ADDITION); + keyMapping.put('-', Operator.SUBTRACTION); + keyMapping.put('\n', Operator.EQUALS); + + initUI(); + + addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + char c = e.getKeyChar(); + + if (Character.isDigit(c)) { + doProcessChar(c); + } else if (c == '.' || c == ',') { + doProcessChar(DECIMAL_SEPARATOR); + } else { + Operator operator = keyMapping.get(c); + + if (operator != null) { + doProcessOperator(operator); + } + } + } + + public void keyPressed(KeyEvent e) { + switch (e.getKeyCode()) { + case KeyEvent.VK_BACK_SPACE: + doProcessBackspace(); + + break; + + case KeyEvent.VK_DELETE: + doReset(); + } + } + }); + + doReset(); + } + + private void initUI() { + tfScreen.setHorizontalAlignment(JTextField.RIGHT); + + JButton btnBackspace = new JButton("Backspace"); + + btnBackspace.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doProcessBackspace(); + } + }); + + JButton btnReset = new JButton("C"); + + btnReset.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doReset(); + } + }); + + JPanel pnGridPanel = new JPanel(new GridLayout(1, 2, 8, 8)); + + pnGridPanel.add(btnBackspace); + pnGridPanel.add(btnReset); + + setLayout(new GridBagLayout()); + + JButton btnSwapSign = new SquareButton("+/-"); + + btnSwapSign.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doSwapSign(); + } + }); + + addComp(tfScreen, 0, 0, 5, 1); + addComp(pnGridPanel, 0, 1, 5, 1); + + addComp(new CharButton('7'), 0, 2, 1, 1); + addComp(new CharButton('8'), 1, 2, 1, 1); + addComp(new CharButton('9'), 2, 2, 1, 1); + addComp(new OperatorButton(Operator.DIVISION, "/"), 3, 2, 1, 1); + addComp(new OperatorButton(Operator.INVERSE, "1/x"), 4, 2, 1, 1); + + addComp(new CharButton('4'), 0, 3, 1, 1); + addComp(new CharButton('5'), 1, 3, 1, 1); + addComp(new CharButton('6'), 2, 3, 1, 1); + addComp(new OperatorButton(Operator.MULTIPLICATION, "*"), 3, 3, 1, 1); + addComp(new OperatorButton(Operator.SQRT, "sqrt"), 4, 3, 1, 1); + + addComp(new CharButton('1'), 0, 4, 1, 1); + addComp(new CharButton('2'), 1, 4, 1, 1); + addComp(new CharButton('3'), 2, 4, 1, 1); + addComp(new OperatorButton(Operator.SUBTRACTION, "-"), 3, 4, 1, 1); + + addComp(new CharButton('0'), 0, 5, 1, 1); + addComp(btnSwapSign, 1, 5, 1, 1); + addComp(new CharButton(DECIMAL_SEPARATOR), 2, 5, 1, 1); + addComp(new OperatorButton(Operator.ADDITION, "+"), 3, 5, 1, 1); + addComp(new OperatorButton(Operator.EQUALS, "="), 4, 5, 1, 1); + + // Set focusable false + resetFocusable(this); + + setFocusable(true); + } + + private static void resetFocusable(Component component) { + component.setFocusable(false); + + if (component instanceof Container) { + for (Component c : ((Container) component).getComponents()) { + resetFocusable(c); + } + } + } + + private void doReset() { + operand_x = null; + operator = null; + state = State.INPUT_X; + + tfScreen.setText(ZERO); + } + + private void doProcessChar(char c) { + String text = tfScreen.getText(); + + String newValue; + + if (state == State.INPUT_X || state == State.INPUT_Y) { + newValue = attachChar(text, c); + + if (stringToValue(newValue) == null) { + return; + } + } else { + newValue = attachChar("0", c); + + if (stringToValue(newValue) == null) { + return; + } + + if (operator == null) { + operand_x = null; + + state = State.INPUT_X; + } else { + operand_x = text; + + state = State.INPUT_Y; + } + } + + tfScreen.setText(newValue); + } + + private static String attachChar(String s, char c) { + if (Character.isDigit(c)) { + if (s.equals(ZERO)) { + return Character.toString(c); + } + + if (s.equals("-" + ZERO)) { + return "-" + Character.toString(c); + } + + return s + Character.toString(c); + } else { + return s + Character.toString(c); + } + } + + private void doSwapSign() { + String text = tfScreen.getText(); + + tfScreen.setText(text.startsWith("-") ? text.substring(1) : "-" + text); + } + + private void doProcessBackspace() { + String text = tfScreen.getText(); + + if (text.length() > 0) { + text = text.substring(0, text.length() - 1); + } + + if (text.length() == 0 || text.equals("-")) { + text = ZERO; + } + + if (stringToValue(text) != null) { + tfScreen.setText(text); + } + } + + private void doProcessOperator(Operator operator) { + double y = stringToValue(tfScreen.getText()); + + // Process unary operators + boolean isUnary; + + switch (operator) { + case SQRT: + tfScreen.setText(valueToString(Math.sqrt(y))); + + isUnary = true; + + break; + + case INVERSE: + tfScreen.setText(valueToString(1 / y)); + + isUnary = true; + + break; + + default: + isUnary = false; + } + + if (isUnary) { + if (state == State.INPUT_X) { + state = State.INPUT_X_FINISHED; + } + + if (state == State.INPUT_Y) { + state = State.INPUT_Y_FINISHED; + } + + return; + } + + // Process binary operators + if (state == State.INPUT_Y || state == State.INPUT_Y_FINISHED) { + double x = stringToValue(operand_x); + double result; + + switch (this.operator) { + case ADDITION: + result = x + y; + + break; + + case SUBTRACTION: + result = x - y; + + break; + + case MULTIPLICATION: + result = x * y; + + break; + + case DIVISION: + result = x / y; + + break; + + default: + throw new IllegalStateException("Unsupported operation " + operator); + } + + tfScreen.setText(valueToString(result)); + } + + this.operator = operator == Operator.EQUALS ? null : operator; + operand_x = null; + + state = State.INPUT_X_FINISHED; + } + + private static Double stringToValue(String value) { + try { + return new Double(value.replace(DECIMAL_SEPARATOR, '.')); + } catch (NumberFormatException e) { + // Continue convertion + } + + if (value.endsWith(String.valueOf(DECIMAL_SEPARATOR))) { + try { + // Try convert uncompleted value + return new Double(value.substring(0, value.length() - 1)); + } catch (NumberFormatException e) { + // Continue convertion + } + } + + return null; + } + + private static String valueToString(Double value) { + if (value == null) { + return ZERO; + } else { + String result = value.toString(); + + if (result.endsWith(".0")) { + result = result.substring(0, result.length() - 2); + } + + if (result.equals("-0")) { + result = ZERO; + } + + return result; + } + } + + private void addComp(Component comp, int gridx, int gridy, + int gridwidth, int gridheight) { + add(comp, new GridBagConstraints(gridx, gridy, gridwidth, gridheight, + 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(4, 4, 4, 4), 0, 0)); + } + + private static class SquareButton extends JButton { + private SquareButton(String text) { + super(text); + + setMargin(new Insets(2, 0, 2, 0)); + } + + public Dimension getMinimumSize() { + Dimension result = super.getMinimumSize(); + + if (result.width < result.height) { + result.width = result.height; + } + + return result; + } + + public Dimension getPreferredSize() { + return getMinimumSize(); + } + } + + private class CharButton extends SquareButton { + private CharButton(final char c) { + super(String.valueOf(c)); + + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doProcessChar(c); + } + }); + } + } + + private class OperatorButton extends SquareButton { + private OperatorButton(final Operator operator, String text) { + super(text); + + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doProcessOperator(operator); + } + }); + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java b/swingset3/com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java new file mode 100644 index 0000000..48a38f4 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java @@ -0,0 +1,98 @@ +/* + * 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.demos.gridbaglayout; + +import java.awt.*; +import javax.swing.*; + +import com.sun.swingset3.demos.JGridPanel; +import com.sun.swingset3.demos.ResourceManager; +import com.sun.swingset3.DemoProperties; + +/** + * GridBagLayout Demo + * + * @author Pavel Porvatov + */ +@DemoProperties( + value = "GridBagLayout Demo", + category = "Containers", + description = "Demonstrates GridBagLayout, a layout which allows to arrange components in containers.", + sourceFiles = { + "com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java", + "com/sun/swingset3/demos/gridbaglayout/Calculator.java", + "com/sun/swingset3/demos/JGridPanel.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties", + "com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif" + } +) +public class GridBagLayoutDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final JLabel lbCaption = new JLabel("" + + resourceManager.getString("GridBagLayoutDemo.caption.text") + ""); + + private final Calculator calculator = new Calculator(); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(GridBagLayoutDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new GridBagLayoutDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public GridBagLayoutDemo() { + setLayout(new BorderLayout()); + + initUI(); + } + + private void initUI() { + JGridPanel pnContent = new JGridPanel(1, 0, 2); + + pnContent.setBorderEqual(10); + + pnContent.cell(lbCaption, JGridPanel.Layout.FILL). + cell(). + cell(calculator, JGridPanel.Layout.CENTER, JGridPanel.Layout.FIRST). + cell(); + + add(pnContent); + } +} diff --git a/swingset3/com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties b/swingset3/com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties new file mode 100644 index 0000000..edde5d8 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties @@ -0,0 +1,4 @@ +### GridBagLayout Demo ### + +GridBagLayoutDemo.caption.text = This calculator uses the GridBagLayout layout manager to arrange components. \ + GridBagLayout is very useful when you need to place components in a grid of rows and columns. diff --git a/swingset3/com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif b/swingset3/com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif new file mode 100644 index 0000000..3177087 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java b/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java new file mode 100644 index 0000000..e2194cf --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/internalframe/InternalFrameDemo.java @@ -0,0 +1,360 @@ +/* + * 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.demos.internalframe; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import javax.swing.*; + +import javax.swing.border.EmptyBorder; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + + +/** + * Internal Frames Demo + * + * @version 1.16 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JInternalFrame Demo", + category = "Containers", + description = "Demonstrates JInternalFrame, a frame which can be embedded within another container to" + + "implement an MDI style interface.", + sourceFiles = { + "com/sun/swingset3/demos/internalframe/InternalFrameDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties", + "com/sun/swingset3/demos/internalframe/resources/images/bananas.png", + "com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png", + "com/sun/swingset3/demos/internalframe/resources/images/globe.png", + "com/sun/swingset3/demos/internalframe/resources/images/globe_small.png", + "com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif", + "com/sun/swingset3/demos/internalframe/resources/images/package.png", + "com/sun/swingset3/demos/internalframe/resources/images/package_small.png", + "com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png", + "com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png" + } +) +public class InternalFrameDemo extends JPanel { + private static final Dimension HGAP5 = new Dimension(5, 1); + private static final Dimension VGAP10 = new Dimension(1, 10); + private static final Dimension HGAP15 = new Dimension(15, 1); + private static final Dimension VGAP15 = new Dimension(1, 15); + + private static final int PALETTE_X = 20; + private static final int PALETTE_Y = 20; + + private static final int PALETTE_WIDTH = 250; + private static final int PALETTE_HEIGHT = 250; + + private static final int FRAME0_X = PALETTE_X + PALETTE_WIDTH + 20; + private static final int FRAME0_Y = 20; + + private static final int FRAME0_WIDTH = 300; + private static final int FRAME0_HEIGHT = 300; + + private static final int FRAME_WIDTH = 300; + private static final int FRAME_HEIGHT = 300; + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private int windowCount = 0; + private JDesktopPane desktop = null; + + private final ImageIcon icon1; + private final ImageIcon icon2; + private final ImageIcon icon3; + private final ImageIcon icon4; + private final ImageIcon smIcon1; + private final ImageIcon smIcon2; + private final ImageIcon smIcon3; + private final ImageIcon smIcon4; + + private final Integer DEMO_FRAME_LAYER = new Integer(2); + private final Integer PALETTE_LAYER = new Integer(3); + + private JCheckBox windowResizable = null; + private JCheckBox windowClosable = null; + private JCheckBox windowIconifiable = null; + private JCheckBox windowMaximizable = null; + + private JTextField windowTitleField = null; + private JLabel windowTitleLabel = null; + + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(InternalFrameDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new InternalFrameDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * InternalFrameDemo Constructor + */ + public InternalFrameDemo() { + setLayout(new BorderLayout()); + + // preload all the icons we need for this demo + icon1 = resourceManager.createImageIcon("bananas.png", + resourceManager.getString("InternalFrameDemo.bananas")); + icon2 = resourceManager.createImageIcon("globe.png", + resourceManager.getString("InternalFrameDemo.globe")); + icon3 = resourceManager.createImageIcon("package.png", + resourceManager.getString("InternalFrameDemo.package")); + icon4 = resourceManager.createImageIcon("soccer_ball.png", + resourceManager.getString("InternalFrameDemo.soccerball")); + + smIcon1 = resourceManager.createImageIcon("bananas_small.png", + resourceManager.getString("InternalFrameDemo.bananas")); + smIcon2 = resourceManager.createImageIcon("globe_small.png", + resourceManager.getString("InternalFrameDemo.globe")); + smIcon3 = resourceManager.createImageIcon("package_small.png", + resourceManager.getString("InternalFrameDemo.package")); + smIcon4 = resourceManager.createImageIcon("soccer_ball_small.png", + resourceManager.getString("InternalFrameDemo.soccerball")); + + //Create desktop pane + // The desktop pane will contain all the internal frames + desktop = new JDesktopPane(); + add(desktop, BorderLayout.CENTER); + // + + // Create the "frame maker" palette + createInternalFramePalette(); + + // Create an initial internal frame to show + JInternalFrame frame1 = createInternalFrame(icon2, DEMO_FRAME_LAYER, 1, 1); + frame1.setBounds(FRAME0_X, FRAME0_Y, FRAME0_WIDTH, FRAME0_HEIGHT); + + } + + + /** + * Create an internal frame and add a scrollable imageicon to it + */ + private JInternalFrame createInternalFrame(Icon icon, Integer layer, int width, int height) { + //Create internal frame + JInternalFrame internalFrame = new JInternalFrame(); + // + + if (!windowTitleField.getText().equals(resourceManager.getString("InternalFrameDemo.frame_label"))) { + internalFrame.setTitle(windowTitleField.getText() + " "); + } else { + internalFrame = new JInternalFrame( + resourceManager.getString("InternalFrameDemo.frame_label") + " " + windowCount + " "); + } + + //Set internal frame properties + internalFrame.setClosable(windowClosable.isSelected()); + internalFrame.setMaximizable(windowMaximizable.isSelected()); + internalFrame.setIconifiable(windowIconifiable.isSelected()); + internalFrame.setResizable(windowResizable.isSelected()); + // + + internalFrame.setBounds(FRAME0_X + 20 * (windowCount % 10), + FRAME0_Y + 20 * (windowCount % 10), width, height); + internalFrame.setContentPane(new ImageScroller(icon)); + + windowCount++; + + //Add internal frame to desktop pane + desktop.add(internalFrame, layer); + // + + //Set internal frame to be active + try { + internalFrame.setSelected(true); + } catch (java.beans.PropertyVetoException e2) { + } + // + + internalFrame.show(); + + return internalFrame; + } + + private void createInternalFramePalette() { + JInternalFrame palette = new JInternalFrame( + resourceManager.getString("InternalFrameDemo.palette_label") + ); + palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); + palette.getContentPane().setLayout(new BorderLayout()); + palette.setBounds(PALETTE_X, PALETTE_Y, PALETTE_WIDTH, PALETTE_HEIGHT); + palette.setResizable(true); + palette.setIconifiable(true); + desktop.add(palette, PALETTE_LAYER); + + // ************************************* + // * Create create frame maker buttons * + // ************************************* + JButton b1 = new JButton(smIcon1); + JButton b2 = new JButton(smIcon2); + JButton b3 = new JButton(smIcon3); + JButton b4 = new JButton(smIcon4); + + // add frame maker actions + b1.addActionListener(new CreateFrameAction(this, icon1)); + b2.addActionListener(new CreateFrameAction(this, icon2)); + b3.addActionListener(new CreateFrameAction(this, icon3)); + b4.addActionListener(new CreateFrameAction(this, icon4)); + + // add frame maker buttons to panel + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + + JPanel buttons1 = new JPanel(); + buttons1.setLayout(new BoxLayout(buttons1, BoxLayout.X_AXIS)); + + JPanel buttons2 = new JPanel(); + buttons2.setLayout(new BoxLayout(buttons2, BoxLayout.X_AXIS)); + + buttons1.add(b1); + buttons1.add(Box.createRigidArea(HGAP15)); + buttons1.add(b2); + + buttons2.add(b3); + buttons2.add(Box.createRigidArea(HGAP15)); + buttons2.add(b4); + + p.add(Box.createRigidArea(VGAP10)); + p.add(buttons1); + p.add(Box.createRigidArea(VGAP15)); + p.add(buttons2); + p.add(Box.createRigidArea(VGAP10)); + + palette.getContentPane().add(p, BorderLayout.NORTH); + + // ************************************ + // * Create frame property checkboxes * + // ************************************ + p = new JPanel(); + p.setBorder(new EmptyBorder(10, 15, 10, 5)); + p.setLayout(new GridLayout(1, 2)); + + + Box box = new Box(BoxLayout.Y_AXIS); + windowResizable = new JCheckBox(resourceManager.getString("InternalFrameDemo.resizable_label"), true); + windowIconifiable = new JCheckBox(resourceManager.getString("InternalFrameDemo.iconifiable_label"), true); + + box.add(Box.createGlue()); + box.add(windowResizable); + box.add(windowIconifiable); + box.add(Box.createGlue()); + p.add(box); + + box = new Box(BoxLayout.Y_AXIS); + windowClosable = new JCheckBox(resourceManager.getString("InternalFrameDemo.closable_label"), true); + windowMaximizable = new JCheckBox(resourceManager.getString("InternalFrameDemo.maximizable_label"), true); + + box.add(Box.createGlue()); + box.add(windowClosable); + box.add(windowMaximizable); + box.add(Box.createGlue()); + p.add(box); + + palette.getContentPane().add(p, BorderLayout.CENTER); + + // ************************************ + // * Create Frame title textfield * + // ************************************ + p = new JPanel(); + p.setBorder(new EmptyBorder(0, 0, 10, 0)); + + windowTitleField = new JTextField(resourceManager.getString("InternalFrameDemo.frame_label")); + windowTitleLabel = new JLabel(resourceManager.getString("InternalFrameDemo.title_text_field_label")); + + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.add(Box.createRigidArea(HGAP5)); + p.add(windowTitleLabel, BorderLayout.WEST); + p.add(Box.createRigidArea(HGAP5)); + p.add(windowTitleField, BorderLayout.CENTER); + p.add(Box.createRigidArea(HGAP5)); + + palette.getContentPane().add(p, BorderLayout.SOUTH); + + palette.show(); + } + + + private class CreateFrameAction extends AbstractAction { + final InternalFrameDemo demo; + final Icon icon; + + public CreateFrameAction(InternalFrameDemo demo, Icon icon) { + this.demo = demo; + this.icon = icon; + } + + public void actionPerformed(ActionEvent e) { + demo.createInternalFrame(icon, + DEMO_FRAME_LAYER, + FRAME_WIDTH, + FRAME_HEIGHT + ); + } + } + + private static class ImageScroller extends JScrollPane { + + public ImageScroller(Icon icon) { + super(); + JPanel p = new JPanel(); + p.setBackground(Color.white); + p.setLayout(new BorderLayout()); + + p.add(new JLabel(icon), BorderLayout.CENTER); + + getViewport().add(p); + getHorizontalScrollBar().setUnitIncrement(10); + getVerticalScrollBar().setUnitIncrement(10); + } + + public Dimension getMinimumSize() { + return new Dimension(25, 25); + } + + } +} diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties b/swingset3/com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties new file mode 100644 index 0000000..8758f02 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/internalframe/resources/InternalFrameDemo.properties @@ -0,0 +1,17 @@ +### Internal Frame Demo ### + +InternalFrameDemo.accessible_description=JInternal Frame Demo +InternalFrameDemo.create_frames_label=Create Customized Internal Frames +InternalFrameDemo.title_text_field_label=Frame title: +InternalFrameDemo.frame_label=Frame +InternalFrameDemo.palette_label=Internal Frame Generator +InternalFrameDemo.name=Internal Frames Demo +InternalFrameDemo.tooltip=JInternalFrame demo +InternalFrameDemo.closable_label=Closable +InternalFrameDemo.resizable_label=Resizable +InternalFrameDemo.iconifiable_label=Iconifiable +InternalFrameDemo.maximizable_label=Maximizable +InternalFrameDemo.bananas=Go Bananas +InternalFrameDemo.globe=Spinning Globe +InternalFrameDemo.package=Gift for you +InternalFrameDemo.soccerball=Soccer anyone? \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif new file mode 100644 index 0000000..7db8282 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/InternalFrameDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/bananas.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/bananas.png new file mode 100644 index 0000000..b05423b Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/bananas.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png new file mode 100644 index 0000000..59faaed Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/bananas_small.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/globe.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/globe.png new file mode 100644 index 0000000..0d733e2 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/globe.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/globe_small.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/globe_small.png new file mode 100644 index 0000000..918f8f2 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/globe_small.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/package.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/package.png new file mode 100644 index 0000000..8c9c056 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/package.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/package_small.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/package_small.png new file mode 100644 index 0000000..048ac0e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/package_small.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png new file mode 100644 index 0000000..7cae82a Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball.png differ diff --git a/swingset3/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png new file mode 100644 index 0000000..a02e8fc Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/internalframe/resources/images/soccer_ball_small.png differ diff --git a/swingset3/com/sun/swingset3/demos/list/ListDemo.java b/swingset3/com/sun/swingset3/demos/list/ListDemo.java new file mode 100644 index 0000000..7c32f10 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/list/ListDemo.java @@ -0,0 +1,399 @@ +/* + * 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.demos.list; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.Vector; +import javax.swing.*; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * List Demo. This demo shows that it is not + * always necessary to have an array of objects + * as big as the size of the list stored. + * + * Indeed, in this example, there is no array + * kept for the list data, rather it is generated + * on the fly as only those elements are needed. + * + * @version 1.17 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JList Demo", + category = "Data", + description = "Demonstrates JList, a component which supports display/editing of a data list", + sourceFiles = { + "com/sun/swingset3/demos/list/ListDemo.java", + "com/sun/swingset3/demos/list/Permuter.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/list/resources/ListDemo.properties", + "com/sun/swingset3/demos/list/resources/images/blue.gif", + "com/sun/swingset3/demos/list/resources/images/cyan.gif", + "com/sun/swingset3/demos/list/resources/images/gray.gif", + "com/sun/swingset3/demos/list/resources/images/green.gif", + "com/sun/swingset3/demos/list/resources/images/ListDemo.gif", + "com/sun/swingset3/demos/list/resources/images/magenta.gif", + "com/sun/swingset3/demos/list/resources/images/red.gif", + "com/sun/swingset3/demos/list/resources/images/yellow.gif" + } +) +public class ListDemo extends JPanel { + private static final Dimension HGAP10 = new Dimension(10, 1); + private static final Dimension VGAP10 = new Dimension(1, 10); + private static final Dimension HGAP15 = new Dimension(15, 1); + private static final Dimension HGAP30 = new Dimension(30, 1); + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final JList list; + + private JPanel prefixList; + private JPanel suffixList; + + private Action prefixAction; + private Action suffixAction; + + private final GeneratedListModel listModel; + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ListDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ListDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * ListDemo Constructor + */ + public ListDemo() { + setLayout(new BorderLayout()); + + loadImages(); + + JLabel description = new JLabel(resourceManager.getString("ListDemo.description")); + add(description, BorderLayout.NORTH); + + JPanel centerPanel = new JPanel(); + centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.X_AXIS)); + centerPanel.add(Box.createRigidArea(HGAP10)); + add(centerPanel, BorderLayout.CENTER); + + JPanel listPanel = new JPanel(); + listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS)); + listPanel.add(Box.createRigidArea(VGAP10)); + + centerPanel.add(listPanel); + centerPanel.add(Box.createRigidArea(HGAP30)); + + // Create the list + list = new JList(); + list.setCellRenderer(new CompanyLogoListCellRenderer()); + listModel = new GeneratedListModel(); + list.setModel(listModel); + + // Set the preferred row count. This affects the preferredSize + // of the JList when it's in a scrollpane. + list.setVisibleRowCount(22); + + // Add list to a scrollpane + JScrollPane scrollPane = new JScrollPane(list); + listPanel.add(scrollPane); + listPanel.add(Box.createRigidArea(VGAP10)); + + // Add the control panel (holds the prefix/suffix list and prefix/suffix checkboxes) + centerPanel.add(createControlPanel()); + + // create prefixes and suffixes + addPrefix("Tera", true); + addPrefix("Micro", false); + addPrefix("Southern", false); + addPrefix("Net", true); + addPrefix("YoYo", true); + addPrefix("Northern", false); + addPrefix("Tele", false); + addPrefix("Eastern", false); + addPrefix("Neo", false); + addPrefix("Digi", false); + addPrefix("National", false); + addPrefix("Compu", true); + addPrefix("Meta", true); + addPrefix("Info", false); + addPrefix("Western", false); + addPrefix("Data", false); + addPrefix("Atlantic", false); + addPrefix("Advanced", false); + addPrefix("Euro", false); + addPrefix("Pacific", false); + addPrefix("Mobile", false); + addPrefix("In", false); + addPrefix("Computa", false); + addPrefix("Digital", false); + addPrefix("Analog", false); + + addSuffix("Tech", true); + addSuffix("Soft", true); + addSuffix("Telecom", true); + addSuffix("Solutions", false); + addSuffix("Works", true); + addSuffix("Dyne", false); + addSuffix("Services", false); + addSuffix("Vers", false); + addSuffix("Devices", false); + addSuffix("Software", false); + addSuffix("Serv", false); + addSuffix("Systems", true); + addSuffix("Dynamics", true); + addSuffix("Net", false); + addSuffix("Sys", false); + addSuffix("Computing", false); + addSuffix("Scape", false); + addSuffix("Com", false); + addSuffix("Ware", false); + addSuffix("Widgets", false); + addSuffix("Media", false); + addSuffix("Computer", false); + addSuffix("Hardware", false); + addSuffix("Gizmos", false); + addSuffix("Concepts", false); + } + + private JPanel createControlPanel() { + JPanel controlPanel = new JPanel() { + private final Insets insets = new Insets(0, 4, 10, 10); + + public Insets getInsets() { + return insets; + } + }; + controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS)); + + JPanel prefixPanel = new JPanel(); + prefixPanel.setLayout(new BoxLayout(prefixPanel, BoxLayout.Y_AXIS)); + prefixPanel.add(new JLabel(resourceManager.getString("ListDemo.prefixes"))); + + JPanel suffixPanel = new JPanel(); + suffixPanel.setLayout(new BoxLayout(suffixPanel, BoxLayout.Y_AXIS)); + suffixPanel.add(new JLabel(resourceManager.getString("ListDemo.suffixes"))); + + prefixList = new JPanel() { + private final Insets insets = new Insets(0, 4, 0, 0); + + public Insets getInsets() { + return insets; + } + }; + prefixList.setLayout(new BoxLayout(prefixList, BoxLayout.Y_AXIS)); + JScrollPane scrollPane = new JScrollPane(prefixList); + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + prefixPanel.add(scrollPane); + prefixPanel.add(Box.createRigidArea(HGAP10)); + + suffixList = new JPanel() { + private final Insets insets = new Insets(0, 4, 0, 0); + + public Insets getInsets() { + return insets; + } + }; + suffixList.setLayout(new BoxLayout(suffixList, BoxLayout.Y_AXIS)); + scrollPane = new JScrollPane(suffixList); + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + suffixPanel.add(scrollPane); + suffixPanel.add(Box.createRigidArea(HGAP10)); + + controlPanel.add(prefixPanel); + controlPanel.add(Box.createRigidArea(HGAP15)); + controlPanel.add(suffixPanel); + return controlPanel; + } + + private final FocusListener listFocusListener = new FocusAdapter() { + public void focusGained(FocusEvent e) { + JComponent c = (JComponent) e.getComponent(); + c.scrollRectToVisible(new Rectangle(0, 0, c.getWidth(), c.getHeight())); + } + }; + + private void addPrefix(String prefix, boolean selected) { + if (prefixAction == null) { + prefixAction = new UpdatePrefixListAction(listModel); + } + final JCheckBox cb = (JCheckBox) prefixList.add(new JCheckBox(prefix)); + cb.setSelected(selected); + cb.addActionListener(prefixAction); + if (selected) { + listModel.addPrefix(prefix); + } + cb.addFocusListener(listFocusListener); + } + + private void addSuffix(String suffix, boolean selected) { + if (suffixAction == null) { + suffixAction = new UpdateSuffixListAction(listModel); + } + final JCheckBox cb = (JCheckBox) suffixList.add(new JCheckBox(suffix)); + cb.setSelected(selected); + cb.addActionListener(suffixAction); + if (selected) { + listModel.addSuffix(suffix); + } + cb.addFocusListener(listFocusListener); + } + + private static class UpdatePrefixListAction extends AbstractAction { + private final GeneratedListModel listModel; + + protected UpdatePrefixListAction(GeneratedListModel listModel) { + this.listModel = listModel; + } + + public void actionPerformed(ActionEvent e) { + JCheckBox cb = (JCheckBox) e.getSource(); + if (cb.isSelected()) { + listModel.addPrefix(cb.getText()); + } else { + listModel.removePrefix(cb.getText()); + } + } + } + + private static class UpdateSuffixListAction extends AbstractAction { + private final GeneratedListModel listModel; + + protected UpdateSuffixListAction(GeneratedListModel listModel) { + this.listModel = listModel; + } + + public void actionPerformed(ActionEvent e) { + JCheckBox cb = (JCheckBox) e.getSource(); + if (cb.isSelected()) { + listModel.addSuffix(cb.getText()); + } else { + listModel.removeSuffix(cb.getText()); + } + } + } + + + private static class GeneratedListModel extends AbstractListModel { + private Permuter permuter; + + private final Vector prefix = new Vector(); + private final Vector suffix = new Vector(); + + private void update() { + permuter = new Permuter(getSize()); + fireContentsChanged(this, 0, getSize()); + } + + public void addPrefix(String s) { + if (!prefix.contains(s)) { + prefix.addElement(s); + update(); + } + } + + public void removePrefix(String s) { + prefix.removeElement(s); + update(); + } + + public void addSuffix(String s) { + if (!suffix.contains(s)) { + suffix.addElement(s); + update(); + } + } + + public void removeSuffix(String s) { + suffix.removeElement(s); + update(); + } + + public int getSize() { + return prefix.size() * suffix.size(); + } + + public Object getElementAt(int index) { + if (permuter == null) { + update(); + } + // morph the index to another int -- this has the benefit of + // causing the list to look random. + int j = permuter.map(index); + int ps = prefix.size(); + int ss = suffix.size(); + return prefix.elementAt(j % ps) + suffix.elementAt((j / ps) % ss); + } + } + + private final ImageIcon[] images = new ImageIcon[7]; + + void loadImages() { + images[0] = resourceManager.createImageIcon("red.gif", resourceManager.getString("ListDemo.red")); + images[1] = resourceManager.createImageIcon("blue.gif", resourceManager.getString("ListDemo.blue")); + images[2] = resourceManager.createImageIcon("yellow.gif", resourceManager.getString("ListDemo.yellow")); + images[3] = resourceManager.createImageIcon("green.gif", resourceManager.getString("ListDemo.green")); + images[4] = resourceManager.createImageIcon("gray.gif", resourceManager.getString("ListDemo.gray")); + images[5] = resourceManager.createImageIcon("cyan.gif", resourceManager.getString("ListDemo.cyan")); + images[6] = resourceManager.createImageIcon("magenta.gif", resourceManager.getString("ListDemo.magenta")); + } + + private class CompanyLogoListCellRenderer extends DefaultListCellRenderer { + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + Component retValue = super.getListCellRendererComponent( + list, value, index, isSelected, cellHasFocus + ); + setIcon(images[index % 7]); + return retValue; + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/list/Permuter.java b/swingset3/com/sun/swingset3/demos/list/Permuter.java new file mode 100644 index 0000000..6da0a52 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/list/Permuter.java @@ -0,0 +1,109 @@ +/* + * 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.demos.list; + +/** + * An object that implements a cheesy pseudorandom permutation of the integers + * from zero to some user-specified value. (The permutation is a linear + * function.) + * + * @version 1.9 11/17/05 + * @author Josh Bloch + */ +class Permuter { + /** + * The size of the permutation. + */ + private int modulus; + + /** + * Nonnegative integer less than n that is relatively prime to m. + */ + private int multiplier; + + /** + * Pseudorandom nonnegative integer less than n. + */ + private static final int ADDEND = 22; + + public Permuter(int n) { + if (n < 0) { + throw new IllegalArgumentException(); + } + modulus = n; + if (n == 1) { + return; + } + + // Initialize the multiplier and offset + multiplier = (int) Math.sqrt(n); + while (gcd(multiplier, n) != 1) { + if (++multiplier == n) { + multiplier = 1; + } + } + } + + /** + * Returns the integer to which this permuter maps the specified integer. + * The specified integer must be between 0 and n-1, and the returned + * integer will be as well. + */ + public int map(int i) { + return (multiplier * i + ADDEND) % modulus; + } + + /** + * Calculate GCD of a and b, which are assumed to be non-negative. + */ + private static int gcd(int a, int b) { + while (b != 0) { + int tmp = a % b; + a = b; + b = tmp; + } + return a; + } + + /** + * Simple test. Takes modulus on command line and prints out permutation. + */ + public static void main(String[] args) { + int modulus = Integer.parseInt(args[0]); + Permuter p = new Permuter(modulus); + for (int i = 0; i < modulus; i++) { + System.out.print(p.map(i) + " "); + } + System.out.println(); + } +} + diff --git a/swingset3/com/sun/swingset3/demos/list/resources/ListDemo.properties b/swingset3/com/sun/swingset3/demos/list/resources/ListDemo.properties new file mode 100644 index 0000000..197cb7f --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/list/resources/ListDemo.properties @@ -0,0 +1,18 @@ +### List Demo ### + +ListDemo.accessible_description=JList Demo +ListDemo.name=List Demo +ListDemo.tooltip=JList demo +ListDemo.prefixes=Prefixes +ListDemo.suffixes=Suffixes +ListDemo.count_label=Number of generated list entries: +ListDemo.all=All +ListDemo.none=None +ListDemo.red=Red Company Logo Image +ListDemo.yellow=Red Company Logo Image +ListDemo.blue=Blue Company Logo Image +ListDemo.gray=Gray Company Logo Image +ListDemo.green=Green Company Logo Image +ListDemo.magenta=Magenta Company Logo Image +ListDemo.cyan=Cyan Company Logo Image +ListDemo.description=

This demo shows how to present lists of data in two different ways. On the left is a JList component whose list items consist of the permutations of the checked prefixes and suffixes. The prefix and suffix checkbox columns on the right are created by using a JPanel with a Y Axis BoxLayout inside a JScrollPane.

diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/ListDemo.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/ListDemo.gif new file mode 100644 index 0000000..d50e74f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/ListDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/blue.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/blue.gif new file mode 100644 index 0000000..0cbfc10 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/blue.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/cyan.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/cyan.gif new file mode 100644 index 0000000..1a15194 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/cyan.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/gray.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/gray.gif new file mode 100644 index 0000000..7e16831 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/gray.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/green.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/green.gif new file mode 100644 index 0000000..5613d8d Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/green.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/magenta.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/magenta.gif new file mode 100644 index 0000000..e3741ab Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/magenta.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/red.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/red.gif new file mode 100644 index 0000000..c197ffc Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/red.gif differ diff --git a/swingset3/com/sun/swingset3/demos/list/resources/images/yellow.gif b/swingset3/com/sun/swingset3/demos/list/resources/images/yellow.gif new file mode 100644 index 0000000..9baeebf Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/list/resources/images/yellow.gif differ diff --git a/swingset3/com/sun/swingset3/demos/optionpane/OptionPaneDemo.java b/swingset3/com/sun/swingset3/demos/optionpane/OptionPaneDemo.java new file mode 100644 index 0000000..2d88e01 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/optionpane/OptionPaneDemo.java @@ -0,0 +1,246 @@ +/* + * 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.demos.optionpane; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.net.URL; +import javax.swing.*; + +import com.sun.swingset3.demos.ResourceManager; +import com.sun.swingset3.DemoProperties; + +/** + * JOptionPaneDemo + * + * @author Jeff Dinkins + * @version 1.11 11/17/05 + */ +@DemoProperties( + value = "JOptionPane Demo", + category = "Choosers", + description = "Demonstrates JOptionPane, a component which displays standard message dialogs (question, warning, error, etc).", + sourceFiles = { + "com/sun/swingset3/demos/optionpane/OptionPaneDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/optionpane/resources/OptionPaneDemo.properties", + "com/sun/swingset3/demos/optionpane/resources/images/bottle.gif", + "com/sun/swingset3/demos/optionpane/resources/images/OptionPaneDemo.gif" + } +) +public class OptionPaneDemo extends JPanel { + private static final Dimension VGAP15 = new Dimension(1, 15); + private static final Dimension VGAP30 = new Dimension(1, 30); + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(OptionPaneDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new OptionPaneDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * OptionPaneDemo Constructor + */ + public OptionPaneDemo() { + setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + JPanel bp = new JPanel() { + public Dimension getMaximumSize() { + return new Dimension(getPreferredSize().width, super.getMaximumSize().height); + } + }; + bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS)); + + bp.add(Box.createRigidArea(VGAP30)); + bp.add(Box.createRigidArea(VGAP30)); + + bp.add(createInputDialogButton()); + bp.add(Box.createRigidArea(VGAP15)); + bp.add(createWarningDialogButton()); + bp.add(Box.createRigidArea(VGAP15)); + bp.add(createMessageDialogButton()); + bp.add(Box.createRigidArea(VGAP15)); + bp.add(createComponentDialogButton()); + bp.add(Box.createRigidArea(VGAP15)); + bp.add(createConfirmDialogButton()); + bp.add(Box.createVerticalGlue()); + + add(Box.createHorizontalGlue()); + add(bp); + add(Box.createHorizontalGlue()); + } + + private JButton createWarningDialogButton() { + Action a = new AbstractAction(resourceManager.getString("OptionPaneDemo.warningbutton")) { + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog( + OptionPaneDemo.this, + resourceManager.getString("OptionPaneDemo.warningtext"), + resourceManager.getString("OptionPaneDemo.warningtitle"), + JOptionPane.WARNING_MESSAGE + ); + } + }; + return createButton(a); + } + + private JButton createMessageDialogButton() { + Action a = new AbstractAction(resourceManager.getString("OptionPaneDemo.messagebutton")) { + final URL img = getClass().getResource("resources/images/bottle.gif"); + final String imagesrc = ""; + final String message = resourceManager.getString("OptionPaneDemo.messagetext"); + + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog( + OptionPaneDemo.this, + "" + imagesrc + "
" + message + "

" + ); + } + }; + return createButton(a); + } + + private JButton createConfirmDialogButton() { + Action a = new AbstractAction(resourceManager.getString("OptionPaneDemo.confirmbutton")) { + public void actionPerformed(ActionEvent e) { + int result = JOptionPane.showConfirmDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.confirmquestion")); + if (result == JOptionPane.YES_OPTION) { + JOptionPane.showMessageDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.confirmyes")); + } else if (result == JOptionPane.NO_OPTION) { + JOptionPane.showMessageDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.confirmno")); + } + } + }; + return createButton(a); + } + + private JButton createInputDialogButton() { + Action a = new AbstractAction(resourceManager.getString("OptionPaneDemo.inputbutton")) { + public void actionPerformed(ActionEvent e) { + String result = JOptionPane.showInputDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.inputquestion")); + if ((result != null) && (result.length() > 0)) { + JOptionPane.showMessageDialog(OptionPaneDemo.this, + result + ": " + + resourceManager.getString("OptionPaneDemo.inputresponse")); + } + } + }; + return createButton(a); + } + + private JButton createComponentDialogButton() { + Action a = new AbstractAction(resourceManager.getString("OptionPaneDemo.componentbutton")) { + public void actionPerformed(ActionEvent e) { + // In a ComponentDialog, you can show as many message components and + // as many options as you want: + + // Messages + Object[] message = new Object[4]; + message[0] = resourceManager.getString("OptionPaneDemo.componentmessage"); + message[1] = new JTextField(resourceManager.getString("OptionPaneDemo.componenttextfield")); + + JComboBox cb = new JComboBox(); + cb.addItem(resourceManager.getString("OptionPaneDemo.component_cb1")); + cb.addItem(resourceManager.getString("OptionPaneDemo.component_cb2")); + cb.addItem(resourceManager.getString("OptionPaneDemo.component_cb3")); + message[2] = cb; + + message[3] = resourceManager.getString("OptionPaneDemo.componentmessage2"); + + // Options + String[] options = { + resourceManager.getString("OptionPaneDemo.component_op1"), + resourceManager.getString("OptionPaneDemo.component_op2"), + resourceManager.getString("OptionPaneDemo.component_op3"), + resourceManager.getString("OptionPaneDemo.component_op4"), + resourceManager.getString("OptionPaneDemo.component_op5") + }; + int result = JOptionPane.showOptionDialog( + OptionPaneDemo.this, // the parent that the dialog blocks + message, // the dialog message array + resourceManager.getString("OptionPaneDemo.componenttitle"), // the title of the dialog window + JOptionPane.DEFAULT_OPTION, // option type + JOptionPane.INFORMATION_MESSAGE, // message type + null, // optional icon, use null to use the default icon + options, // options string array, will be made into buttons + options[3] // option that should be made into a default button + ); + switch (result) { + case 0: // yes + JOptionPane.showMessageDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.component_r1")); + break; + case 1: // no + JOptionPane.showMessageDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.component_r2")); + break; + case 2: // maybe + JOptionPane.showMessageDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.component_r3")); + break; + case 3: // probably + JOptionPane.showMessageDialog(OptionPaneDemo.this, resourceManager.getString("OptionPaneDemo.component_r4")); + break; + default: + break; + } + + } + }; + return createButton(a); + } + + private JButton createButton(Action a) { + JButton b = new JButton() { + public Dimension getMaximumSize() { + int width = Short.MAX_VALUE; + int height = super.getMaximumSize().height; + return new Dimension(width, height); + } + }; + // setting the following client property informs the button to show + // the action text as it's name. The default is to not show the + // action text. + b.putClientProperty("displayActionText", Boolean.TRUE); + b.setAction(a); + // b.setAlignmentX(JButton.CENTER_ALIGNMENT); + return b; + } + +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/optionpane/resources/OptionPaneDemo.properties b/swingset3/com/sun/swingset3/demos/optionpane/resources/OptionPaneDemo.properties new file mode 100644 index 0000000..e4cf707 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/optionpane/resources/OptionPaneDemo.properties @@ -0,0 +1,42 @@ +### OptionPane Demo ### + +OptionPaneDemo.accessible_description=The OptionPane Demo shows examples of using JOptionPane to generate different common option dialog boxes +OptionPaneDemo.tooltip=JOptionPane Demo +OptionPaneDemo.name=Option Pane Demo + +OptionPaneDemo.warningbutton=Show Warning Dialog +OptionPaneDemo.componentbutton=Show Component Dialog +OptionPaneDemo.inputbutton=Show Input Dialog +OptionPaneDemo.confirmbutton=Show Confirmation Dialog +OptionPaneDemo.messagebutton=Show Message Dialog + +OptionPaneDemo.warningtitle=Warning Dialog Example +OptionPaneDemo.warningtext=

This is a test of the Emergency Broadcast System. This is
only a test
. The webmaster of your local intranet, in voluntary
cooperation with the Federal and State authorities, have
developed this system to keep you informed in the event of an
emergency. If this had been an actual emergency, the signal you
just heard would have been followed by official information, news
or instructions. This concludes this test of the Emergency
Broadcast System
.


Developer Note: This dialog demo used HTML for text formatting.

+ +OptionPaneDemo.messagetext=Message in a Bottle (yeah) + +OptionPaneDemo.confirmquestion=Is the sun shining outside today? +OptionPaneDemo.confirmyes=Well what are you doing playing on the computer?
Get outside! Take a trip to the beach! Get a little sun! +OptionPaneDemo.confirmno=Well good thing you're inside protected from the elements! + +OptionPaneDemo.inputquestion=What is your favorite movie? +OptionPaneDemo.inputresponse=That was a pretty good movie! + +OptionPaneDemo.componenttitle=Component Dialog Example +OptionPaneDemo.componentmessage=JOptionPane can contain as many components
as you want, such as a text field: +OptionPaneDemo.componenttextfield=or a combobox: +OptionPaneDemo.component_cb1=item 1 +OptionPaneDemo.component_cb2=item 2 +OptionPaneDemo.component_cb3=item 3 +OptionPaneDemo.componentmessage2=JOptionPane can also show as many options
as you want: +OptionPaneDemo.component_op1=Yes +OptionPaneDemo.component_op2=No +OptionPaneDemo.component_op3=Maybe +OptionPaneDemo.component_op4=Probably +OptionPaneDemo.component_op5=Cancel + +OptionPaneDemo.component_r1=Upbeat and positive! I like that! Good choice. +OptionPaneDemo.component_r2=Definitely not, I wouldn't do it either. +OptionPaneDemo.component_r3= Mmmm.. yes, the situation is unclear at this
time. Check back when you know for sure.
+OptionPaneDemo.component_r4=You know you want to. I think you should
have gone for broke and pressed "Yes".
+ diff --git a/swingset3/com/sun/swingset3/demos/optionpane/resources/images/OptionPaneDemo.gif b/swingset3/com/sun/swingset3/demos/optionpane/resources/images/OptionPaneDemo.gif new file mode 100644 index 0000000..114e1ab Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/optionpane/resources/images/OptionPaneDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/optionpane/resources/images/bottle.gif b/swingset3/com/sun/swingset3/demos/optionpane/resources/images/bottle.gif new file mode 100644 index 0000000..e706c0c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/optionpane/resources/images/bottle.gif differ diff --git a/swingset3/com/sun/swingset3/demos/progressbar/ProgressBarDemo.java b/swingset3/com/sun/swingset3/demos/progressbar/ProgressBarDemo.java new file mode 100644 index 0000000..390c8b4 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/progressbar/ProgressBarDemo.java @@ -0,0 +1,200 @@ +/* + * 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.demos.progressbar; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import javax.swing.*; +import javax.swing.border.BevelBorder; +import javax.swing.border.SoftBevelBorder; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * JProgressBar Demo + * + * @version 1.12 11/17/05 + * @author Jeff Dinkins + # @author Peter Korn (accessibility support) + */ +@DemoProperties( + value = "ProgressBar Demo", + category = "Controls", + description = "Demonstrates the JProgressBar, a control which displays progress to the user", + sourceFiles = { + "com/sun/swingset3/demos/progressbar/ProgressBarDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/progressbar/resources/ProgressBarDemo.properties", + "com/sun/swingset3/demos/progressbar/resources/images/ProgressBarDemo.gif" + } +) +public class ProgressBarDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ProgressBarDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ProgressBarDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * ProgressBarDemo Constructor + */ + public ProgressBarDemo() { + createProgressPanel(); + } + + private final javax.swing.Timer timer = new javax.swing.Timer(18, createTextLoadAction()); + private Action loadAction; + private Action stopAction; + private JProgressBar progressBar; + private JTextArea progressTextArea; + + private void createProgressPanel() { + setLayout(new BorderLayout()); + + JPanel textWrapper = new JPanel(new BorderLayout()); + textWrapper.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); + textWrapper.setAlignmentX(LEFT_ALIGNMENT); + progressTextArea = new MyTextArea(); + + progressTextArea.getAccessibleContext().setAccessibleName( + resourceManager.getString("ProgressBarDemo.accessible_text_area_name")); + progressTextArea.getAccessibleContext().setAccessibleName( + resourceManager.getString("ProgressBarDemo.accessible_text_area_description")); + textWrapper.add(new JScrollPane(progressTextArea), BorderLayout.CENTER); + + add(textWrapper, BorderLayout.CENTER); + + JPanel progressPanel = new JPanel(); + add(progressPanel, BorderLayout.SOUTH); + + progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, text.length()) { + public Dimension getPreferredSize() { + return new Dimension(300, super.getPreferredSize().height); + } + }; + progressBar.getAccessibleContext().setAccessibleName( + resourceManager.getString("ProgressBarDemo.accessible_text_loading_progress")); + + progressPanel.add(progressBar); + progressPanel.add(createLoadButton()); + progressPanel.add(createStopButton()); + } + + private JButton createLoadButton() { + loadAction = new AbstractAction(resourceManager.getString("ProgressBarDemo.start_button")) { + public void actionPerformed(ActionEvent e) { + loadAction.setEnabled(false); + stopAction.setEnabled(true); + if (progressBar.getValue() == progressBar.getMaximum()) { + progressBar.setValue(0); + textLocation = 0; + progressTextArea.setText(""); + } + timer.start(); + } + }; + return createButton(loadAction); + } + + private JButton createStopButton() { + stopAction = new AbstractAction(resourceManager.getString("ProgressBarDemo.stop_button")) { + public void actionPerformed(ActionEvent e) { + timer.stop(); + loadAction.setEnabled(true); + stopAction.setEnabled(false); + } + }; + return createButton(stopAction); + } + + private static JButton createButton(Action a) { + JButton b = new JButton(); + // setting the following client property informs the button to show + // the action text as it's name. The default is to not show the + // action text. + b.putClientProperty("displayActionText", Boolean.TRUE); + b.setAction(a); + return b; + } + + + private int textLocation = 0; + + private final String text = resourceManager.getString("ProgressBarDemo.text"); + + private Action createTextLoadAction() { + return new AbstractAction("text load action") { + public void actionPerformed(ActionEvent e) { + if (progressBar.getValue() < progressBar.getMaximum()) { + progressBar.setValue(progressBar.getValue() + 1); + progressTextArea.append(text.substring(textLocation, textLocation + 1)); + textLocation++; + } else { + timer.stop(); + loadAction.setEnabled(true); + stopAction.setEnabled(false); + } + } + }; + } + + + private static class MyTextArea extends JTextArea { + private MyTextArea() { + super(null, 0, 0); + setEditable(false); + setText(""); + } + + public float getAlignmentX() { + return LEFT_ALIGNMENT; + } + + public float getAlignmentY() { + return TOP_ALIGNMENT; + } + } +} + + diff --git a/swingset3/com/sun/swingset3/demos/progressbar/resources/ProgressBarDemo.properties b/swingset3/com/sun/swingset3/demos/progressbar/resources/ProgressBarDemo.properties new file mode 100644 index 0000000..7660e0b --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/progressbar/resources/ProgressBarDemo.properties @@ -0,0 +1,35 @@ +### ProgressBar Demo ### + +ProgressBarDemo.accessible_description=This demo shows an example of using the JProgressBar component. +ProgressBarDemo.tooltip=JProgressBar demo +ProgressBarDemo.name=ProgressBar Demo +ProgressBarDemo.start_button=Start Loading Text +ProgressBarDemo.stop_button=Stop Loading Text +ProgressBarDemo.accessible_text_loading_progress=Text loading progress +ProgressBarDemo.accessible_text_area_name=Text progressively being loaded in + +ProgressBarDemo.accessible_text_area_description=This JTextArea is being filled with text from a buffer progressively a character at a time while the progress bar a the bottom of the window shows the loading progress + +ProgressBarDemo.text=\ +The saying goes: if an infinite number of monkeys typed on an infinite number of typewriters, eventually \n\ +all the great works of mankind would emerge. Now, with today's high speed computers, we can finally test \n\ +this theory... \n\n\ +\tLzskd jfy 92y;ho4 th;qlh sd 6yty;q2 hnlj 8sdf. Djfy 92y;ho4, th;qxhz d7yty; \n\ +\tQ0hnlj 23&^ (# ljask djf y92y; fy92y; Sd6y ty;q2h nl jk la gfa harvin garvel\n\ +\tlasdfsd a83sl la8z ks8l 92y;ho4 th;qlh sd 6yty;q2 hnlj 8sdf. Djfy 92y;ho4,\n\ +\tth;qxhz d7yty; Q0hnlj 23&^ nknod mrs88 jsd79lfm#%$JLaoz6df lso7dj f2 jfls\n\ +\t67d9ol1@2fou99s 1lkj2 @l.k1 2; a89o7aljf 1l3i7ou8 d8l3 lqwerty0092 #1!\n\ +\tja9o do8lkjj139rojsd9**!l6*hd # ljasd78 l2awkjad78 3ol7asljf 3 ldif & l.js\n\ +\tLl ls ewan la8uj 23lll7u 8l 3h hhxx8 8d lsd fixx 891lkjno99sl d8l@@@!!8#8\n\ +\tdfoil jarooda mklaoorj nowai the smisthliylka jkdlfjiw ladajadra lthhheeejfjl\n\ +\tdkddooolda bub mirznod of the koojgaf!! But 2 be or not to be... that is the\n\ +\tquestion. Then when shall we three meet again In thunder, lightning, or in\n\ +\train? When the hurlyburly's done, When the battle's lost and won. That will\n\ +\tbe ere the set of sun. Where the place? Upon the heath. There to meet with\n\ +\tMacbeth. But hath forth not to want..... a banana, or to be.... a banana.\n\ +\tBanana, I knew him banana. Banana banana. Banana banana banana banana.\n\ +\n\ +\n\ +\n\ +\n\ +Well... hmm.... it seemed like a good idea... diff --git a/swingset3/com/sun/swingset3/demos/progressbar/resources/images/ProgressBarDemo.gif b/swingset3/com/sun/swingset3/demos/progressbar/resources/images/ProgressBarDemo.gif new file mode 100644 index 0000000..1aa706d Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/progressbar/resources/images/ProgressBarDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/ScrollPaneDemo.java b/swingset3/com/sun/swingset3/demos/scrollpane/ScrollPaneDemo.java new file mode 100644 index 0000000..4d41b07 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/scrollpane/ScrollPaneDemo.java @@ -0,0 +1,138 @@ +/* + * 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.demos.scrollpane; + +import java.awt.*; +import javax.swing.*; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * Scroll Pane Demo + * + * @version 1.9 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JScrollPane Demo", + category = "Containers", + description = "Demonstrates JScrollPane, a container for scrolling contents within a view port", + sourceFiles = { + "com/sun/swingset3/demos/scrollpane/ScrollPaneDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/scrollpane/resources/ScrollPaneDemo.properties", + "com/sun/swingset3/demos/scrollpane/resources/images/colheader.jpg", + "com/sun/swingset3/demos/scrollpane/resources/images/COPYRIGHT", + "com/sun/swingset3/demos/scrollpane/resources/images/crayons.jpg", + "com/sun/swingset3/demos/scrollpane/resources/images/lowerleft.jpg", + "com/sun/swingset3/demos/scrollpane/resources/images/rowheader.jpg", + "com/sun/swingset3/demos/scrollpane/resources/images/ScrollPaneDemo.gif", + "com/sun/swingset3/demos/scrollpane/resources/images/upperleft.jpg", + "com/sun/swingset3/demos/scrollpane/resources/images/upperright.jpg"} +) +public class ScrollPaneDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ScrollPaneDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ScrollPaneDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * ScrollPaneDemo Constructor + */ + public ScrollPaneDemo() { + setLayout(new BorderLayout()); + + ImageIcon crayons = resourceManager.createImageIcon("crayons.jpg", + resourceManager.getString("ScrollPaneDemo.crayons")); + add(new ImageScroller(crayons), BorderLayout.CENTER); + } + + + /** + * ScrollPane class that demonstrates how to set the various column and row headers + * and corners. + */ + private class ImageScroller extends JScrollPane { + public ImageScroller(Icon icon) { + super(); + + // Panel to hold the icon image + JPanel p = new JPanel(new BorderLayout()); + p.add(new JLabel(icon), BorderLayout.CENTER); + getViewport().add(p); + + // Create and add a column header to the scrollpane + JLabel colHeader = new JLabel( + resourceManager.createImageIcon("colheader.jpg", resourceManager.getString("ScrollPaneDemo.colheader"))); + setColumnHeaderView(colHeader); + + // Create and add a row header to the scrollpane + JLabel rowHeader = new JLabel( + resourceManager.createImageIcon("rowheader.jpg", resourceManager.getString("ScrollPaneDemo.rowheader"))); + setRowHeaderView(rowHeader); + + // Create and add the upper left corner + JLabel cornerUL = new JLabel( + resourceManager.createImageIcon("upperleft.jpg", resourceManager.getString("ScrollPaneDemo.upperleft"))); + setCorner(UPPER_LEFT_CORNER, cornerUL); + + // Create and add the upper right corner + JLabel cornerUR = new JLabel( + resourceManager.createImageIcon("upperright.jpg", resourceManager.getString("ScrollPaneDemo.upperright"))); + setCorner(UPPER_RIGHT_CORNER, cornerUR); + + // Create and add the lower left corner + JLabel cornerLL = new JLabel( + resourceManager.createImageIcon("lowerleft.jpg", resourceManager.getString("ScrollPaneDemo.lowerleft"))); + setCorner(LOWER_LEFT_CORNER, cornerLL); + + JScrollBar vsb = getVerticalScrollBar(); + JScrollBar hsb = getHorizontalScrollBar(); + + vsb.setValue(icon.getIconHeight()); + hsb.setValue(icon.getIconWidth() / 10); + } + } + +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/ScrollPaneDemo.properties b/swingset3/com/sun/swingset3/demos/scrollpane/resources/ScrollPaneDemo.properties new file mode 100644 index 0000000..4d33fb5 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/scrollpane/resources/ScrollPaneDemo.properties @@ -0,0 +1,11 @@ +### ScrollPane Demo ### + +ScrollPaneDemo.accessible_description=JScrollPane Demo +ScrollPaneDemo.name=Scroll Pane Demo +ScrollPaneDemo.tooltip=JScrollPane demo +ScrollPaneDemo.crayons=Lots of Crayons +ScrollPaneDemo.colheader=Column Header +ScrollPaneDemo.rowheader=Row Header +ScrollPaneDemo.upperleft=Upper Left Corner +ScrollPaneDemo.upperright=Upper Right Column Header Corner +ScrollPaneDemo.lowerleft=Lower Left Row Header Corner diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/COPYRIGHT b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/COPYRIGHT new file mode 100644 index 0000000..6633256 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/COPYRIGHT @@ -0,0 +1,7 @@ + + All images in this directory are copyright 1995 by Jeff Dinkins. + Unauthorized reproduction is prohibited. + + For more information about Jeff's photographs, please see: + http://www.theFixx.org/Jeff + diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/ScrollPaneDemo.gif b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/ScrollPaneDemo.gif new file mode 100644 index 0000000..95fcc12 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/ScrollPaneDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/colheader.jpg b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/colheader.jpg new file mode 100644 index 0000000..774deed Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/colheader.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/crayons.jpg b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/crayons.jpg new file mode 100644 index 0000000..922171d Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/crayons.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/lowerleft.jpg b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/lowerleft.jpg new file mode 100644 index 0000000..b9e6047 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/lowerleft.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/rowheader.jpg b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/rowheader.jpg new file mode 100644 index 0000000..c791147 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/rowheader.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/upperleft.jpg b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/upperleft.jpg new file mode 100644 index 0000000..69e2a00 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/upperleft.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/upperright.jpg b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/upperright.jpg new file mode 100644 index 0000000..a40a128 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/scrollpane/resources/images/upperright.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/slider/SliderDemo.java b/swingset3/com/sun/swingset3/demos/slider/SliderDemo.java new file mode 100644 index 0000000..c6f6269 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/slider/SliderDemo.java @@ -0,0 +1,303 @@ +/* + * 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.demos.slider; + +import java.awt.*; +import javax.swing.*; +import javax.swing.border.BevelBorder; +import javax.swing.border.TitledBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * JSlider Demo + * + * @version 1.9 11/17/05 + * @author Dave Kloba + * @author Jeff Dinkins + */ +@DemoProperties( + value = "Slider Demo", + category = "Controls", + description = "Demonstrates the JSlider, a control which supports linear adjustment", + sourceFiles = { + "com/sun/swingset3/demos/slider/SliderDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/slider/resources/SliderDemo.properties", + "com/sun/swingset3/demos/slider/resources/images/SliderDemo.gif" + } +) +public class SliderDemo extends JPanel { + private static final Dimension HGAP5 = new Dimension(5, 1); + private static final Dimension VGAP5 = new Dimension(1, 5); + private static final Dimension HGAP10 = new Dimension(10, 1); + private static final Dimension VGAP10 = new Dimension(1, 10); + private static final Dimension HGAP20 = new Dimension(20, 1); + private static final Dimension HGAP25 = new Dimension(25, 1); + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(SliderDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new SliderDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * SliderDemo Constructor + */ + public SliderDemo() { + createSliderDemo(); + } + + private void createSliderDemo() { + JSlider s; + JPanel hp; + JPanel vp; + GridLayout g; + JPanel tp; + JLabel tf; + ChangeListener listener; + + setLayout(new BorderLayout()); + + tf = new JLabel(resourceManager.getString("SliderDemo.slidervalue")); + add(tf, BorderLayout.SOUTH); + + tp = new JPanel(); + g = new GridLayout(1, 2); + g.setHgap(5); + g.setVgap(5); + tp.setLayout(g); + add(tp, BorderLayout.CENTER); + + listener = new SliderListener(tf); + + BevelBorder border = new BevelBorder(BevelBorder.LOWERED); + + hp = new JPanel(); + hp.setLayout(new BoxLayout(hp, BoxLayout.Y_AXIS)); + hp.setBorder(new TitledBorder( + border, + resourceManager.getString("SliderDemo.horizontal"), + TitledBorder.LEFT, + TitledBorder.ABOVE_TOP)); + tp.add(hp); + + vp = new JPanel(); + vp.setLayout(new BoxLayout(vp, BoxLayout.X_AXIS)); + vp.setBorder(new TitledBorder( + border, + resourceManager.getString("SliderDemo.vertical"), + TitledBorder.LEFT, + TitledBorder.ABOVE_TOP)); + tp.add(vp); + + // Horizontal Slider 1 + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.plain"))); + s = new JSlider(-10, 100, 20); + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.plain")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.a_plain_slider")); + s.addChangeListener(listener); + + p.add(Box.createRigidArea(VGAP5)); + p.add(s); + p.add(Box.createRigidArea(VGAP5)); + hp.add(p); + hp.add(Box.createRigidArea(VGAP10)); + + // Horizontal Slider 2 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.majorticks"))); + s = new JSlider(100, 1000, 400); + s.setPaintTicks(true); + s.setMajorTickSpacing(100); + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.majorticks")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.majorticksdescription")); + s.addChangeListener(listener); + + p.add(Box.createRigidArea(VGAP5)); + p.add(s); + p.add(Box.createRigidArea(VGAP5)); + hp.add(p); + hp.add(Box.createRigidArea(VGAP10)); + + // Horizontal Slider 3 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.ticks"))); + s = new JSlider(0, 11, 6); + + s.putClientProperty("JSlider.isFilled", Boolean.TRUE); + + s.setPaintTicks(true); + s.setMajorTickSpacing(5); + s.setMinorTickSpacing(1); + + s.setPaintLabels(true); + s.setSnapToTicks(true); + + s.getLabelTable().put(new Integer(11), new JLabel(Integer.toString(11), JLabel.CENTER)); + s.setLabelTable(s.getLabelTable()); + + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.minorticks")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.minorticksdescription")); + + s.addChangeListener(listener); + + p.add(Box.createRigidArea(VGAP5)); + p.add(s); + p.add(Box.createRigidArea(VGAP5)); + hp.add(p); + hp.add(Box.createRigidArea(VGAP10)); + + // Horizontal Slider 4 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.disabled"))); + BoundedRangeModel brm = new DefaultBoundedRangeModel(80, 0, 0, 100); + s = new JSlider(brm); + s.setPaintTicks(true); + s.setMajorTickSpacing(20); + s.setMinorTickSpacing(5); + s.setEnabled(false); + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.disabled")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.disableddescription")); + s.addChangeListener(listener); + + p.add(Box.createRigidArea(VGAP5)); + p.add(s); + p.add(Box.createRigidArea(VGAP5)); + hp.add(p); + + ////////////////////////////////////////////////////////////////////////////// + + // Vertical Slider 1 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.plain"))); + s = new JSlider(JSlider.VERTICAL, -10, 100, 20); + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.plain")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.a_plain_slider")); + s.addChangeListener(listener); + p.add(Box.createRigidArea(HGAP10)); + p.add(s); + p.add(Box.createRigidArea(HGAP10)); + vp.add(p); + vp.add(Box.createRigidArea(HGAP10)); + + // Vertical Slider 2 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.majorticks"))); + s = new JSlider(JSlider.VERTICAL, 100, 1000, 400); + + s.putClientProperty("JSlider.isFilled", Boolean.TRUE); + + s.setPaintTicks(true); + s.setMajorTickSpacing(100); + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.majorticks")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.majorticksdescription")); + s.addChangeListener(listener); + p.add(Box.createRigidArea(HGAP25)); + p.add(s); + p.add(Box.createRigidArea(HGAP25)); + vp.add(p); + vp.add(Box.createRigidArea(HGAP5)); + + // Vertical Slider 3 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.minorticks"))); + s = new JSlider(JSlider.VERTICAL, 0, 100, 60); + s.setPaintTicks(true); + s.setMajorTickSpacing(20); + s.setMinorTickSpacing(5); + + s.setPaintLabels(true); + + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.minorticks")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.minorticksdescription")); + + s.addChangeListener(listener); + p.add(Box.createRigidArea(HGAP10)); + p.add(s); + p.add(Box.createRigidArea(HGAP10)); + vp.add(p); + vp.add(Box.createRigidArea(HGAP5)); + + // Vertical Slider 4 + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setBorder(new TitledBorder(resourceManager.getString("SliderDemo.disabled"))); + s = new JSlider(JSlider.VERTICAL, 0, 100, 80); + s.setPaintTicks(true); + s.setMajorTickSpacing(20); + s.setMinorTickSpacing(5); + s.setEnabled(false); + s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.disabled")); + s.getAccessibleContext().setAccessibleDescription(resourceManager.getString("SliderDemo.disableddescription")); + s.addChangeListener(listener); + p.add(Box.createRigidArea(HGAP20)); + p.add(s); + p.add(Box.createRigidArea(HGAP20)); + vp.add(p); + } + + private class SliderListener implements ChangeListener { + private final JLabel tf; + + public SliderListener(JLabel f) { + tf = f; + } + + public void stateChanged(ChangeEvent e) { + JSlider s1 = (JSlider) e.getSource(); + tf.setText(resourceManager.getString("SliderDemo.slidervalue") + s1.getValue()); + } + } +} + diff --git a/swingset3/com/sun/swingset3/demos/slider/resources/SliderDemo.properties b/swingset3/com/sun/swingset3/demos/slider/resources/SliderDemo.properties new file mode 100644 index 0000000..25e2ae9 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/slider/resources/SliderDemo.properties @@ -0,0 +1,19 @@ +### Slider Demo ### + +SliderDemo.accessible_description=This demo shows an example of using the JSlider component. +SliderDemo.tooltip=JSlider demo +SliderDemo.name=Slider Demo + +SliderDemo.slidervalue=Slider Value: +SliderDemo.horizontal=Horizontal +SliderDemo.vertical=Vertical +SliderDemo.plain=Plain +SliderDemo.a_plain_slider=A Plain Slider +SliderDemo.majorticks=Major Ticks +SliderDemo.majorticksdescription=A slider showing major tick marks +SliderDemo.ticks=Minor Ticks, Snap-to-ticks and Labels +SliderDemo.minorticks=Minor Ticks +SliderDemo.minorticksdescription=A slider showing major and minor tick marks, with slider action snapping to tick marks, with some ticks visibly labeled +SliderDemo.disabled=Disabled +SliderDemo.disableddescription=A slider showing major and minor tick marks that is not enabled (cannot be manipulated + diff --git a/swingset3/com/sun/swingset3/demos/slider/resources/images/SliderDemo.gif b/swingset3/com/sun/swingset3/demos/slider/resources/images/SliderDemo.gif new file mode 100644 index 0000000..61924f5 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/slider/resources/images/SliderDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/spinner/JMandelbrot.java b/swingset3/com/sun/swingset3/demos/spinner/JMandelbrot.java new file mode 100644 index 0000000..8d38bd4 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/JMandelbrot.java @@ -0,0 +1,330 @@ +/* + * 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.demos.spinner; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.Point2D; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.util.List; + +import com.sun.swingset3.demos.ResourceManager; + +/** + * @author Mikhail Lapshin + */ +public class JMandelbrot extends JComponent { + private static final double EPSILON = 1E-16; + private static final int MIN_WIDTH = 50; + private static final int MIN_HEIGHT = 50; + private static final double ZOOM_RATE = 3; + private static final int NUM_OF_THREADS = 4; + + private Point2D center; + public static final String CENTER_PROPERTY_NAME = "center"; + + private int maxIteration = 300; + public static final String MAX_ITERATION_PROPERTY_NAME = "maxIteration"; + + private Palette palette; + public static final String PALETTE_PROPERTY_NAME = "palette"; + + private BufferedImage buffer; + private final MandelbrotCalculator[] calculators = + new MandelbrotCalculator[NUM_OF_THREADS]; + + private double xLowLimit = -2; + private double xHighLimit = 2; + private double yLowLimit = -2; + private double yHighLimit = 2; + private double xScale = 100; + private double yScale = 100; + private int oldComponentWidth = (int) (xScale * (xHighLimit - xLowLimit)); + private int oldComponentHeight = (int) (yScale * (yHighLimit - yLowLimit)); + + public JMandelbrot(int width, int height, Palette palette, + ResourceManager resourceManager) { + setPreferredSize(new Dimension(width, height)); + setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT)); + calcConstants(width, height); + setPalette(palette); + setToolTipText(resourceManager.getString("SpinnerDemo.toolTip")); + installListeners(); + } + + private void calcConstants() { + calcConstants(getWidth(), getHeight()); + } + + private void calcConstants(int width, int height) { + if ((width >= MIN_WIDTH) && (height >= MIN_HEIGHT)) { + double oldIntervalWidth = xHighLimit - xLowLimit; + double oldIntervalHeight = yHighLimit - yLowLimit; + double newIntervalWidth = + width * oldIntervalWidth / oldComponentWidth; + double newIntervalHeight = + height * oldIntervalHeight / oldComponentHeight; + double xDiff = newIntervalWidth - oldIntervalWidth; + double yDiff = newIntervalHeight - oldIntervalHeight; + xLowLimit -= xDiff / 2; + xHighLimit += xDiff / 2; + yLowLimit -= yDiff / 2; + yHighLimit += yDiff / 2; + buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + oldComponentWidth = width; + oldComponentHeight = height; + setCenter(calcCenter()); + } + } + + private void installListeners() { + addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + int xCoord = e.getX(); + int yCoord = e.getY(); + double intervalWidth = xHighLimit - xLowLimit; + double intervalHeight = yHighLimit - yLowLimit; + double x = intervalWidth * xCoord / getWidth() + xLowLimit; + double y = intervalHeight * yCoord / getHeight() + yLowLimit; + + double newIntervalWidth; + double newIntervalHeight; + if (e.getButton() == MouseEvent.BUTTON1) { + boolean limitReached = false; + newIntervalWidth = intervalWidth / ZOOM_RATE; + if ((newIntervalWidth / getWidth()) < EPSILON) { + newIntervalWidth = intervalWidth; + limitReached = true; + } + newIntervalHeight = intervalHeight / ZOOM_RATE; + if ((newIntervalHeight / getHeight()) < EPSILON) { + newIntervalHeight = intervalHeight; + limitReached = true; + } + if (!limitReached) { + xLowLimit = x - (x - xLowLimit) / ZOOM_RATE; + yLowLimit = y - (y - yLowLimit) / ZOOM_RATE; + } + } else { + newIntervalWidth = intervalWidth * ZOOM_RATE; + newIntervalHeight = intervalHeight * ZOOM_RATE; + xLowLimit = x - (x - xLowLimit) * ZOOM_RATE; + yLowLimit = y - (y - yLowLimit) * ZOOM_RATE; + } + + xHighLimit = xLowLimit + newIntervalWidth; + yHighLimit = yLowLimit + newIntervalHeight; + + setCenter(calcCenter()); + + xScale = getWidth() / newIntervalWidth; + yScale = getHeight() / newIntervalHeight; + + calculatePicture(); + } + }); + + addComponentListener(new ComponentListener() { + public void componentResized(ComponentEvent e) { + calcConstants(); + calculatePicture(); + repaint(); + } + + public void componentMoved(ComponentEvent e) { + } + + public void componentShown(ComponentEvent e) { + } + + public void componentHidden(ComponentEvent e) { + } + }); + } + + //Use SwingWorker to asynchronously calculate parts of the picture + public void calculatePicture() { + int yStep = getHeight() / NUM_OF_THREADS; + int yStart = 0; + for (int i = 0; i < calculators.length; i++) { + if ((calculators[i] != null) && !calculators[i].isDone()) { + calculators[i].cancel(true); + } + int yEnd = i == calculators.length - 1 ? getHeight() : yStart + yStep; + calculators[i] = new MandelbrotCalculator(yStart, yEnd); + calculators[i].execute(); + yStart = yEnd; + } + } + // + + private Point2D calcCenter() { + return new Point2D.Double(xLowLimit + (xHighLimit - xLowLimit) / 2, + yLowLimit + (yHighLimit - yLowLimit) / 2); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.drawImage(buffer, 0, 0, null); + } + + //Use SwingWorker to asynchronously calculate parts of the picture + private class MandelbrotCalculator extends SwingWorker { + private final int yStart; + private final int yEnd; + + public MandelbrotCalculator(int yStart, int yEnd) { + this.yStart = yStart; + this.yEnd = yEnd; + } + + protected Object doInBackground() throws Exception { + int[] data = ((DataBufferInt) buffer.getRaster().getDataBuffer()).getData(); + + double xArr[] = new double[buffer.getWidth()]; + + for (int i = 0; i < xArr.length; i++) { + xArr[i] = i / xScale + xLowLimit; + } + + double yArr[] = new double[yEnd - yStart]; + + for (int i = 0; i < yArr.length; i++) { + yArr[i] = (yStart + i) / yScale + yLowLimit; + } + + int i = yStart * buffer.getWidth(); + + for (double y : yArr) { + for (double x : xArr) { + int value = calcValue(x, y); + + data[i] = value == maxIteration ? 0 : palette.getRgbColor(value); + + i++; + } + if (Thread.currentThread().isInterrupted()) { + return null; + } + publish(); + } + return null; + } + + private int calcValue(double x, double y) { + double x0 = x; + double y0 = y; + + for (int i = 0; i < maxIteration; i++) { + double x2 = x * x; + double y2 = y * y; + + if (x2 + y2 > 4) { + return i; + } + + y = 2 * x * y + y0; + x = x2 - y2 + x0; + } + + return maxIteration; + } + + @Override + protected void process(List chunks) { + repaint(); + } + } + // + + // Getters and Setters + + public int getMaxIteration() { + return maxIteration; + } + + public void setMaxIteration(int maxIteration) { + int oldValue = this.maxIteration; + this.maxIteration = maxIteration; + firePropertyChange(MAX_ITERATION_PROPERTY_NAME, oldValue, maxIteration); + palette.setSize(maxIteration); + } + + public double getXHighLimit() { + return xHighLimit; + } + + public double getXLowLimit() { + return xLowLimit; + } + + public double getYLowLimit() { + return yLowLimit; + } + + public double getYHighLimit() { + return yHighLimit; + } + + public Point2D getCenter() { + return center; + } + + public void setCenter(Point2D coords) { + Point2D oldValue = this.center; + this.center = coords; + + double width = xHighLimit - xLowLimit; + double height = yHighLimit - yLowLimit; + + xLowLimit = coords.getX() - width / 2; + xHighLimit = xLowLimit + width; + yLowLimit = coords.getY() - height / 2; + yHighLimit = yLowLimit + height; + + firePropertyChange(CENTER_PROPERTY_NAME, oldValue, coords); + } + + public Palette getPalette() { + return palette; + } + + public void setPalette(Palette palette) { + Palette oldValue = this.palette; + palette.setSize(maxIteration); + this.palette = palette; + firePropertyChange(PALETTE_PROPERTY_NAME, oldValue, palette); + } +} diff --git a/swingset3/com/sun/swingset3/demos/spinner/JPaletteShower.java b/swingset3/com/sun/swingset3/demos/spinner/JPaletteShower.java new file mode 100644 index 0000000..63dc4e1 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/JPaletteShower.java @@ -0,0 +1,69 @@ +/* + * 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.demos.spinner; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Mikhail Lapshin + */ +public class JPaletteShower extends JComponent { + private Palette palette; + + public JPaletteShower(Palette palette, int width, int height) { + setPreferredSize(new Dimension(width, height)); + setMinimumSize(new Dimension(width, height)); + this.palette = palette; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + int w = getSize().width; + int h = getSize().height; + int maxIndex = palette.getSize() - 1; + double rate = (double) maxIndex / w; + for (int x = 0; x < w; x++) { + g.setColor(palette.getColor((int) (x * rate))); + g.fillRect(x, 0, 1, h); + } + } + + public Palette getPalette() { + return palette; + } + + public void setPalette(Palette palette) { + this.palette = palette; + repaint(); + } +} diff --git a/swingset3/com/sun/swingset3/demos/spinner/JSpinnerPanel.java b/swingset3/com/sun/swingset3/demos/spinner/JSpinnerPanel.java new file mode 100644 index 0000000..2036b5a --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/JSpinnerPanel.java @@ -0,0 +1,72 @@ +/* + * 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.demos.spinner; + +import javax.swing.*; +import java.awt.*; + +/** + * Arranges labels and spinners into two vertical columns. + * Labels at the left, spinners at the right. + * @author Mikhail Lapshin + */ +//Helpful component for layout of labeled spinners +public class JSpinnerPanel extends JPanel { + private final JPanel labelPanel; + private final JPanel spinnerPanel; + + public JSpinnerPanel() { + setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + labelPanel = new JPanel(); + labelPanel.setLayout(new GridLayout(0, 1)); + + spinnerPanel = new JPanel(); + spinnerPanel.setLayout(new GridLayout(0, 1)); + + add(labelPanel); + add(Box.createHorizontalStrut(5)); + add(spinnerPanel); + } + + public void addSpinner(String labelText, JSpinner spinner) { + JLabel label = new JLabel(labelText); + label.setHorizontalAlignment(SwingConstants.TRAILING); + labelPanel.add(label); + + JPanel flowPanel = new JPanel(); + flowPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 5, 1)); + flowPanel.add(spinner); + spinnerPanel.add(flowPanel); + } +} +// + diff --git a/swingset3/com/sun/swingset3/demos/spinner/MandelbrotControl.java b/swingset3/com/sun/swingset3/demos/spinner/MandelbrotControl.java new file mode 100644 index 0000000..2301992 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/MandelbrotControl.java @@ -0,0 +1,169 @@ +/* + * 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.demos.spinner; + +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Point2D; +import javax.swing.event.ChangeListener; +import javax.swing.event.ChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; + +import com.sun.swingset3.demos.ResourceManager; + +/** + * @author Mikhail Lapshin + */ +public class MandelbrotControl extends JPanel { + private final JMandelbrot mandelbrot; + private JSpinner iterSpinner; + private CoordSpinner xSpinner; + private CoordSpinner ySpinner; + private static final double COORD_SPINNER_STEP = 0.1d; // part of width or height + private final ResourceManager resourceManager; + + public MandelbrotControl(JMandelbrot mandelbrot, + ResourceManager resourceManager) { + this.mandelbrot = mandelbrot; + this.resourceManager = resourceManager; + createUI(); + installListeners(); + } + + private void createUI() { + setLayout(new FlowLayout(FlowLayout.LEADING, 5, 0)); + setBorder(BorderFactory.createTitledBorder( + resourceManager.getString("SpinnerDemo.fractalControls"))); + JSpinnerPanel spinnerPanel = new JSpinnerPanel(); + + //Create spinner + iterSpinner = new JSpinner(new SpinnerNumberModel( + mandelbrot.getMaxIteration(), 10, 100000, 50)); + // + //Add change listener using anonymus inner class + iterSpinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + mandelbrot.setMaxIteration((Integer) iterSpinner.getValue()); + mandelbrot.calculatePicture(); + } + }); + // + spinnerPanel.addSpinner( + resourceManager.getString("SpinnerDemo.iterations"), iterSpinner); + + //Create spinner + final double xValue = mandelbrot.getCenter().getX(); + double width = mandelbrot.getXHighLimit() - mandelbrot.getXLowLimit(); + xSpinner = new CoordSpinner(xValue, width * COORD_SPINNER_STEP); + // + //Add change listener using anonymus inner class + xSpinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + Double newX = (Double) xSpinner.getValue(); + mandelbrot.setCenter(new Point2D.Double( + newX, mandelbrot.getCenter().getY())); + mandelbrot.calculatePicture(); + } + }); + // + spinnerPanel.addSpinner( + resourceManager.getString("SpinnerDemo.x"), xSpinner); + + //Create spinner + final double yValue = mandelbrot.getCenter().getY(); + double height = mandelbrot.getYHighLimit() - mandelbrot.getYLowLimit(); + ySpinner = new CoordSpinner(yValue, height * COORD_SPINNER_STEP); + // + //Add change listener using anonymus inner class + ySpinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + Double newY = (Double) ySpinner.getValue(); + mandelbrot.setCenter(new Point2D.Double( + mandelbrot.getCenter().getX(), newY)); + mandelbrot.calculatePicture(); + } + }); + // + spinnerPanel.addSpinner( + resourceManager.getString("SpinnerDemo.y"), ySpinner); + + add(spinnerPanel); + } + + private void installListeners() { + mandelbrot.addPropertyChangeListener( + JMandelbrot.CENTER_PROPERTY_NAME, + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + double width = mandelbrot.getXHighLimit() + - mandelbrot.getXLowLimit(); + double newX = mandelbrot.getCenter().getX(); + xSpinner.updateModel(newX, width * COORD_SPINNER_STEP); + double height = mandelbrot.getYHighLimit() + - mandelbrot.getYLowLimit(); + double newY = mandelbrot.getCenter().getY(); + ySpinner.updateModel(newY, height * COORD_SPINNER_STEP); + } + } + ); + } + + //Customized spinner class + // It uses special format for NumberEditor and has constant preferred width + private static class CoordSpinner extends JSpinner { + @Override + protected JComponent createEditor(SpinnerModel model) { + return new NumberEditor(this, "#.####################"); + } + + public CoordSpinner(double value, double stepSize) { + super(new SpinnerNumberModel(value, -100, 100, stepSize)); + } + + //A useful shortcut method + public void updateModel(double value, double stepSize) { + SpinnerNumberModel model = (SpinnerNumberModel) getModel(); + model.setValue(value); + model.setStepSize(stepSize); + } + + @Override + public Dimension getPreferredSize() { + Dimension prefSize = super.getPreferredSize(); + prefSize.setSize(180, prefSize.getHeight()); + return prefSize; + } + } + // +} + + diff --git a/swingset3/com/sun/swingset3/demos/spinner/Palette.java b/swingset3/com/sun/swingset3/demos/spinner/Palette.java new file mode 100644 index 0000000..445e0c4 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/Palette.java @@ -0,0 +1,102 @@ +/* + * 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.demos.spinner; + +/** + * @author Mikhail Lapshin + */ +import java.awt.*; + +public class Palette { + private final int minColor; + private final int colorRange; + private Color[] colors; + private int[] rgbColors; + private final int rSteps; + private final int gSteps; + private final int bSteps; + private int totalRange; + private int rRange; + private int gRange; + private int bRange; + private final double rStart; + private final double gStart; + private final double bStart; + + public Palette(int totalRange, int minColor, int maxColor, double rStart, + double gStart, double bStart, int rSteps, int gSteps, int bSteps) { + this.minColor = minColor; + this.colorRange = maxColor - minColor; + this.rStart = rStart; + this.gStart = gStart; + this.bStart = bStart; + this.rSteps = rSteps; + this.gSteps = gSteps; + this.bSteps = bSteps; + setSize(totalRange); + } + + public void setSize(int newSize) { + totalRange = newSize; + rRange = totalRange / rSteps; + gRange = totalRange / gSteps; + bRange = totalRange / bSteps; + fillColorTable(); + } + + private void fillColorTable() { + colors = new Color[totalRange]; + rgbColors = new int[totalRange]; + for (int i = 0; i < totalRange; i++) { + double cosR = Math.cos(i * 2 * Math.PI / rRange + rStart); + double cosG = Math.cos(i * 2 * Math.PI / gRange + gStart); + double cosB = Math.cos(i * 2 * Math.PI / bRange + bStart); + Color color = new Color( + (int) ((cosR * colorRange) + colorRange) / 2 + minColor, + (int) ((cosG * colorRange) + colorRange) / 2 + minColor, + (int) ((cosB * colorRange) + colorRange) / 2 + minColor); + colors[i] = color; + rgbColors[i] = color.getRGB(); + } + } + + public Color getColor(int index) { + return colors[index]; + } + + public int getRgbColor(int index) { + return rgbColors[index]; + } + + public int getSize() { + return totalRange; + } +} diff --git a/swingset3/com/sun/swingset3/demos/spinner/PaletteChooser.java b/swingset3/com/sun/swingset3/demos/spinner/PaletteChooser.java new file mode 100644 index 0000000..b72b73d --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/PaletteChooser.java @@ -0,0 +1,172 @@ +/* + * 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.demos.spinner; + +import javax.swing.*; +import java.awt.*; +import javax.swing.event.ChangeListener; +import javax.swing.event.ChangeEvent; + +import com.sun.swingset3.demos.ResourceManager; + +/** + * @author Mikhail Lapshin + */ +public class PaletteChooser extends JPanel { + private static final int MIN_COLOR = 50; + private static final int MAX_COLOR = 255; + private static final int R_STEPS = 5; + private static final int G_STEPS = 5; + private static final int B_STEPS = 5; + private static final int R_ANGLE = 270; + private static final int G_ANGLE = 90; + private static final int B_ANGLE = 0; + + public static final String PALETTE_PROPERTY_NAME = "palette"; + + private final ResourceManager resourceManager; + private Palette palette; + private final JPaletteShower shower; + private final ChangeListener changeListener; + + private JSpinner rsSpinner; + private JSpinner gsSpinner; + private JSpinner bsSpinner; + private JSpinner raSpinner; + private JSpinner gaSpinner; + private JSpinner baSpinner; + + public PaletteChooser(ResourceManager resourceManager) { + this.resourceManager = resourceManager; + palette = new Palette(MAX_COLOR - MIN_COLOR, MIN_COLOR, MAX_COLOR, + Math.toRadians(R_ANGLE), Math.toRadians(G_ANGLE), + Math.toRadians(B_ANGLE), R_STEPS, G_STEPS, B_STEPS); + shower = new JPaletteShower(palette, 250, 25); + + //Use single change listener for several spinners + changeListener = new ChangeListener() { + public void stateChanged(ChangeEvent e) { + setPalette(createPalette()); + shower.setPalette(palette); + repaint(); + } + }; + // + + setBorder(BorderFactory.createTitledBorder( + resourceManager.getString("SpinnerDemo.colorPalette"))); + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + add(shower); + add(createControlPanel()); + } + + private double toRadians(JSpinner spinner) { + return Math.toRadians(getIntValue(spinner)); + } + + private Palette createPalette() { + return new Palette(getWidth(), MIN_COLOR, MAX_COLOR, + toRadians(raSpinner), toRadians(gaSpinner), + toRadians(baSpinner), getIntValue(rsSpinner), + getIntValue(gsSpinner), getIntValue(bsSpinner)); + } + + private static int getIntValue(JSpinner spinner) { + return (Integer) spinner.getValue(); + } + + private JPanel createControlPanel() { + JPanel controlPanel = new JPanel(); + controlPanel.setLayout(new GridLayout(1, 2)); + controlPanel.add(createStepPanel()); + controlPanel.add(createStartAnglePanel()); + return controlPanel; + } + + private JPanel createStartAnglePanel() { + JSpinnerPanel startAnglePanel = new JSpinnerPanel(); + startAnglePanel.setBorder(BorderFactory.createTitledBorder( + resourceManager.getString("SpinnerDemo.startAngles"))); + + raSpinner = createAngleSpinner(R_ANGLE, "SpinnerDemo.r", startAnglePanel); + gaSpinner = createAngleSpinner(G_ANGLE, "SpinnerDemo.g", startAnglePanel); + baSpinner = createAngleSpinner(B_ANGLE, "SpinnerDemo.b", startAnglePanel); + + return startAnglePanel; + } + + private JPanel createStepPanel() { + JSpinnerPanel stepPanel = new JSpinnerPanel(); + stepPanel.setBorder(BorderFactory.createTitledBorder( + resourceManager.getString("SpinnerDemo.steps"))); + + rsSpinner = createStepSpinner(R_STEPS, "SpinnerDemo.r", stepPanel); + gsSpinner = createStepSpinner(G_STEPS, "SpinnerDemo.g", stepPanel); + bsSpinner = createStepSpinner(B_STEPS, "SpinnerDemo.b", stepPanel); + + return stepPanel; + } + + private JSpinner createAngleSpinner(int startAngle, String resourceName, + JSpinnerPanel parent) { + SpinnerModel model = new SpinnerNumberModel(startAngle, 0, 360, 10); + return createSpinner(model, resourceName, parent); + } + + private JSpinner createStepSpinner(int startSteps, String resourceName, + JSpinnerPanel parent) { + SpinnerModel model = new SpinnerNumberModel(startSteps, 1, 1000, 1); + return createSpinner(model, resourceName, parent); + } + + private JSpinner createSpinner(SpinnerModel model, String resourceName, + JSpinnerPanel parent) { + + //Create spinner + JSpinner spinner = new JSpinner(model); + // + //Use single change listener for several spinners + spinner.addChangeListener(changeListener); + // + parent.addSpinner(resourceManager.getString(resourceName), spinner); + return spinner; + } + + public Palette getPalette() { + return palette; + } + + private void setPalette(Palette palette) { + Palette oldValue = this.palette; + this.palette = palette; + firePropertyChange(PALETTE_PROPERTY_NAME, oldValue, palette); + } +} diff --git a/swingset3/com/sun/swingset3/demos/spinner/SpinnerDemo.java b/swingset3/com/sun/swingset3/demos/spinner/SpinnerDemo.java new file mode 100644 index 0000000..2cdd37c --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/SpinnerDemo.java @@ -0,0 +1,113 @@ +/* + * 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.demos.spinner; + +import javax.swing.*; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * Demonstrates JSpinner and SwingWorker + * + * @author Mikhail Lapshin + */ +@DemoProperties( + value = "Spinner Demo", + category = "Controls", + description = "Demonstrates JSpinner and SwingWorker", + sourceFiles = { + "com/sun/swingset3/demos/spinner/SpinnerDemo.java", + "com/sun/swingset3/demos/spinner/JMandelbrot.java", + "com/sun/swingset3/demos/spinner/JPaletteShower.java", + "com/sun/swingset3/demos/spinner/JSpinnerPanel.java", + "com/sun/swingset3/demos/spinner/MandelbrotControl.java", + "com/sun/swingset3/demos/spinner/Palette.java", + "com/sun/swingset3/demos/spinner/PaletteChooser.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/spinner/resources/SpinnerDemo.properties", + "com/sun/swingset3/demos/spinner/resources/images/SpinnerDemo.gif" + } +) +public class SpinnerDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(getClass()); + + public static void main(String[] args) { + JFrame frame = new JFrame( + SpinnerDemo.class.getAnnotation(DemoProperties.class).value()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new SpinnerDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public SpinnerDemo() { + setLayout(new BorderLayout()); + + // Create main components + PaletteChooser chooser = + new PaletteChooser(resourceManager); + final JMandelbrot mandelbrot = + new JMandelbrot(400, 400, chooser.getPalette(), resourceManager); + MandelbrotControl mandelbrotControl = + new MandelbrotControl(mandelbrot, resourceManager); + + // Connect palette chooser and mandelbrot component + chooser.addPropertyChangeListener( + PaletteChooser.PALETTE_PROPERTY_NAME, + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + mandelbrot.setPalette((Palette) evt.getNewValue()); + mandelbrot.calculatePicture(); + } + } + ); + + // Layout components + add(mandelbrot); + + JPanel controlPanel = new JPanel(); + controlPanel.setLayout(new BorderLayout()); + controlPanel.add(chooser, BorderLayout.NORTH); + + JPanel mandelbrotControlPanel = new JPanel(); + mandelbrotControlPanel.setLayout(new BorderLayout()); + mandelbrotControlPanel.add(mandelbrotControl, BorderLayout.NORTH); + controlPanel.add(mandelbrotControlPanel, BorderLayout.CENTER); + + add(controlPanel, BorderLayout.EAST); + } +} diff --git a/swingset3/com/sun/swingset3/demos/spinner/resources/SpinnerDemo.properties b/swingset3/com/sun/swingset3/demos/spinner/resources/SpinnerDemo.properties new file mode 100644 index 0000000..c5372ef --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/spinner/resources/SpinnerDemo.properties @@ -0,0 +1,15 @@ +### Spinner Demo ### + +SpinnerDemo.toolTip=Use left and right mouse buttons to zoom in and zoom out +SpinnerDemo.colorPalette=Color palette +SpinnerDemo.steps=Steps 1..1000 +SpinnerDemo.startAngles=Start angle 0..360 +SpinnerDemo.iterations=Iterations +SpinnerDemo.fractalControls=Fractal controls +SpinnerDemo.zoomRate=Zoom rate +SpinnerDemo.threads=Threads +SpinnerDemo.x=X +SpinnerDemo.y=Y +SpinnerDemo.r=R +SpinnerDemo.g=G +SpinnerDemo.b=B diff --git a/swingset3/com/sun/swingset3/demos/spinner/resources/images/SpinnerDemo.gif b/swingset3/com/sun/swingset3/demos/spinner/resources/images/SpinnerDemo.gif new file mode 100644 index 0000000..87d560d Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/spinner/resources/images/SpinnerDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/splitpane/SplitPaneDemo.java b/swingset3/com/sun/swingset3/demos/splitpane/SplitPaneDemo.java new file mode 100644 index 0000000..376fb8a --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/splitpane/SplitPaneDemo.java @@ -0,0 +1,293 @@ +/* + * 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.demos.splitpane; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * Split Pane demo + * + * @version 1.12 11/17/05 + * @author Scott Violet + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JSplitPane Demo", + category = "Containers", + description = "Demonstrates JSplitPane, a container which lays out two components in an adjustable split view (horizontal or vertical)", + sourceFiles = { + "com/sun/swingset3/demos/splitpane/SplitPaneDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/splitpane/resources/SplitPaneDemo.properties", + "com/sun/swingset3/demos/splitpane/resources/images/day.jpg", + "com/sun/swingset3/demos/splitpane/resources/images/night.jpg", + "com/sun/swingset3/demos/splitpane/resources/images/SplitPaneDemo.gif" + } +) +public class SplitPaneDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private static final Insets insets = new Insets(4, 8, 4, 8); + + private final JSplitPane splitPane; + private final JLabel day; + private final JLabel night; + + private JPanel controlPanel; + private GridBagLayout gridbag; + private GridBagConstraints c; + + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(SplitPaneDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new SplitPaneDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * SplitPaneDemo Constructor + */ + public SplitPaneDemo() { + setLayout(new BorderLayout()); + + //Create horizontal SplitPane with day and night + day = new JLabel(resourceManager.createImageIcon("day.jpg", + resourceManager.getString("SplitPaneDemo.day"))); + night = new JLabel(resourceManager.createImageIcon("night.jpg", + resourceManager.getString("SplitPaneDemo.night"))); + + splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, day, night); + // + + //Turn on continuous layout + splitPane.setContinuousLayout(true); + // + + //Turn on one-touch expansion + splitPane.setOneTouchExpandable(true); + // + + //Set divider location + splitPane.setDividerLocation(200); + // + + //Set minimum size for each child + day.setMinimumSize(new Dimension(20, 20)); + night.setMinimumSize(new Dimension(20, 20)); + // + + add(splitPane, BorderLayout.CENTER); + setBackground(Color.black); + + add(createSplitPaneControls(), BorderLayout.SOUTH); + } + + /** + * Creates controls to alter the JSplitPane. + */ + protected JPanel createSplitPaneControls() { + + gridbag = new GridBagLayout(); + c = new GridBagConstraints(); + controlPanel = new JPanel(gridbag); + + //Create radio box to edit splitpane orientation + Box box = Box.createHorizontalBox(); + ButtonGroup group = new ButtonGroup(); + + OrientationListener orientationListener = new OrientationListener(); + + JRadioButton button = new JRadioButton(resourceManager.getString("SplitPaneDemo.vert_split")); + button.setActionCommand("vertical"); + button.addActionListener(orientationListener); + group.add(button); + box.add(button); + + button = new JRadioButton(resourceManager.getString("SplitPaneDemo.horz_split")); + button.setActionCommand("horizontal"); + button.setSelected(true); + button.addActionListener(orientationListener); + group.add(button); + box.add(button); + // + + addToGridbag(box, 0, 0, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.WEST); + + //Create checkbox to edit continuous layout + JCheckBox checkBox = new JCheckBox(resourceManager.getString("SplitPaneDemo.cont_layout")); + checkBox.setSelected(true); + + checkBox.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + splitPane.setContinuousLayout( + ((JCheckBox) e.getSource()).isSelected()); + } + }); + // + + c.gridy++; + addToGridbag(checkBox, 0, 1, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.WEST); + + //Create checkbox to edit one-touch-expandable + checkBox = new JCheckBox(resourceManager.getString("SplitPaneDemo.one_touch_expandable")); + checkBox.setSelected(true); + + checkBox.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + splitPane.setOneTouchExpandable( + ((JCheckBox) e.getSource()).isSelected()); + } + }); + // + + addToGridbag(checkBox, 0, 2, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.WEST); + + JSeparator separator = new JSeparator(JSeparator.VERTICAL); + addToGridbag(separator, 1, 0, 1, 3, + GridBagConstraints.VERTICAL, GridBagConstraints.CENTER); + + //Create spinner to edit divider size + final JSpinner spinner = new JSpinner( + new SpinnerNumberModel(splitPane.getDividerSize(), 5, 50, 2)); + + spinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent event) { + SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); + splitPane.setDividerSize(model.getNumber().intValue()); + } + }); + // + + JLabel label = new JLabel(resourceManager.getString("SplitPaneDemo.divider_size")); + label.setLabelFor(spinner); + addToGridbag(label, 2, 0, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.EAST); + addToGridbag(spinner, 3, 0, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.WEST); + + //Create spinners to edit day & night's minimum sizes + JSpinner minSizeSpinner = new JSpinner( + new SpinnerNumberModel(day.getMinimumSize().width, 0, 300, 10)); + + minSizeSpinner.addChangeListener(new MinimumSizeListener(day)); + // + + label = new JLabel(resourceManager.getString("SplitPaneDemo.first_component_min_size")); + label.setLabelFor(minSizeSpinner); + addToGridbag(label, 2, 1, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.EAST); + addToGridbag(minSizeSpinner, 3, 1, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.WEST); + + //Create spinners to edit day & night's minimum sizes + minSizeSpinner = new JSpinner( + new SpinnerNumberModel(night.getMinimumSize().width, 0, 300, 10)); + + minSizeSpinner.addChangeListener(new MinimumSizeListener(night)); + // + + label = new JLabel(resourceManager.getString("SplitPaneDemo.second_component_min_size")); + label.setLabelFor(minSizeSpinner); + addToGridbag(label, 2, 2, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.EAST); + addToGridbag(minSizeSpinner, 3, 2, 1, 1, + GridBagConstraints.NONE, GridBagConstraints.WEST); + + return controlPanel; + } + + protected void addToGridbag(JComponent child, int gx, int gy, + int gwidth, int gheight, int fill, int anchor) { + c.insets = insets; + c.gridx = gx; + c.gridy = gy; + c.gridwidth = gwidth; + c.gridheight = gheight; + c.fill = fill; + c.anchor = anchor; + gridbag.addLayoutComponent(child, c); + controlPanel.add(child); + + } + + //Create radio box to edit splitpane orientation + private class OrientationListener implements ActionListener { + public void actionPerformed(ActionEvent event) { + splitPane.setOrientation(event.getActionCommand().equals("vertical") ? + JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT); + } + + } + // + + //Create spinners to edit day & night's minimum sizes + + public class MinimumSizeListener implements ChangeListener { + private final JComponent component; + + public MinimumSizeListener(JComponent c) { + this.component = c; + } + + public void stateChanged(ChangeEvent event) { + JSpinner spinner = (JSpinner) event.getSource(); + SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); + int min = model.getNumber().intValue(); + component.setMinimumSize(new Dimension(min, min)); + } + } + // +} diff --git a/swingset3/com/sun/swingset3/demos/splitpane/resources/SplitPaneDemo.properties b/swingset3/com/sun/swingset3/demos/splitpane/resources/SplitPaneDemo.properties new file mode 100644 index 0000000..ef61ebd --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/splitpane/resources/SplitPaneDemo.properties @@ -0,0 +1,14 @@ +### SplitPane Demo ### + +SplitPaneDemo.accessible_description=JSplitPane Demo +SplitPaneDemo.name=Split Pane Demo +SplitPaneDemo.tooltip=JSplitPane demo +SplitPaneDemo.day=San Francisco by day +SplitPaneDemo.night=San Francisco by night +SplitPaneDemo.vert_split=Vertical Split +SplitPaneDemo.horz_split=Horizontal Split +SplitPaneDemo.cont_layout=Continuous Layout +SplitPaneDemo.one_touch_expandable=One-Touch expandable +SplitPaneDemo.divider_size=Divider Size +SplitPaneDemo.first_component_min_size=Day's Minimum Size +SplitPaneDemo.second_component_min_size=Night's Minimum Size diff --git a/swingset3/com/sun/swingset3/demos/splitpane/resources/images/SplitPaneDemo.gif b/swingset3/com/sun/swingset3/demos/splitpane/resources/images/SplitPaneDemo.gif new file mode 100644 index 0000000..945aa5b Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/splitpane/resources/images/SplitPaneDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/splitpane/resources/images/day.jpg b/swingset3/com/sun/swingset3/demos/splitpane/resources/images/day.jpg new file mode 100644 index 0000000..a838c5c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/splitpane/resources/images/day.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/splitpane/resources/images/night.jpg b/swingset3/com/sun/swingset3/demos/splitpane/resources/images/night.jpg new file mode 100644 index 0000000..bc87387 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/splitpane/resources/images/night.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java b/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java new file mode 100644 index 0000000..88f84ba --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java @@ -0,0 +1,255 @@ +/* + * 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.demos.tabbedpane; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Random; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * JTabbedPane Demo + * + * @version 1.11 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JTabbedPane Demo", + category = "Containers", + description = "Demonstrates JTabbedPane, a container which allows tabbed navigation of components", + sourceFiles = { + "com/sun/swingset3/demos/tabbedpane/TabbedPaneDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/tabbedpane/resources/TabbedPaneDemo.properties", + "com/sun/swingset3/demos/tabbedpane/resources/images/blake.gif", + "com/sun/swingset3/demos/tabbedpane/resources/images/brooke.gif", + "com/sun/swingset3/demos/tabbedpane/resources/images/camille.jpg", + "com/sun/swingset3/demos/tabbedpane/resources/images/david.gif", + "com/sun/swingset3/demos/tabbedpane/resources/images/ewan.gif", + "com/sun/swingset3/demos/tabbedpane/resources/images/ewan.jpg", + "com/sun/swingset3/demos/tabbedpane/resources/images/miranda.jpg", + "com/sun/swingset3/demos/tabbedpane/resources/images/matthew.gif", + "com/sun/swingset3/demos/tabbedpane/resources/images/stephen.gif", + "com/sun/swingset3/demos/tabbedpane/resources/images/TabbedPaneDemo.gif" + } +) +public class TabbedPaneDemo extends JPanel implements ActionListener { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final HeadSpin spin; + + private final JTabbedPane tabbedpane; + + private final ButtonGroup group; + + private final JRadioButton top; + private final JRadioButton bottom; + private final JRadioButton left; + private final JRadioButton right; + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(TabbedPaneDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new TabbedPaneDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * TabbedPaneDemo Constructor + */ + public TabbedPaneDemo() { + setLayout(new BorderLayout()); + + // create tab position controls + JPanel tabControls = new JPanel(); + tabControls.add(new JLabel(resourceManager.getString("TabbedPaneDemo.label"))); + top = (JRadioButton) tabControls.add(new JRadioButton(resourceManager.getString("TabbedPaneDemo.top"))); + left = (JRadioButton) tabControls.add(new JRadioButton(resourceManager.getString("TabbedPaneDemo.left"))); + bottom = (JRadioButton) tabControls.add(new JRadioButton(resourceManager.getString("TabbedPaneDemo.bottom"))); + right = (JRadioButton) tabControls.add(new JRadioButton(resourceManager.getString("TabbedPaneDemo.right"))); + add(tabControls, BorderLayout.NORTH); + + group = new ButtonGroup(); + group.add(top); + group.add(bottom); + group.add(left); + group.add(right); + + top.setSelected(true); + + top.addActionListener(this); + bottom.addActionListener(this); + left.addActionListener(this); + right.addActionListener(this); + + // create tab + tabbedpane = new JTabbedPane(); + add(tabbedpane, BorderLayout.CENTER); + + String name = resourceManager.getString("TabbedPaneDemo.camille"); + JLabel pix = new JLabel(resourceManager.createImageIcon("camille.jpg", name)); + tabbedpane.add(name, pix); + + name = resourceManager.getString("TabbedPaneDemo.miranda"); + pix = new JLabel(resourceManager.createImageIcon("miranda.jpg", name)); + pix.setToolTipText(resourceManager.getString("TabbedPaneDemo.miranda.tooltip")); + tabbedpane.add(name, pix); + + name = resourceManager.getString("TabbedPaneDemo.ewan"); + pix = new JLabel(resourceManager.createImageIcon("ewan.jpg", name)); + tabbedpane.add(name, pix); + + name = resourceManager.getString("TabbedPaneDemo.bounce"); + spin = new HeadSpin(); + tabbedpane.add(name, spin); + + tabbedpane.getModel().addChangeListener( + new ChangeListener() { + public void stateChanged(ChangeEvent e) { + SingleSelectionModel model = (SingleSelectionModel) e.getSource(); + if (model.getSelectedIndex() == tabbedpane.getTabCount() - 1) { + spin.go(); + } + } + } + ); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == top) { + tabbedpane.setTabPlacement(JTabbedPane.TOP); + } else if (e.getSource() == left) { + tabbedpane.setTabPlacement(JTabbedPane.LEFT); + } else if (e.getSource() == bottom) { + tabbedpane.setTabPlacement(JTabbedPane.BOTTOM); + } else if (e.getSource() == right) { + tabbedpane.setTabPlacement(JTabbedPane.RIGHT); + } + } + + private class HeadSpin extends JComponent implements ActionListener { + private javax.swing.Timer animator; + + private final ImageIcon[] icon = new ImageIcon[6]; + + private final static int numImages = 6; + + private final double[] x = new double[numImages]; + private final double[] y = new double[numImages]; + + private final int[] xh = new int[numImages]; + private final int[] yh = new int[numImages]; + + private final double[] scale = new double[numImages]; + + private final Random rand = new Random(); + + public HeadSpin() { + setBackground(Color.black); + icon[0] = resourceManager.createImageIcon("ewan.gif", resourceManager.getString("TabbedPaneDemo.ewan")); + icon[1] = resourceManager.createImageIcon("stephen.gif", resourceManager.getString("TabbedPaneDemo.stephen")); + icon[2] = resourceManager.createImageIcon("david.gif", resourceManager.getString("TabbedPaneDemo.david")); + icon[3] = resourceManager.createImageIcon("matthew.gif", resourceManager.getString("TabbedPaneDemo.matthew")); + icon[4] = resourceManager.createImageIcon("blake.gif", resourceManager.getString("TabbedPaneDemo.blake")); + icon[5] = resourceManager.createImageIcon("brooke.gif", resourceManager.getString("TabbedPaneDemo.brooke")); + + /* + for(int i = 0; i < 6; i++) { + x[i] = (double) rand.nextInt(500); + y[i] = (double) rand.nextInt(500); + } + */ + } + + public void go() { + animator = new javax.swing.Timer(22 + 22 + 22, this); + animator.start(); + } + + public void paint(Graphics g) { + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + + for (int i = 0; i < numImages; i++) { + if (x[i] > 3 * i) { + nudge(i); + squish(g, icon[i], xh[i], yh[i], scale[i]); + } else { + x[i] += .05; + y[i] += .05; + } + } + } + + public void nudge(int i) { + x[i] += (double) rand.nextInt(1000) / 8756; + y[i] += (double) rand.nextInt(1000) / 5432; + int tmpScale = (int) (Math.abs(Math.sin(x[i])) * 10); + scale[i] = (double) tmpScale / 10; + int nudgeX = (int) (((double) getWidth() / 2) * .8); + int nudgeY = (int) (((double) getHeight() / 2) * .60); + xh[i] = (int) (Math.sin(x[i]) * nudgeX) + nudgeX; + yh[i] = (int) (Math.sin(y[i]) * nudgeY) + nudgeY; + } + + public void squish(Graphics g, ImageIcon icon, int x, int y, double scale) { + if (isVisible()) { + g.drawImage(icon.getImage(), x, y, + (int) (icon.getIconWidth() * scale), + (int) (icon.getIconHeight() * scale), + this); + } + } + + public void actionPerformed(ActionEvent e) { + if (isVisible()) { + repaint(); + } else { + animator.stop(); + } + } + } +} + diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/TabbedPaneDemo.properties b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/TabbedPaneDemo.properties new file mode 100644 index 0000000..f32d963 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/TabbedPaneDemo.properties @@ -0,0 +1,22 @@ +### TabbedPane Demo ### + +TabbedPaneDemo.accessible_description=This demo shows an example of using the JTabbedPane component. +TabbedPaneDemo.tooltip=JTabbedPane demo +TabbedPaneDemo.name=TabbedPane Demo + +TabbedPaneDemo.bounce=
Bouncing Babies!
+TabbedPaneDemo.stephen=Stephen +TabbedPaneDemo.david=David +TabbedPaneDemo.matthew=Matthew +TabbedPaneDemo.ewan=Ewan +TabbedPaneDemo.blake=Blake +TabbedPaneDemo.brooke=Brooke +TabbedPaneDemo.camille=Camille +TabbedPaneDemo.miranda=Miranda +TabbedPaneDemo.miranda.tooltip=Check out the Java code on her onesie! + +TabbedPaneDemo.label=Tab Placement: +TabbedPaneDemo.top=Top +TabbedPaneDemo.bottom=Bottom +TabbedPaneDemo.left=Left +TabbedPaneDemo.right=Right \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/TabbedPaneDemo.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/TabbedPaneDemo.gif new file mode 100644 index 0000000..9be6463 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/TabbedPaneDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/blake.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/blake.gif new file mode 100644 index 0000000..679639e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/blake.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/brooke.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/brooke.gif new file mode 100644 index 0000000..815ce77 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/brooke.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/camille.jpg b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/camille.jpg new file mode 100644 index 0000000..d00eabd Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/camille.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/david.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/david.gif new file mode 100644 index 0000000..46de559 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/david.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.gif new file mode 100644 index 0000000..82c8e58 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.jpg b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.jpg new file mode 100644 index 0000000..d19210e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/ewan.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/matthew.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/matthew.gif new file mode 100644 index 0000000..812775e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/matthew.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/miranda.jpg b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/miranda.jpg new file mode 100644 index 0000000..83df277 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/miranda.jpg differ diff --git a/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/stephen.gif b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/stephen.gif new file mode 100644 index 0000000..470c3bc Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tabbedpane/resources/images/stephen.gif differ diff --git a/swingset3/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java b/swingset3/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java new file mode 100644 index 0000000..21f5234 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java @@ -0,0 +1,333 @@ +/* + * 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.demos.table; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import javax.swing.Action; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.table.TableCellRenderer; + +import com.sun.swingset3.demos.JHyperlink; + +/** + * Table renderer which renders cell value as hyperlink with optional rollover underline. + * + * @author aim + */ +public class HyperlinkCellRenderer extends JHyperlink implements TableCellRenderer { + private JTable table; + private final ArrayList columnModelIndeces = new ArrayList(); + + private Color rowColors[]; + private Color foreground; + private Color visitedForeground; + private Border focusBorder; + private Border noFocusBorder; + + private boolean underlineOnRollover = true; + + private transient int hitColumnIndex = -1; + private transient int hitRowIndex = -1; + + private HashMap visitedCache; + + public HyperlinkCellRenderer(Action action, boolean underlineOnRollover) { + setAction(action); + setHorizontalAlignment(JHyperlink.LEFT); + rowColors = new Color[1]; + rowColors[0] = UIManager.getColor("Table.background"); + this.underlineOnRollover = underlineOnRollover; + applyDefaults(); + } + + public void setRowColors(Color[] colors) { + this.rowColors = colors; + } + + public void updateUI() { + super.updateUI(); + applyDefaults(); + } + + protected void applyDefaults() { + setOpaque(true); + setBorderPainted(false); + foreground = UIManager.getColor("Hyperlink.foreground"); + visitedForeground = UIManager.getColor("Hyperlink.visitedForeground"); + + // Make sure border used on non-focussed cells is same size as focussed border + focusBorder = UIManager.getBorder("Table.focusCellHighlightBorder"); + if (focusBorder != null) { + Insets insets = focusBorder.getBorderInsets(this); + noFocusBorder = new EmptyBorder(insets.top, insets.left, insets.bottom, insets.right); + } else { + focusBorder = noFocusBorder = new EmptyBorder(1, 1, 1, 1); + } + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + if (this.table == null) { + this.table = table; + HyperlinkMouseListener hyperlinkListener = new HyperlinkMouseListener(); + table.addMouseMotionListener(hyperlinkListener); + table.addMouseListener(hyperlinkListener); + } + int columnModelIndex = table.getColumnModel().getColumn(column).getModelIndex(); + if (!columnModelIndeces.contains(columnModelIndex)) { + columnModelIndeces.add(columnModelIndex); + } + + if (value instanceof Link) { + Link link = (Link) value; + setText(link.getDisplayText()); + setToolTipText(link.getDescription()); + } else { + setText(value != null ? value.toString() : ""); + } + setVisited(isCellLinkVisited(value, row, column)); + setDrawUnderline(!underlineOnRollover || + (row == hitRowIndex && column == hitColumnIndex)); + + if (!isSelected) { + setBackground(rowColors[row % rowColors.length]); + //setForeground(isCellLinkVisited(value, row, column)? + // visitedForeground : foreground); + setForeground(foreground); + setVisitedForeground(visitedForeground); + } else { + setBackground(table.getSelectionBackground()); + setForeground(table.getSelectionForeground()); + setVisitedForeground(table.getSelectionForeground()); + } + //setBorder(hasFocus? focusBorder : noFocusBorder); + //System.out.println("border insets="+getBorder().getBorderInsets(this)); + + return this; + } + + protected void setCellLinkVisited(Object value, int row, int column) { + if (!isCellLinkVisited(value, row, column)) { + if (value instanceof Link) { + ((Link) value).setVisited(true); + } else { + if (visitedCache == null) { + visitedCache = new HashMap(); + } + int position[] = new int[2]; + position[0] = table.convertRowIndexToModel(row); + position[1] = table.convertColumnIndexToModel(column); + visitedCache.put(value, position); + } + } + } + + protected boolean isCellLinkVisited(Object value, int row, int column) { + if (value instanceof Link) { + return ((Link) value).isVisited(); + } + if (visitedCache != null) { + int position[] = visitedCache.get(value); + if (position != null) { + return position[0] == table.convertRowIndexToModel(row) && + position[1] == table.convertColumnIndexToModel(column); + } + } + return false; + } + + public int getActiveHyperlinkRow() { + return hitRowIndex; + } + + public int getActiveHyperlinkColumn() { + return hitColumnIndex; + } + + // overridden because the AbstractButton's version forces the source of the event + // to be the AbstractButton and we want a little more freedom to configure the + // event + @Override + protected void fireActionPerformed(ActionEvent event) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ActionListener.class) { + ((ActionListener) listeners[i + 1]).actionPerformed(event); + } + } + } + + public void invalidate() { + } + + public void validate() { + } + + public void revalidate() { + } + + public void repaint(long tm, int x, int y, int width, int height) { + } + + public void repaint(Rectangle r) { + } + + public void repaint() { + } + + private class HyperlinkMouseListener extends MouseAdapter { + private transient Rectangle cellRect; + private final transient Rectangle iconRect = new Rectangle(); + private final transient Rectangle textRect = new Rectangle(); + private transient Cursor tableCursor; + + @Override + public void mouseMoved(MouseEvent event) { + // This should only be called if underlineOnRollover is true + JTable table = (JTable) event.getSource(); + + // Locate the table cell under the event location + int oldHitColumnIndex = hitColumnIndex; + int oldHitRowIndex = hitRowIndex; + + checkIfPointInsideHyperlink(event.getPoint()); + + if (hitRowIndex != oldHitRowIndex || + hitColumnIndex != oldHitColumnIndex) { + if (hitRowIndex != -1) { + if (tableCursor == null) { + tableCursor = table.getCursor(); + } + table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } else { + table.setCursor(tableCursor); + } + + // repaint the cells affected by rollover + Rectangle repaintRect; + if (hitRowIndex != -1 && hitColumnIndex != -1) { + // we need to repaint new cell with rollover underline + // cellRect already contains rect of hit cell + if (oldHitRowIndex != -1 && oldHitColumnIndex != -1) { + // we also need to repaint previously underlined hyperlink cell + // to remove the underline + repaintRect = cellRect.union( + table.getCellRect(oldHitRowIndex, oldHitColumnIndex, false)); + } else { + // we don't have a previously underlined hyperlink, so just repaint new one' + repaintRect = table.getCellRect(hitRowIndex, hitColumnIndex, false); + } + } else { + // we just need to repaint previously underlined hyperlink cell + //to remove the underline + repaintRect = table.getCellRect(oldHitRowIndex, oldHitColumnIndex, false); + } + table.repaint(repaintRect); + } + + } + + @Override + public void mouseClicked(MouseEvent event) { + if (checkIfPointInsideHyperlink(event.getPoint())) { + + ActionEvent actionEvent = new ActionEvent(new Integer(hitRowIndex), + ActionEvent.ACTION_PERFORMED, + "hyperlink"); + + HyperlinkCellRenderer.this.fireActionPerformed(actionEvent); + + setCellLinkVisited(table.getValueAt(hitRowIndex, hitColumnIndex), + hitRowIndex, hitColumnIndex); + + } + } + + protected boolean checkIfPointInsideHyperlink(Point p) { + hitColumnIndex = table.columnAtPoint(p); + hitRowIndex = table.rowAtPoint(p); + + if (hitColumnIndex != -1 && hitRowIndex != -1 && + columnModelIndeces.contains(table.getColumnModel(). + getColumn(hitColumnIndex).getModelIndex())) { + // We know point is within a hyperlink column, however we do further hit testing + // to see if point is within the text bounds on the hyperlink + TableCellRenderer renderer = table.getCellRenderer(hitRowIndex, hitColumnIndex); + JHyperlink hyperlink = (JHyperlink) table.prepareRenderer(renderer, hitRowIndex, hitColumnIndex); + + // Convert the event to the renderer's coordinate system + cellRect = table.getCellRect(hitRowIndex, hitColumnIndex, false); + hyperlink.setSize(cellRect.width, cellRect.height); + p.translate(-cellRect.x, -cellRect.y); + cellRect.x = cellRect.y = 0; + iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; + textRect.x = textRect.y = textRect.width = textRect.height = 0; + SwingUtilities.layoutCompoundLabel( + hyperlink.getFontMetrics(hyperlink.getFont()), + hyperlink.getText(), hyperlink.getIcon(), + hyperlink.getVerticalAlignment(), + hyperlink.getHorizontalAlignment(), + hyperlink.getVerticalTextPosition(), + hyperlink.getHorizontalTextPosition(), + cellRect, iconRect, textRect, hyperlink.getIconTextGap()); + + if (textRect.contains(p)) { + // point is within hyperlink text bounds + return true; + } + } + // point is not within a hyperlink's text bounds + hitRowIndex = -1; + hitColumnIndex = -1; + return false; + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/table/IMDBLink.java b/swingset3/com/sun/swingset3/demos/table/IMDBLink.java new file mode 100644 index 0000000..47ad836 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/IMDBLink.java @@ -0,0 +1,153 @@ +/* + * 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.demos.table; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.ArrayList; + +/** + * Class used to support converting a movie title string into an IMDB URI + * corresponding to that movie's IMDB entry. Since IMDB encodes entries with + * an alpha-numeric key (rather than title), we have to use Yahoo search on the + * title and then screenscrape the search results to find the IMDB key. + * + * @author aim + */ +public class IMDBLink { + + private IMDBLink() { + } + + /** + * @param movieTitle the title of the movie + * @param year the year the movie was nominated for the oscar + * @return String containing URI for movie's IMDB entry or null if URI could not be found + */ + public static String getMovieURIString(String movieTitle, int year) throws IOException { + ArrayList matches = new ArrayList(); + URL url; + BufferedReader reader; + + // btw, google rejects the request with a 403 return code! + // URL url = new URL("http://www.google.com/search?q=Dazed+and+confused"); + // Thank you, yahoo, for granting our search request :-) + try { + String urlKey = URLEncoder.encode(movieTitle, "UTF-8"); + url = new URL("http://search.yahoo.com/search?ei=utf-8&fr=sfp&p=imdb+" + + urlKey + "&iscqry="); + } catch (Exception ex) { + System.err.println(ex); + + return null; + } + + URLConnection conn = url.openConnection(); + conn.connect(); + + // Get the response from Yahoo search query + reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + // Parse response a find each imdb/titleString result + String line; + String imdbString = ".imdb.com"; + String titleStrings[] = {"/title", "/Title"}; + + while ((line = reader.readLine()) != null) { + for (String titleString : titleStrings) { + String scrapeKey = imdbString + titleString; + int index = line.indexOf(scrapeKey); + if (index != -1) { + // The IMDB key looks something like "tt0032138" + // so we look for the 9 characters after the scrape key + // to construct the full IMDB URI. + // e.g. http://www.imdb.com/title/tt0032138 + int len = scrapeKey.length(); + String imdbURL = "http://www" + + line.substring(index, index + len) + + line.substring(index + len, index + len + 10); + + if (!matches.contains(imdbURL)) { + matches.add(imdbURL); + } + } + } + } + reader.close(); + + // Since imdb contains entries for multiple movies of the same titleString, + // use the year to find the right entry + if (matches.size() > 1) { + for (String matchURL : matches) { + if (verifyYear(matchURL, year)) { + return matchURL; + } + } + } + return matches.isEmpty()? null : matches.get(0); + } + + + private static boolean verifyYear(String imdbURL, int movieYear) throws IOException { + boolean yearMatches = false; + + URLConnection conn = new URL(imdbURL).openConnection(); + conn.connect(); + + // Get the response + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + String line; + while ((line = reader.readLine()) != null) { + int index = line.indexOf(""); + if (index != -1) { + // looking for "movie title (YEAR)" + try { + int year = Integer.parseInt(line.substring(index - 5, index - 1)); + // Movie may have been made the year prior to oscar award + yearMatches = year == movieYear || year == movieYear - 1; + + } catch (NumberFormatException ex) { + // ignore title lines that have other formatting + } + break; // only interested in analyzing the one line + } + } + reader.close(); + + return yearMatches; + } +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/table/Link.java b/swingset3/com/sun/swingset3/demos/table/Link.java new file mode 100644 index 0000000..4f0e6ee --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/Link.java @@ -0,0 +1,94 @@ +/* + * 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.demos.table; + +import java.net.URI; + +/** + * Class representing the state of a hyperlink + * This class may be used in conjunction with HyperlinkCellRenderer, + * but it is not required. + * + * @author aim + */ +public class Link { + protected String displayText; + private URI uri; + private String description; + private boolean visited; + + /** + * Creates a new instance of Link + */ + public Link(String text) { + setDisplayText(text); + } + + public Link(String text, URI uri) { + this(text); + setUri(uri); + } + + public String getDisplayText() { + return displayText; + } + + public void setDisplayText(String text) { + this.displayText = text; + } + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public String getDescription() { + return description != null ? description : + uri != null ? uri.getPath() : null; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isVisited() { + return visited; + } + + public void setVisited(boolean visited) { + this.visited = visited; + } + +} diff --git a/swingset3/com/sun/swingset3/demos/table/OscarCandidate.java b/swingset3/com/sun/swingset3/demos/table/OscarCandidate.java new file mode 100644 index 0000000..bb51493 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/OscarCandidate.java @@ -0,0 +1,103 @@ +/* + * 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.demos.table; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author aim + */ +public class OscarCandidate { + + private String category; + private Integer year; + private boolean winner = false; + private String movie; + private URI imdbURI; + private final ArrayList persons = new ArrayList(); + + /** + * Creates a new instance of OscarCandidate + */ + public OscarCandidate(String category) { + this.category = category; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + public boolean isWinner() { + return winner; + } + + public void setWinner(boolean winner) { + this.winner = winner; + } + + public String getMovieTitle() { + return movie; + } + + public void setMovieTitle(String movie) { + this.movie = movie; + } + + public URI getIMDBMovieURI() { + return imdbURI; + } + + public void setIMDBMovieURI(URI uri) { + this.imdbURI = uri; + } + + public List getPersons() { + return persons; + } + + +} diff --git a/swingset3/com/sun/swingset3/demos/table/OscarCellRenderers.java b/swingset3/com/sun/swingset3/demos/table/OscarCellRenderers.java new file mode 100644 index 0000000..2cf7a5e --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/OscarCellRenderers.java @@ -0,0 +1,201 @@ +/* + * 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.demos.table; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.util.HashMap; +import java.util.List; +import javax.swing.Action; +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableModel; + +/** + * + * @author aim + */ +public class OscarCellRenderers { + + //Render table rows with alternating colors + public static class RowRenderer extends DefaultTableCellRenderer { + private Color rowColors[]; + + public RowRenderer() { + // initialize default colors from look-and-feel + rowColors = new Color[1]; + rowColors[0] = UIManager.getColor("Table.background"); + } + + public RowRenderer(Color colors[]) { + super(); + setRowColors(colors); + } + + public void setRowColors(Color colors[]) { + rowColors = colors; + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + setText(value != null ? value.toString() : "unknown"); + if (!isSelected) { + setBackground(rowColors[row % rowColors.length]); + } + return this; + } + + public boolean isOpaque() { + return true; + } + } + // + + //Render "year" table column with font representing style of decade + // currently only used on OS X because fonts are Mac centric. + + public static class YearRenderer extends RowRenderer { + private HashMap eraFonts; + + public YearRenderer() { + setHorizontalAlignment(JLabel.CENTER); + + if (System.getProperty("os.name").equals("Mac OS X")) { + eraFonts = new HashMap(); + eraFonts.put("192"/*1920's*/, new Font("Jazz LET", Font.PLAIN, 12)); + eraFonts.put("193"/*1930's*/, new Font("Mona Lisa Solid ITC TT", Font.BOLD, 18)); + eraFonts.put("194"/*1940's*/, new Font("American Typewriter", Font.BOLD, 12)); + eraFonts.put("195"/*1950's*/, new Font("Britannic Bold", Font.PLAIN, 12)); + eraFonts.put("196"/*1960's*/, new Font("Cooper Black", Font.PLAIN, 14)); + eraFonts.put("197"/*1970's*/, new Font("Syncro LET", Font.PLAIN, 14)); + eraFonts.put("198"/*1980's*/, new Font("Mistral", Font.PLAIN, 18)); + eraFonts.put("199"/*1990's*/, new Font("Papyrus", Font.BOLD, 14)); + eraFonts.put("200"/*2000's*/, new Font("Calisto MT", Font.PLAIN, 14)); + } + } + + public YearRenderer(Color colors[]) { + this(); + setRowColors(colors); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + String year = table.getValueAt(row, + table.convertColumnIndexToView(OscarTableModel.YEAR_COLUMN)).toString(); + if (eraFonts != null && year != null && year.length() == 4) { + String era = year.substring(0, 3); + Font eraFont = eraFonts.get(era); + setFont(eraFont); + } + return this; + } + } + // + + //Render "nominee" table column with special icon for winners + + public static class NomineeRenderer extends RowRenderer { + private final ImageIcon winnerIcon; + private final ImageIcon nomineeIcon; // nice way of saying "loser" :) + + public NomineeRenderer() { + winnerIcon = new ImageIcon( + getClass().getResource("resources/images/goldstar.png")); + nomineeIcon = new ImageIcon( + getClass().getResource("resources/images/nominee.png")); + setHorizontalTextPosition(JLabel.TRAILING); + } + + public NomineeRenderer(Color colors[]) { + this(); + setRowColors(colors); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + + TableModel model = table.getModel(); + boolean winner = ((Boolean) model.getValueAt(table.convertRowIndexToModel(row), + OscarTableModel.WINNER_COLUMN)).booleanValue(); + + List persons = (List) value; + String text = persons != null && !persons.isEmpty() ? persons.get(0) : "name unknown"; + int personCount = persons.size(); + if (personCount > 1) { + setText(text + " + more..."); + StringBuffer winners = new StringBuffer(""); + for (int i = 0; i < personCount; i++) { + String person = persons.get(i); + winners.append(" " + person + (i < personCount - 1 ? ", " : "")); + } + setToolTipText((winner ? "Winners:" : "Nominees:") + winners); + } else { + setText(text); + setToolTipText(winner ? "Winner!" : "Nominee"); + } + + setIcon(winner ? winnerIcon : nomineeIcon); + + return this; + } + } + // + + public static class MovieRenderer extends HyperlinkCellRenderer { + public MovieRenderer(Action action, boolean underlineOnRollover, Color rowColors[]) { + super(action, underlineOnRollover); + setRowColors(rowColors); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, + hasFocus, row, column); + if (value != null) { + setToolTipText("http://www.imdb.com/" + "\"" + value + "\""); + } + return this; + } + } + +} diff --git a/swingset3/com/sun/swingset3/demos/table/OscarDataParser.java b/swingset3/com/sun/swingset3/demos/table/OscarDataParser.java new file mode 100644 index 0000000..5850498 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/OscarDataParser.java @@ -0,0 +1,174 @@ +/* + * 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.demos.table; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.logging.Level; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +public abstract class OscarDataParser extends DefaultHandler { + private static final String[] CATEGORIES_IN = { + "actor", "actress", "bestPicture", + "actorSupporting", "actressSupporting", "artDirection", + "assistantDirector", "director", "cinematography", + "costumeDesign", "danceDirection", "docFeature", + "docShort", "filmEditing", "foreignFilm", + "makeup", "musicScore", "musicSong", + "screenplayAdapted", "screenplayOriginal", "shortAnimation", + "shortLiveAction", "sound", "soundEditing", + "specialEffects", "visualEffects", "writing", + "engEffects", "uniqueArtisticPicture" + }; + + private static final String[] CATEGORIES_OUT = { + "Best Actor", "Best Actress", "Best Picture", + "Best Supporting Actor", "Best Supporting Actress", "Best Art Direction", + "Best Assistant Director", "Best Director", "Best Cinematography", + "Best Costume Design", "Best Dance Direction", "Best Feature Documentary", + "Best Short Documentary", "Best Film Editing", "Best Foreign Film", + "Best Makeup", "Best Musical Score", "Best Song", + "Best Adapted Screenplay", "Best Original Screenplay", "Best Animation Short", + "Best Live Action Short", "Best Sound", "Best Sound Editing", + "Best Special Effects", "Best Visual Effects", "Best Engineering Effects", + "Best Writing", "Most Unique Artistic Picture" + }; + + + private String tempVal; + + //to maintain context + private OscarCandidate tempOscarCandidate; + + private int count = 0; + + public int getCount() { + return count; + } + + public void parseDocument(URL oscarURL) { + //get a factory + SAXParserFactory spf = SAXParserFactory.newInstance(); + + try { + //get a new instance of parser + SAXParser sp = spf.newSAXParser(); + + //parse the file and also register this class for call backs + InputStream is = new BufferedInputStream(oscarURL.openStream()); + sp.parse(is, this); + System.out.println("done parsing count="+count); + is.close(); + + } catch (SAXException se) { + se.printStackTrace(); + } catch (ParserConfigurationException pce) { + pce.printStackTrace(); + } catch (IOException ie) { + ie.printStackTrace(); + } + } + + //Event Handlers + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + //reset + tempVal = ""; + for (int i = 0; i < CATEGORIES_IN.length; i++) { + if (qName.equalsIgnoreCase(CATEGORIES_IN[i])) { + tempOscarCandidate = new OscarCandidate(CATEGORIES_OUT[i]); + tempOscarCandidate.setYear(Integer.parseInt(attributes.getValue("year"))); + if (CATEGORIES_IN[i].equals("screenplayOriginal") && + tempOscarCandidate.getYear() == 2007) { + } + return; + } + } + } + + public void characters(char[] ch, int start, int length) throws SAXException { + tempVal = new String(ch, start, length); + } + + public void endElement(String uri, String localName, String qName) throws SAXException { + if (qName.equalsIgnoreCase("won")) { + tempOscarCandidate.setWinner(true); + } else if (qName.equalsIgnoreCase("lost")) { + tempOscarCandidate.setWinner(false); + } else if (qName.equalsIgnoreCase("movie")) { + tempOscarCandidate.setMovieTitle(tempVal); + } else if (qName.equalsIgnoreCase("person")) { + tempOscarCandidate.getPersons().add(tempVal); + } else { + // find category + for (String category : CATEGORIES_IN) { + if (qName.equalsIgnoreCase(category)) { + //add it to the list + count++; + addCandidate(tempOscarCandidate); + break; + } + } + } + } + + @Override + public void error(SAXParseException ex) throws SAXException { + TableDemo.logger.log(Level.SEVERE, "error parsing oscar data ", ex); + } + + @Override + public void fatalError(SAXParseException ex) throws SAXException { + TableDemo.logger.log(Level.SEVERE, "fatal error parsing oscar data ", ex); + } + + @Override + public void warning(SAXParseException ex) { + TableDemo.logger.log(Level.WARNING, "warning occurred while parsing oscar data ", ex); + } + + @Override + public void endDocument() throws SAXException { + TableDemo.logger.log(Level.FINER, "parsed to end of oscar data."); + } + + protected abstract void addCandidate(OscarCandidate candidate); +} + diff --git a/swingset3/com/sun/swingset3/demos/table/OscarTableModel.java b/swingset3/com/sun/swingset3/demos/table/OscarTableModel.java new file mode 100644 index 0000000..f7fc521 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/OscarTableModel.java @@ -0,0 +1,100 @@ +/* + * 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.demos.table; + +import java.util.ArrayList; +import java.util.List; +import javax.swing.table.AbstractTableModel; + +/** + * Data model for oscar candidate data: a list of OscarCandidate beans. + * + * @author aim + */ + +public class OscarTableModel extends AbstractTableModel { + public static final int CATEGORY_COLUMN = 0; + public static final int YEAR_COLUMN = 1; + public static final int WINNER_COLUMN = 2; + public static final int MOVIE_COLUMN = 3; + public static final int PERSONS_COLUMN = 4; + public static final int COLUMN_COUNT = 5; + + private final List candidates = new ArrayList(); + + public void add(List newCandidates) { + int first = candidates.size(); + int last = first + newCandidates.size() - 1; + candidates.addAll(newCandidates); + fireTableRowsInserted(first, last); + } + + public void add(OscarCandidate candidate) { + int index = candidates.size(); + candidates.add(candidate); + fireTableRowsInserted(index, index); + } + + public int getRowCount() { + return candidates.size(); + } + + public int getColumnCount() { + return COLUMN_COUNT; + } + + @Override + public Class getColumnClass(int column) { + return getValueAt(0, column).getClass(); + } + + public OscarCandidate getCandidate(int row) { + return candidates.get(row); + } + + public Object getValueAt(int row, int column) { + OscarCandidate oscarCandidate = candidates.get(row); + switch (column) { + case CATEGORY_COLUMN: + return oscarCandidate.getCategory(); + case YEAR_COLUMN: + return oscarCandidate.getYear(); + case MOVIE_COLUMN: + return oscarCandidate.getMovieTitle(); + case WINNER_COLUMN: + return oscarCandidate.isWinner() ? Boolean.TRUE : Boolean.FALSE; + case PERSONS_COLUMN: + return oscarCandidate.getPersons(); + } + return null; + } +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/table/TableDemo.java b/swingset3/com/sun/swingset3/demos/table/TableDemo.java new file mode 100644 index 0000000..ed304d6 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/TableDemo.java @@ -0,0 +1,604 @@ +/* + * 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.demos.table; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.DemoUtilities; +import com.sun.swingset3.demos.Stacker; + +import javax.swing.*; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javax.swing.event.*; +import javax.swing.table.*; +import javax.swing.text.Document; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Pattern; + +/** + * + * @author aim + */ +@DemoProperties( + value = "JTable Demo", + category = "Data", + description = "Demonstrates use of Swing's data grid component, JTable, including asynchronous loading and sorting/filtering.", + sourceFiles = { + "com/sun/swingset3/demos/table/TableDemo.java", + "com/sun/swingset3/demos/table/HyperlinkCellRenderer.java", + "com/sun/swingset3/demos/table/IMDBLink.java", + "com/sun/swingset3/demos/table/Link.java", + "com/sun/swingset3/demos/table/OscarCandidate.java", + "com/sun/swingset3/demos/table/OscarCellRenderers.java", + "com/sun/swingset3/demos/table/OscarDataParser.java", + "com/sun/swingset3/demos/table/OscarTableModel.java", + "com/sun/swingset3/demos/DemoUtilities.java", + "com/sun/swingset3/demos/JHyperlink.java", + "com/sun/swingset3/demos/table/resources/bestpicture", + //"com/sun/swingset3/demos/table/resources/oscars.xml", file too large!! + "com/sun/swingset3/demos/table/resources/TableDemo.properties", + "com/sun/swingset3/demos/table/resources/images/goldstar.png", + "com/sun/swingset3/demos/table/resources/images/nominee.png", + "com/sun/swingset3/demos/table/resources/images/TableDemo.gif" + } +) +public class TableDemo extends JPanel { + static final Logger logger = Logger.getLogger(TableDemo.class.getName()); + + private OscarTableModel oscarModel; + + private JPanel controlPanel; + private Stacker dataPanel; + private JTable oscarTable; + private JCheckBox winnersCheckbox; + private JTextField filterField; + private Box statusBarLeft; + private JLabel actionStatus; + private JLabel tableStatus; + + private Color[] rowColors; + private String statusLabelString; + private String searchLabelString; + + private boolean showOnlyWinners = false; + private String filterString = null; + + private TableRowSorter sorter; + private RowFilter winnerFilter; + private RowFilter searchFilter; + + // Resource bundle for internationalized and accessible text + private ResourceBundle bundle = null; + + public TableDemo() { + initModel(); + initComponents(); + initSortingFiltering(); + } + + protected void initModel() { + oscarModel = new OscarTableModel(); + } + + protected void initComponents() { + setLayout(new BorderLayout()); + + controlPanel = createControlPanel(); + add(controlPanel, BorderLayout.NORTH); + + //Create JTable + oscarTable = new JTable(oscarModel); + // + + //Set JTable display properties + oscarTable.setColumnModel(createColumnModel()); + oscarTable.setAutoCreateRowSorter(true); + oscarTable.setRowHeight(26); + oscarTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); + oscarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + oscarTable.setIntercellSpacing(new Dimension(0, 0)); + // + + //Initialize preferred size for table's viewable area + Dimension viewSize = new Dimension(); + viewSize.width = oscarTable.getColumnModel().getTotalColumnWidth(); + viewSize.height = 10 * oscarTable.getRowHeight(); + oscarTable.setPreferredScrollableViewportSize(viewSize); + // + + //Customize height and alignment of table header + JTableHeader header = oscarTable.getTableHeader(); + header.setPreferredSize(new Dimension(30, 26)); + TableCellRenderer headerRenderer = header.getDefaultRenderer(); + if (headerRenderer instanceof JLabel) { + ((JLabel) headerRenderer).setHorizontalAlignment(JLabel.CENTER); + } + // + + JScrollPane scrollpane = new JScrollPane(oscarTable); + dataPanel = new Stacker(scrollpane); + add(dataPanel, BorderLayout.CENTER); + + add(createStatusBar(), BorderLayout.SOUTH); + + } + + protected JPanel createControlPanel() { + JPanel controlPanel = new JPanel(); + GridBagLayout gridbag = new GridBagLayout(); + GridBagConstraints c = new GridBagConstraints(); + controlPanel.setLayout(gridbag); + + c.gridx = 0; + c.gridy = 1; + c.gridheight = 1; + c.insets = new Insets(20, 10, 0, 10); + c.anchor = GridBagConstraints.SOUTHWEST; + JLabel searchLabel = new JLabel(getString("TableDemo.searchLabel", + "Search Titles and Recipients")); + controlPanel.add(searchLabel, c); + + c.gridx = 0; + c.gridy = 2; + c.weightx = 1.0; + c.insets.top = 0; + c.insets.bottom = 12; + c.anchor = GridBagConstraints.SOUTHWEST; + //c.fill = GridBagConstraints.HORIZONTAL; + filterField = new JTextField(24); + filterField.getDocument().addDocumentListener(new SearchFilterListener()); + controlPanel.add(filterField, c); + + c.gridx = 1; + c.gridy = 2; + c.gridwidth = GridBagConstraints.REMAINDER; + //c.insets.right = 24; + //c.insets.left = 12; + c.weightx = 0.0; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.NONE; + winnersCheckbox = new JCheckBox(getString("TableDemo.winnersLabel", + "Show Only Winners")); + winnersCheckbox.addChangeListener(new ShowWinnersListener()); + controlPanel.add(winnersCheckbox, c); + + return controlPanel; + } + + protected Container createStatusBar() { + statusLabelString = getString("TableDemo.rowCountLabel", + "Showing "); + searchLabelString = getString("TableDemo.searchCountLabel", + "Search found "); + + Box statusBar = Box.createHorizontalBox(); + + // Left status area + statusBar.add(Box.createRigidArea(new Dimension(10, 22))); + statusBarLeft = Box.createHorizontalBox(); + statusBar.add(statusBarLeft); + actionStatus = new JLabel(getString("TableDemo.noDataStatusLabel", + "No data loaded")); + actionStatus.setHorizontalAlignment(JLabel.LEADING); + statusBarLeft.add(actionStatus); + + // Middle (should stretch) + statusBar.add(Box.createHorizontalGlue()); + statusBar.add(Box.createHorizontalGlue()); + statusBar.add(Box.createVerticalGlue()); + + // Right status area + tableStatus = new JLabel(statusLabelString + "0"); + statusBar.add(tableStatus); + statusBar.add(Box.createHorizontalStrut(12)); + + //Track number of rows currently displayed + oscarModel.addTableModelListener(new TableModelListener() { + public void tableChanged(TableModelEvent e) { + // Get rowCount from *table*, not model, as the view row count + // may be different from the model row count due to filtering + tableStatus.setText((hasFilterString() ? searchLabelString : statusLabelString) + + oscarTable.getRowCount()); + } + }); + // + + return statusBar; + } + + private Color[] getTableRowColors() { + if (rowColors == null) { + rowColors = new Color[2]; + rowColors[0] = UIManager.getColor("Table.background"); + rowColors[1] = new Color((int) (rowColors[0].getRed() * .9), + (int) (rowColors[0].getGreen() * .9), + (int) (rowColors[0].getBlue() * .9)); + } + return rowColors; + } + + // returns appropriate string from resource bundle + protected String getString(String key, String fallback) { + String value = fallback; + if (bundle == null) { + String bundleName = getClass().getPackage().getName() + ".resources." + getClass().getSimpleName(); + bundle = ResourceBundle.getBundle(bundleName); + } + try { + value = bundle != null ? bundle.getString(key) : key; + + } catch (MissingResourceException ex) { + logger.log(Level.WARNING, "couldn't find resource value for: " + key, ex); + } + return value; + } + + public void start() { + if (oscarModel.getRowCount() == 0) { + loadData("resources/oscars.xml"); + } + } + + //Initialize table columns + protected TableColumnModel createColumnModel() { + DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); + + TableCellRenderer cellRenderer = new OscarCellRenderers.RowRenderer(getTableRowColors()); + + TableColumn column = new TableColumn(); + column.setModelIndex(OscarTableModel.YEAR_COLUMN); + column.setHeaderValue(getString("TableDemo.yearColumnTitle", "Year")); + column.setPreferredWidth(26); + column.setCellRenderer(new OscarCellRenderers.YearRenderer(getTableRowColors())); + columnModel.addColumn(column); + + column = new TableColumn(); + column.setModelIndex(OscarTableModel.CATEGORY_COLUMN); + column.setHeaderValue(getString("TableDemo.categoryColumnTitle", "Award Category")); + column.setPreferredWidth(100); + column.setCellRenderer(cellRenderer); + columnModel.addColumn(column); + + column = new TableColumn(); + column.setModelIndex(OscarTableModel.MOVIE_COLUMN); + column.setHeaderValue(getString("TableDemo.movieTitleColumnTitle", "Movie Title")); + column.setPreferredWidth(180); + HyperlinkCellRenderer hyperlinkRenderer = + new OscarCellRenderers.MovieRenderer(new IMDBLinkAction(), + true, getTableRowColors()); + hyperlinkRenderer.setRowColors(getTableRowColors()); + column.setCellRenderer(hyperlinkRenderer); + columnModel.addColumn(column); + + column = new TableColumn(); + column.setModelIndex(OscarTableModel.PERSONS_COLUMN); + column.setHeaderValue(getString("TableDemo.nomineesColumnTitle", "Nominees")); + column.setPreferredWidth(120); + column.setCellRenderer(new OscarCellRenderers.NomineeRenderer(getTableRowColors())); + columnModel.addColumn(column); + + return columnModel; + } + // + + protected void initSortingFiltering() { + //Setup filtering for winners + sorter = new TableRowSorter(oscarModel); + oscarTable.setRowSorter(sorter); + winnerFilter = new RowFilter() { + public boolean include(Entry entry) { + OscarTableModel oscarModel = entry.getModel(); + OscarCandidate candidate = oscarModel.getCandidate(entry.getIdentifier().intValue()); + if (candidate.isWinner()) { + // Returning true indicates this row should be shown. + return true; + } + // loser + return false; + } + }; + // + + //Setup search filter + searchFilter = new RowFilter() { + public boolean include(Entry entry) { + OscarTableModel oscarModel = entry.getModel(); + OscarCandidate candidate = oscarModel.getCandidate(entry.getIdentifier().intValue()); + boolean matches = false; + Pattern p = Pattern.compile(filterString + ".*", Pattern.CASE_INSENSITIVE); + + String movie = candidate.getMovieTitle(); + if (movie != null) { + if (movie.startsWith("The ")) { + movie = movie.replace("The ", ""); + } else if (movie.startsWith("A ")) { + movie = movie.replace("A ", ""); + } + // Returning true indicates this row should be shown. + matches = p.matcher(movie).matches(); + } + List persons = candidate.getPersons(); + for (String person : persons) { + if (p.matcher(person).matches()) { + matches = true; + } + } + return matches; + } + }; + // + } + + public void setShowOnlyWinners(boolean showOnlyWinners) { + boolean oldShowOnlyWinners = this.showOnlyWinners; + this.showOnlyWinners = showOnlyWinners; + configureFilters(); + tableStatus.setText(statusLabelString + oscarTable.getRowCount()); + firePropertyChange("showOnlyWinners", oldShowOnlyWinners, showOnlyWinners); + } + + public boolean getShowOnlyWinners() { + return showOnlyWinners; + } + + public void setFilterString(String filterString) { + String oldFilterString = this.filterString; + this.filterString = filterString; + configureFilters(); + firePropertyChange("filterString", oldFilterString, filterString); + } + + protected boolean hasFilterString() { + return filterString != null && !filterString.equals(""); + } + + protected void configureFilters() { + if (showOnlyWinners && hasFilterString()) { + List> filters = + new ArrayList>(2); + filters.add(winnerFilter); + filters.add(searchFilter); + RowFilter comboFilter = RowFilter.andFilter((Iterable>) filters); + sorter.setRowFilter(comboFilter); + } else if (showOnlyWinners) { + sorter.setRowFilter(winnerFilter); + } else if (hasFilterString()) { + sorter.setRowFilter(searchFilter); + } else { + sorter.setRowFilter(null); + } + tableStatus.setText((hasFilterString() ? searchLabelString : statusLabelString) + + oscarTable.getRowCount()); + + } + + private class ShowWinnersListener implements ChangeListener { + public void stateChanged(ChangeEvent event) { + setShowOnlyWinners(winnersCheckbox.isSelected()); + } + } + + //Setup search filter + protected class SearchFilterListener implements DocumentListener { + protected void changeFilter(DocumentEvent event) { + Document document = event.getDocument(); + try { + setFilterString(document.getText(0, document.getLength())); + + } catch (Exception ex) { + ex.printStackTrace(); + System.err.println(ex); + } + } + + public void changedUpdate(DocumentEvent e) { + changeFilter(e); + } + + public void insertUpdate(DocumentEvent e) { + changeFilter(e); + } + + public void removeUpdate(DocumentEvent e) { + changeFilter(e); + } + } + // + + //Use SwingWorker to asynchronously load the data + + public void loadData(String dataPath) { + // create SwingWorker which will load the data on a separate thread + OscarDataLoader loader = new OscarDataLoader( + TableDemo.class.getResource(dataPath), oscarModel); + + actionStatus.setText(getString("TableDemo.loadingStatusLabel", + "Loading data: ")); + + // display progress bar while data loads + final JProgressBar progressBar = new JProgressBar(); + statusBarLeft.add(progressBar); + loader.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if (event.getPropertyName().equals("progress")) { + int progress = ((Integer) event.getNewValue()).intValue(); + progressBar.setValue(progress); + + if (progress == 100) { + statusBarLeft.remove(progressBar); + actionStatus.setText(""); + revalidate(); + } + } + } + }); + loader.execute(); + + } + // + + protected void showMessage(String title, String message) { + JOptionPane.showMessageDialog(this, message, title, JOptionPane.INFORMATION_MESSAGE); + } + + //Use SwingWorker to asynchronously load the data + private class OscarDataLoader extends javax.swing.SwingWorker, OscarCandidate> { + private final URL oscarData; + private final OscarTableModel oscarModel; + private final List candidates = new ArrayList(); + private JLabel credits; + + private OscarDataLoader(URL oscarURL, OscarTableModel oscarTableModel) { + this.oscarData = oscarURL; + this.oscarModel = oscarTableModel; + } + + @Override + public List doInBackground() { + OscarDataParser parser = new OscarDataParser() { + @Override + protected void addCandidate(OscarCandidate candidate) { + candidates.add(candidate); + if (candidates.size() % 3 == 0) { + try { // slow it down so we can see progress :-) + Thread.sleep(1); + } catch (Exception ex) { + } + } + publish(candidate); + setProgress(100 * candidates.size() / 8545); + } + }; + parser.parseDocument(oscarData); + return candidates; + } + + // for OS X older Java 6 + /* + protected void process(List... moreCandidates) { + for(List newCandidates: moreCandidates) { + oscarModel.add(newCandidates); + } + }*/ + + //@Override + + protected void process(List moreCandidates) { + if (credits == null) { + showCredits(); + } + oscarModel.add(moreCandidates); + } + + // For older Java 6 on OS X + protected void process(OscarCandidate... moreCandidates) { + for (OscarCandidate candidate : moreCandidates) { + oscarModel.add(candidate); + } + } + + private void showCredits() { + credits = new JLabel(getString("TableDemo.credits", + "

Academy Award data
courtesy of Howard Katz

")); + credits.setFont(UIManager.getFont("Table.font").deriveFont(24f)); + credits.setHorizontalAlignment(JLabel.CENTER); + credits.setBorder(new CompoundBorder(new TitledBorder(""), + new EmptyBorder(20,20,20,20))); + dataPanel.showMessageLayer(credits, .75f); + } + @Override + protected void done() { + setProgress(100); + dataPanel.hideMessageLayer(); + } + + } + //
+ + private class IMDBLinkAction extends AbstractAction { + + public void actionPerformed(ActionEvent event) { + int row = ((Integer) event.getSource()).intValue(); + OscarCandidate candidate = oscarModel.getCandidate(oscarTable.convertRowIndexToModel(row)); + + try { + URI imdbURI = candidate.getIMDBMovieURI(); + if (imdbURI == null) { + String imdbString = IMDBLink.getMovieURIString(candidate.getMovieTitle(), + candidate.getYear()); + if (imdbString != null) { + imdbURI = new URI(imdbString); + candidate.setIMDBMovieURI(imdbURI); + } + } + if (imdbURI != null) { + DemoUtilities.browse(imdbURI); + } else { + showMessage("IMDB Link", + getString("TableDemo.imdbLinkNotFound", + "Unable to locate IMDB URL for") + "\n" + + candidate.getMovieTitle()); + } + + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + + public static void main(String args[]) { + + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + JFrame frame = new JFrame("JTable Demo"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + TableDemo demo = new TableDemo(); + frame.add(demo); + frame.setSize(700, 400); + frame.setVisible(true); + demo.start(); + } + }); + } +} \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/table/resources/TableDemo.properties b/swingset3/com/sun/swingset3/demos/table/resources/TableDemo.properties new file mode 100644 index 0000000..1210d3f --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/resources/TableDemo.properties @@ -0,0 +1,22 @@ +# Table Demo Properties + +TableDemo.accessible_description=Advanced Table Demo +TableDemo.name=Advanced Table Demo +TableDemo.title=Academy Awards Results +TableDemo.credits=

Academy Award data
courtesy of Howard Katz

+ +TableDemo.searchLabel=Search Titles and Recipients +TableDemo.winnersLabel=Show Only Winners + +TableDemo.noDataStatusLabel=No data loaded +TableDemo.loadingStatusLabel=Loading data: +TableDemo.rowCountLabel=Showing +TableDemo.searchCountLabel=Search found + +TableDemo.yearColumnTitle=Year +TableDemo.categoryColumnTitle=Award Category +TableDemo.movieTitleColumnTitle=Movie Title +TableDemo.nomineesColumnTitle=Nominee(s) + +TableDemo.imdbLinkNotFound=Unable to locate IMDB URL for + diff --git a/swingset3/com/sun/swingset3/demos/table/resources/bestpicture b/swingset3/com/sun/swingset3/demos/table/resources/bestpicture new file mode 100644 index 0000000..17460f6 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/resources/bestpicture @@ -0,0 +1,397 @@ + +1927/28 (1st) +OUTSTANDING PICTURE +* +Paramount Famous Lasky -- Wings + +1928/29 (2nd) +OUTSTANDING PICTURE +* +Metro-Goldwyn-Mayer -- The Broadway Melody +[NOTE: THIS IS NOT AN OFFICIAL NOMINATION. There were no announcements of nominations, no certificates of nomination or honorable mention, and only the winners (*) were revealed during the awards banquet on April 3, 1930.] + +1929/30 (3rd) +OUTSTANDING PRODUCTION +* +All Quiet on the Western Front -- Universal + +1930/31 (4th) +OUTSTANDING PRODUCTION +* +Cimarron -- RKO Radio + +1931/32 (5th) +OUTSTANDING PRODUCTION +* +Grand Hotel -- Metro-Goldwyn-Mayer + +1932/33 (6th) +OUTSTANDING PRODUCTION +* +Cavalcade -- Fox + +1934 (7th) +OUTSTANDING PRODUCTION +* +It Happened One Night -- Columbia + +1935 (8th) +OUTSTANDING PRODUCTION +* +Mutiny on the Bounty -- Metro-Goldwyn-Mayer + +1936 (9th) +OUTSTANDING PRODUCTION +* +The Great Ziegfeld -- Metro-Goldwyn-Mayer + +1937 (10th) +OUTSTANDING PRODUCTION +* +The Life of Emile Zola -- Warner Bros. + +1938 (11th) +OUTSTANDING PRODUCTION +* +You Can't Take It with You -- Columbia + +1939 (12th) +OUTSTANDING PRODUCTION +* +Gone with the Wind -- Selznick International Pictures + +1940 (13th) +OUTSTANDING PRODUCTION +* +Rebecca -- Selznick International Pictures + +1941 (14th) +OUTSTANDING MOTION PICTURE +* +How Green Was My Valley -- 20th Century-Fox + +1942 (15th) +OUTSTANDING MOTION PICTURE +* +Mrs. Miniver -- Metro-Goldwyn-Mayer + +1943 (16th) +OUTSTANDING MOTION PICTURE +* +Casablanca -- Warner Bros. + +1944 (17th) +BEST MOTION PICTURE +* +Going My Way -- Paramount + +1945 (18th) +BEST MOTION PICTURE +* +The Lost Weekend -- Paramount + +1946 (19th) +BEST MOTION PICTURE +* +The Best Years of Our Lives -- Samuel Goldwyn Productions + +1947 (20th) +BEST MOTION PICTURE +* +Gentleman's Agreement -- 20th Century-Fox + +1948 (21st) +BEST MOTION PICTURE +* +Hamlet -- J. Arthur Rank-Two Cities Films + +1949 (22nd) +BEST MOTION PICTURE +* +All the King's Men -- Robert Rossen Productions + +1950 (23rd) +BEST MOTION PICTURE +* +All about Eve -- 20th Century-Fox + +1951 (24th) +BEST MOTION PICTURE +* +An American in Paris -- Arthur Freed, Producer + +1952 (25th) +BEST MOTION PICTURE +* +The Greatest Show on Earth -- Cecil B. DeMille, Producer + +1953 (26th) +BEST MOTION PICTURE +* +From Here to Eternity -- Buddy Adler, Producer + +1954 (27th) +BEST MOTION PICTURE +* +On the Waterfront -- Sam Spiegel, Producer + +1955 (28th) +BEST MOTION PICTURE +* +Marty -- Harold Hecht, Producer + +1956 (29th) +BEST MOTION PICTURE +* +Around the World in 80 Days -- Michael Todd, Producer + +1957 (30th) +BEST MOTION PICTURE +* +The Bridge on the River Kwai -- Sam Spiegel, Producer + +1958 (31st) +BEST MOTION PICTURE +* +Gigi -- Arthur Freed, Producer + +1959 (32nd) +BEST MOTION PICTURE +* +Ben-Hur -- Sam Zimbalist, Producer + +1960 (33rd) +BEST MOTION PICTURE +* +The Apartment -- Billy Wilder, Producer + +1961 (34th) +BEST MOTION PICTURE +* +West Side Story -- Robert Wise, Producer + +1962 (35th) +BEST PICTURE +* +Lawrence of Arabia -- Sam Spiegel, Producer + +1963 (36th) +BEST PICTURE +* +Tom Jones -- Tony Richardson, Producer + +1964 (37th) +BEST PICTURE +* +My Fair Lady -- Jack L. Warner, Producer + +1965 (38th) +BEST PICTURE +* +The Sound of Music -- Robert Wise, Producer + +1966 (39th) +BEST PICTURE +* +A Man for All Seasons -- Fred Zinnemann, Producer + +1967 (40th) +BEST PICTURE +* +In the Heat of the Night -- Walter Mirisch, Producer + +1968 (41st) +BEST PICTURE +* +Oliver! -- John Woolf, Producer + +1969 (42nd) +BEST PICTURE +* +Midnight Cowboy -- Jerome Hellman, Producer + +1970 (43rd) +BEST PICTURE +* +Patton -- Frank McCarthy, Producer + +1971 (44th) +BEST PICTURE +* +The French Connection -- Philip D'Antoni, Producer + +1972 (45th) +BEST PICTURE +* +The Godfather -- Albert S. Ruddy, Producer + +1973 (46th) +BEST PICTURE +* +The Sting -- Tony Bill, Michael Phillips and Julia Phillips, Producers + +1974 (47th) +BEST PICTURE +* +The Godfather Part II -- Francis Ford Coppola, Producer; Gray Frederickson and Fred Roos, Co-Producers + +1975 (48th) +BEST PICTURE +* +One Flew over the Cuckoo's Nest -- Saul Zaentz and Michael Douglas, Producers + +1976 (49th) +BEST PICTURE +* +Rocky -- Irwin Winkler and Robert Chartoff, Producers + +1977 (50th) +BEST PICTURE +* +Annie Hall -- Charles H. Joffe, Producer + +1978 (51st) +BEST PICTURE +* +The Deer Hunter -- Barry Spikings, Michael Deeley, Michael Cimino and John Peverall, Producers + +1979 (52nd) +BEST PICTURE +* +Kramer vs. Kramer -- Stanley R. Jaffe, Producer + +1980 (53rd) +BEST PICTURE +* +Ordinary People -- Ronald L. Schwary, Producer + +1981 (54th) +BEST PICTURE +* +Chariots of Fire -- David Puttnam, Producer + +1982 (55th) +BEST PICTURE +* +Gandhi -- Richard Attenborough, Producer + +1983 (56th) +BEST PICTURE +* +Terms of Endearment -- James L. Brooks, Producer + +1984 (57th) +BEST PICTURE +* +Amadeus -- Saul Zaentz, Producer + +1985 (58th) +BEST PICTURE +* +Out of Africa -- Sydney Pollack, Producer + +1986 (59th) +BEST PICTURE +* +Platoon -- Arnold Kopelson, Producer + +1987 (60th) +BEST PICTURE +* +The Last Emperor -- Jeremy Thomas, Producer + +1988 (61st) +BEST PICTURE +* +Rain Man -- Mark Johnson, Producer + +1989 (62nd) +BEST PICTURE +* +Driving Miss Daisy -- Richard D. Zanuck and Lili Fini Zanuck, Producers + +1990 (63rd) +BEST PICTURE +* +Dances With Wolves -- Jim Wilson and Kevin Costner, Producers + +1991 (64th) +BEST PICTURE +* +The Silence of the Lambs -- Edward Saxon, Kenneth Utt and Ron Bozman, Producers + +1992 (65th) +BEST PICTURE +* +Unforgiven -- Clint Eastwood, Producer + +1993 (66th) +BEST PICTURE +* +Schindler's List -- Steven Spielberg, Gerald R. Molen and Branko Lustig, Producers + +1994 (67th) +BEST PICTURE +* +Forrest Gump -- Wendy Finerman, Steve Tisch and Steve Starkey, Producers + +1995 (68th) +BEST PICTURE +* +Braveheart -- Mel Gibson, Alan Ladd, Jr. and Bruce Davey, Producers + +1996 (69th) +BEST PICTURE +* +The English Patient -- Saul Zaentz, Producer + +1997 (70th) +BEST PICTURE +* +Titanic -- James Cameron and Jon Landau, Producers + +1998 (71st) +BEST PICTURE +* +Shakespeare in Love -- David Parfitt, Donna Gigliotti, Harvey Weinstein, Edward Zwick and Marc Norman, Producers + +1999 (72nd) +BEST PICTURE +* +American Beauty -- Bruce Cohen and Dan Jinks, Producers + +2000 (73rd) +BEST PICTURE +* +Gladiator -- Douglas Wick, David Franzoni and Branko Lustig, Producers + +2001 (74th) +BEST PICTURE +* +A Beautiful Mind -- Brian Grazer and Ron Howard, Producers + +2002 (75th) +BEST PICTURE +* +Chicago -- Martin Richards, Producer + +2003 (76th) +BEST PICTURE +* +The Lord of the Rings: The Return of the King -- Barrie M. Osborne, Peter Jackson and Fran Walsh, Producers + +2004 (77th) +BEST PICTURE +* +Million Dollar Baby -- Clint Eastwood, Albert S. Ruddy and Tom Rosenberg, Producers + +2005 (78th) +BEST PICTURE +* +Crash -- Paul Haggis and Cathy Schulman, Producers + +2006 (79th) +BEST PICTURE +* +The Departed -- Graham King, Producer +© Academy of Motion Picture Arts and Sciences \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/table/resources/images/TableDemo.gif b/swingset3/com/sun/swingset3/demos/table/resources/images/TableDemo.gif new file mode 100644 index 0000000..edcdeed Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/table/resources/images/TableDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/table/resources/images/goldstar.png b/swingset3/com/sun/swingset3/demos/table/resources/images/goldstar.png new file mode 100644 index 0000000..06b05e1 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/table/resources/images/goldstar.png differ diff --git a/swingset3/com/sun/swingset3/demos/table/resources/images/nominee.png b/swingset3/com/sun/swingset3/demos/table/resources/images/nominee.png new file mode 100644 index 0000000..371ff68 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/table/resources/images/nominee.png differ diff --git a/swingset3/com/sun/swingset3/demos/table/resources/oscars.xml b/swingset3/com/sun/swingset3/demos/table/resources/oscars.xml new file mode 100644 index 0000000..92d1d77 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/table/resources/oscars.xml @@ -0,0 +1 @@ +

This data has been marked up in XML and placed into the public domain by Howard Katz,

Fatdog Software Inc., 2006. It may be freely copied and distributed worldwide.

The Last Command The Way of All Flesh Emil Jannings The Noose The Patent Leather Kid Richard Barthelmess The Circus Charles Chaplin 7th Heaven Street Angel Sunrise Janet Gaynor A Ship Comes in Louise Dresser Sadie Thompson Gloria Swanson The Dove The Tempest William Cameron Menzies 7th Heaven Harry Oliver Sunrise Rochus Gliese Wings Paramount Famous Lasky 7th Heaven Fox The Racket The Caddo Company Sunrise Charles Rosher Karl Struss The Devil Dancer The Magic Flame Sadie Thompson George Barnes Two Arabian Knights Lewis Milestone Speedy Ted Wilde 7th Heaven Frank Borzage The Crowd King Vidor Sorrell and Son Herbert Brenon Wings Roy Pomeroy Ralph Hammeras Nugent Slaughter Sunrise Fox Chang Paramount Famous Lasky The Crowd Metro-Goldwyn-Mayer 7th Heaven Benjamin Glazer Glorious Betsy Anthony Coldeway The Jazz Singer Alfred Cohn Underworld Ben Hecht The Last Command Lajos Biro Joseph Farnham George Marion Jr. The Private Life of Helen of Troy Gerald Duffy In Old Arizona Warner Baxter Thunderbolt George Bancroft Alibi Chester Morris The Valiant Paul Muni The Patriot Lewis Stone Coquette Mary Pickford Madame X Ruth Chatterton The Barker Betty Compson The Letter Jeanne Eagels The Divine Lady Corinne Griffith The Broadway Melody Bessie Love The Bridge of San Luis Rey Cedric Gibbons Alibi The Awakening William Cameron Menzies Dynamite Mitchell Leisen The Patriot Hans Dreier Street Angel Harry Oliver The Broadway Melody Metro-Goldwyn-Mayer Alibi Art Cinema Hollywood Revue Metro-Goldwyn-Mayer In Old Arizona Fox The Patriot Paramount Famous Lasky White Shadows in the South Seas Clyde De Vinna The Divine Lady John Seitz Four Devils Street Angel Ernest Palmer In Old Arizona Arthur Edeson Our Dancing Daughters George Barnes The Divine Lady Frank Lloyd The Broadway Melody Harry Beaumont Drag Frank Lloyd In Old Arizona Irving Cummings Madame X Lionel Barrymore The Patriot Ernst Lubitsch Weary River Frank Lloyd The Patriot Hans Kraly The Cop Elliott Clawson In Old Arizona Tom Barry The Last of Mrs. Cheyney Hans Kraly The Leatherneck Elliott Clawson Our Dancing Daughters Josephine Lovett Sal of Singapore Elliott Clawson Skyscraper Elliott Clawson The Valiant Tom Barry A Woman of Affairs Bess Meredyth Wonder of Women Bess Meredyth Disraeli George Arliss The Green Goddess George Arliss The Big House Wallace Beery The Big Pond Maurice Chevalier The Love Parade Maurice Chevalier Bulldog Drummond Ronald Colman Condemned Ronald Colman The Rogue Song Lawrence Tibbett The Divorcee Norma Shearer The Devil's Holiday Nancy Carroll Sarah and Son Ruth Chatterton Anna Christie Greta Garbo Romance Greta Garbo Their Own Desire Norma Shearer The Trespasser Gloria Swanson King of Jazz Herman Rosse Bulldog Drummond William Cameron Menzies The Love Parade Hans Dreier Sally Jack Okey The Vagabond King Hans Dreier All Quiet on the Western Front Universal The Big House Cosmopolitan Disraeli Warner Bros. The Divorcee Metro-Goldwyn-Mayer The Love Parade Paramount Famous Lasky With Byrd at the South Pole Joseph T. Rucker Willard Van Der Veer All Quiet on the Western Front Arthur Edeson Anna Christie William Daniels Hell's Angels Gaetano Gaudio) Harry Perry The Love Parade Victor Milner All Quiet on the Western Front Lewis Milestone Anna Christie Clarence Brown The Divorcee Robert Leonard Hallelujah King Vidor The Love Parade Ernst Lubitsch Romance Clarence Brown The Big House Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer The Case of Sergeant Grischa RKO Radio Studio Sound Department John Tribby The Love Parade Paramount Famous Lasky Studio Sound Department Franklin Hansen Raffles United Artists Studio Sound Department Oscar Lagerstrom Song of the Flame First National Studio Sound Department George Groves The Big House Frances Marion All Quiet on the Western Front George Abbott Maxwell Anderson Del Andrews Disraeli Julian Josephson The Divorcee John Meehan Street of Chance Howard Estabrook A Free Soul Lionel Barrymore Skippy Jackie Cooper Cimarron Richard Dix The Royal Family of Broadway Fredric March The Front Page Adolphe Menjou Min and Bill Marie Dressler Morocco Marlene Dietrich Cimarron Irene Dunne Holiday Ann Harding A Free Soul Norma Shearer Cimarron Max Ree Just Imagine Stephen Goosson Ralph Hammeras Morocco Hans Dreier Svengali Anton Grot Whoopee! Richard Day Cimarron RKO Radio East Lynne Fox The Front Page The Caddo Company Skippy Paramount Publix Trader Horn Metro-Goldwyn-Mayer Tabu Floyd Crosby Cimarron Edward Cronjager Morocco Lee Garmes The Right to Love Charles Lang Svengali Barney "Chick" McGill Skippy Norman Taurog Cimarron Wesley Ruggles A Free Soul Clarence Brown The Front Page Lewis Milestone Morocco Josef Von Sternberg Samuel Goldwyn - United Artists Studio Sound Department Metro-Goldwyn-Mayer Studio Sound Department Paramount Publix Studio Sound Department RKO Radio Studio Sound Department Cimarron Howard Estabrook The Criminal Code Seton I. Miller Fred Niblo Jr. Holiday Horace Jackson Little Caesar Francis Faragoh Robert N. Lee Skippy Joseph L. Mankiewicz Sam Mintz The Dawn Patrol John Monk Saunders The Doorway to Hell Rowland Brown Laughter Harry d'Abbadie d'Arrast Douglas Doty Donald Ogden Stewart The Public Enemy John Bright Kubec Glasmon Smart Money Lucien Hubbard Joseph Jackson The Champ Wallace Beery Dr. Jekyll and Mr. Hyde Fredric March The Guardsman Alfred Lunt The Sin of Madelon Claudet Helen Hayes Emma Marie Dressler The Guardsman Lynn Fontanne Transatlantic Gordon Wiles Arrowsmith Richard Day A Nous La Liberte Lazare Meerson Grand Hotel Metro-Goldwyn-Mayer Arrowsmith Samuel Goldwyn Bad Girl Fox The Champ Metro-Goldwyn-Mayer Five Star Final First National One Hour with You Paramount Publix Shanghai Express Paramount Publix The Smiling Lieutenant Paramount Publix Shanghai Express Lee Garmes Arrowsmith Ray June Dr. Jekyll and Mr. Hyde Karl Struss Bad Girl Frank Borzage The Champ King Vidor Shanghai Express Josef Von Sternberg Flowers and Trees Walt Disney It's Got Me Again Leon Schlesinger Mickey's Orphans Walt Disney The Music Box Hal Roach The Loud Mouth Mack Sennett Scratch-As-Catch-Can RKO Radio Stout Hearts and Willing Hands RKO Radio Wrestling Swordfish Mack Sennett Screen Souvenirs Paramount Publix Swing High Metro-Goldwyn-Mayer Metro-Goldwyn-Mayer Studio Sound Department Paramount Publix Studio Sound Department RKO Radio Studio Sound Department Warner Bros.-First National Studio Sound Department Bad Girl Edwin Burke Arrowsmith Sidney Howard Dr. Jekyll and Mr. Hyde Percy Heath Samuel Hoffenstein The Champ Frances Marion Lady and Gent Grover Jones William Slavens McNutt The Star Witness Lucien Hubbard What Price Hollywood? Jane Murfin Adela Rogers St. Johns The Private Life of Henry VIII Charles Laughton Berkeley Square Leslie Howard I Am a Fugitive from a Chain Gang Paul Muni Morning Glory Katharine Hepburn Lady for a Day May Robson Cavalcade Diana Wynyard Cavalcade William S. Darling A Farewell to Arms Roland Anderson Hans Dreier When Ladies Meet Cedric Gibbons Charles Barton Scott Beal Charles Dorian Fred Fox Gordon Hollingshead Dewey Starkey William Tummel Al Alborn Sidney S. Brod Bunny Dull Percy Ikerd Arthur Jacobson Eddie Killey Joe McDonough W. J. Reiter Frank X. Shaw Benjamin Silvey John S. Waters Cavalcade Fox 42nd Street Warner Bros. A Farewell to Arms Paramount I Am a Fugitive from a Chain Gang Warner Bros. Lady for a Day Columbia Little Women RKO Radio The Private Life of Henry VIII London Films She Done Him Wrong Paramount Smilin' Through Metro-Goldwyn-Mayer State Fair Fox A Farewell to Arms Charles Bryant Lang Jr. Reunion in Vienna George J. Folsey The Sign of the Cross Karl Struss Cavalcade Frank Lloyd Lady for a Day Frank Capra Little Women George Cukor The Three Little Pigs Walt Disney Building a Building Walt Disney The Merry Old Soul Walter Lantz So This Is Harris Louis Brock Mister Mugg Warren Doane A Preferred List Louis Brock Krakatoa Joe Rock Menu Pete Smith The Sea Educational A Farewell to Arms Paramount Studio Sound Department Franklin B. Hansen 42nd Street Warner Bros. Studio Sound Department Nathan Levinson Gold Diggers of 1933 Warner Bros. Studio Sound Department Nathan Levinson I Am a Fugitive from a Chain Gang Warner Bros. Studio Sound Department Nathan Levinson Little Women Victor Heerman Sarah Y. Mason Lady for a Day Robert Riskin State Fair Paul Green Sonya Levien One Way Passage Robert Lord The Prizefighter and the Lady Frances Marion Rasputin and the Empress Charles MacArthur It Happened One Night Clark Gable The Affairs of Cellini Frank Morgan The Thin Man William Powell It Happened One Night Claudette Colbert Of Human Bondage Bette Davis One Night of Love Grace Moore The Barretts of Wimpole Street Norma Shearer The Merry Widow Cedric Gibbons Frederic Hope The Affairs of Cellini Richard Day The Gay Divorcee Carroll Clark Van Nest Polglase Viva Villa! John Waters Cleopatra Cullen Tate Imitation of Life Scott Beal It Happened One Night Columbia The Barretts of Wimpole Street Metro-Goldwyn-Mayer Cleopatra Paramount Flirtation Walk First National The Gay Divorcee RKO Radio Here Comes the Navy Warner Bros. The House of Rothschild 20th Century Imitation of Life Universal One Night of Love Columbia The Thin Man Metro-Goldwyn-Mayer Viva Villa! Metro-Goldwyn-Mayer The White Parade Jesse L. Lasky Cleopatra Victor Milner The Affairs of Cellini Charles Rosher Operator 13 George Folsey It Happened One Night Frank Capra One Night of Love Victor Schertzinger The Thin Man W. S. Van Dyke Eskimo Conrad Nervig Cleopatra Anne Bauchens One Night of Love Gene Milford One Night of Love Columbia Studio Music Department Louis Silvers Gus Kahn Victor Schertzinger The Gay Divorcee RKO Radio Studio Music Department Samuel Hoffenstein Max Steiner Kenneth Webb The Lost Patrol RKO Radio Studio Music Department Max Steiner Captain Blood Warner Bros.-First National Studio Music Department Erich Wolfgang Korngold Leo Forbstein Mutiny on the Bounty Metro-Goldwyn-Mayer Studio Music Department Nat W. Finston Herbert Stothart Peter Ibbetson Paramount Studio Music Department Irvin Talbot Ernst Toch The Continental The Gay Divorcee Con Conrad Herb Magidson Carioca Flying Down to Rio Edward Eliscu Gus Kahn Vincent Youmans Love in Bloom She Loves Me Not Ralph Rainger Leo Robin The Tortoise and the Hare Walt Disney Holiday Land Charles Mintz Jolly Little Elves Walter Lantz La Cucaracha Kenneth Macgowan Men in Black Jules White What, No Men! Warner Bros. City of Wax Horace Woodard Stacy Woodard Bosom Friends Skibo Productions Strikes and Spares Pete Smith One Night of Love Columbia Studio Sound Department John Livadary The Affairs of Cellini United Artists Studio Sound Department Thomas T. Moulton Cleopatra Paramount Studio Sound Department Franklin B. Hansen Flirtation Walk Warner Bros.-First National Studio Sound Department Nathan Levinson The Gay Divorcee RKO Radio Studio Sound Department Carl Dreher Imitation of Life Universal Studio Sound Department Theodore Soderberg Viva Villa! Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer The White Parade Fox Studio Sound Department E. H. Hansen It Happened One Night Robert Riskin The Thin Man Frances Goodrich Albert Hackett Viva Villa! Ben Hecht Manhattan Melodrama Arthur Caesar Hide-Out Mauri Grashin The Richest Girl in the World Norman Krasna The Informer Victor McLaglen Mutiny on the Bounty Clark Gable Mutiny on the Bounty Charles Laughton Black Fury Paul Muni Mutiny on the Bounty Franchot Tone Dangerous Bette Davis Escape Me Never Elisabeth Bergner Private Worlds Claudette Colbert Alice Adams Katharine Hepburn Becky Sharp Miriam Hopkins The Dark Angel Merle Oberon The Dark Angel Richard Day The Lives of a Bengal Lancer Roland Anderson Hans Dreier Top Hat Carroll Clark Van Nest Polglase The Lives of a Bengal Lancer Clem Beauchamp Paul Wing David Copperfield Joseph Newman Les Miserables Eric Stacey A Midsummer Night's Dream Sherry Shourds Mutiny on the Bounty Metro-Goldwyn-Mayer Alice Adams RKO Radio Broadway Melody of 1936 Metro-Goldwyn-Mayer Captain Blood Cosmopolitan David Copperfield Metro-Goldwyn-Mayer The Informer RKO Radio Les Miserables 20th Century The Lives of a Bengal Lancer Paramount A Midsummer Night's Dream Warner Bros. Naughty Marietta Metro-Goldwyn-Mayer Ruggles of Red Gap Paramount Top Hat RKO Radio A Midsummer Night's Dream Hal Mohr Barbary Coast Ray June The Crusades Victor Milner Les Miserables Gregg Toland Broadway Melody of 1936 Folies Bergere Dave Gould All the King's Horses Big Broadcast of 1936 LeRoy Prinz Broadway Hostess Go Into Your Dance Bobby Connolly Gold Diggers of 1935 Busby Berkeley King of Burlesque Sammy Lee Top Hat Hermes Pan She Benjamin Zemach The Informer John Ford Captain Blood Michael Curtiz The Lives of a Bengal Lancer Henry Hathaway Mutiny on the Bounty Frank Lloyd A Midsummer Night's Dream Ralph Dawson David Copperfield Robert J. Kern The Informer George Hively Les Miserables Barbara McLean The Lives of a Bengal Lancer Ellsworth Hoagland Mutiny on the Bounty Margaret Booth The Informer RKO Radio Studio Music Department Max Steiner Lullaby of Broadway Gold Diggers of 1935 Al Dubin Harry Warren Cheek to Cheek Top Hat Irving Berlin Lovely to Look at Roberta Dorothy Fields Jerome Kern Jimmy McHugh Three Orphan Kittens Walt Disney The Calico Dragon Harman-Ising Who Killed Cock Robin? Walt Disney How To Sleep Jack Chertok Oh, My Nerves Jules White Tit for Tat Hal Roach Wings Over Mt. Everest Gaumont British and Skibo Productions Audioscopiks Pete Smith Camera Thrills Universal Naughty Marietta Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer $1,000 a Minute Republic Studio Sound Department The Bride of Frankenstein Universal Studio Sound Department Gilbert Kurland Captain Blood Warner Bros.-First National Studio Sound Department Nathan Levinson The Dark Angel United Artists Studio Sound Department Thomas T. Moulton I Dream Too Much RKO Radio Studio Sound Department Carl Dreher The Lives of a Bengal Lancer Paramount Studio Sound Department Franklin B. Hansen Love Me Forever Columbia Studio Sound Department John Livadary Thanks a Million 20th Century-Fox Studio Sound Department E. H. Hansen The Scoundrel Ben Hecht Charles MacArthur Broadway Melody of 1936 Moss Hart G-Men Gregory Rogers The Gay Deception Stephen Avery Don Hartman The Informer Dudley Nichols Captain Blood Casey Robinson The Lives of a Bengal Lancer Achmed Abdullah John L. Balderston Grover Jones William Slavens McNutt Waldemar Young Mutiny on the Bounty Jules Furthman Talbot Jennings Carey Wilson The Story of Louis Pasteur Paul Muni Mr. Deeds Goes to Town Gary Cooper Dodsworth Walter Huston My Man Godfrey William Powell San Francisco Spencer Tracy Come and Get It Walter Brennan My Man Godfrey Mischa Auer Pigskin Parade Stuart Erwin Romeo and Juliet Basil Rathbone The General Died at Dawn Akim Tamiroff The Great Ziegfeld Luise Rainer Theodora Goes Wild Irene Dunne Valiant Is the Word for Carrie Gladys George My Man Godfrey Carole Lombard Romeo and Juliet Norma Shearer Anthony Adverse Gale Sondergaard The Gorgeous Hussy Beulah Bondi My Man Godfrey Alice Brady These Three Bonita Granville Dodsworth Maria Ouspenskaya Dodsworth Richard Day Anthony Adverse Anton Grot The Great Ziegfeld Cedric Gibbons Eddie Imazu Edwin B. Willis Lloyds of London William S. Darling The Magnificent Brute Albert S. D'Agostino Jack Otterson Romeo and Juliet Cedric Gibbons Frederic Hope Edwin B. Willis Winterset Perry Ferguson The Charge of the Light Brigade Jack Sullivan Anthony Adverse William Cannon The Garden of Allah Eric G. Stacey The Last of the Mohicans Clem Beauchamp San Francisco Joseph Newman The Great Ziegfeld Metro-Goldwyn-Mayer Anthony Adverse Warner Bros. Dodsworth Samuel Goldwyn Libeled Lady Metro-Goldwyn-Mayer Mr. Deeds Goes to Town Columbia Romeo and Juliet Metro-Goldwyn-Mayer San Francisco Metro-Goldwyn-Mayer The Story of Louis Pasteur Cosmopolitan A Tale of Two Cities Metro-Goldwyn-Mayer Three Smart Girls Universal Anthony Adverse Gaetano Gaudio The General Died at Dawn Victor Milner The Gorgeous Hussy George Folsey The Great Ziegfeld Seymour Felix Born to Dance Dave Gould Cain and Mabel Bobby Connolly Dancing Pirate Russell Lewis Gold Diggers of 1937 Busby Berkeley One in a Million Jack Haskell Swing Time Hermes Pan Mr. Deeds Goes to Town Frank Capra Dodsworth William Wyler The Great Ziegfeld Robert Z. Leonard My Man Godfrey Gregory La Cava San Francisco W. S. Van Dyke Anthony Adverse Ralph Dawson Come and Get It Edward Curtiss The Great Ziegfeld William S. Gray Lloyds of London Barbara McLean A Tale of Two Cities Conrad A. Nervig Theodora Goes Wild Otto Meyer Anthony Adverse Warner Bros. Studio Music Department Erich Wolfgang Korngold Leo Forbstein The Charge of the Light Brigade Max Steiner, Warner Bros. Studio Music Department Max Steiner Leo Forbstein The Garden of Allah Selznick International Pictures Music Department Max Steiner The General Died at Dawn Paramount Studio Music Department Werner Janssen Boris Morros Winterset RKO Radio Studio Music Department Nathaniel Shilkret The Way You Look Tonight Swing Time Dorothy Fields Jerome Kern A Melody from the Sky Trail of the Lonesome Pine Louis Alter Sidney Mitchell Did I Remember Suzy Harold Adamson Walter Donaldson I've Got You Under My Skin Born To Dance Cole Porter Pennies from Heaven Pennies from Heaven Johnny Burke Arthur Johnston When Did You Leave Heaven Sing, Baby, Sing Walter Bullock Richard A. Whiting The Country Cousin Walt Disney Old Mill Pond Harman-Ising Sinbad the Sailor Paramount Bored of Education Hal Roach Moscow Moods Paramount Wanted, a Master Pete Smith The Public Pays Metro-Goldwyn-Mayer Double Or Nothing Warner Bros. Dummy Ache RKO Radio Give Me Liberty Warner Bros. La Fiesta De Santa Barbara Lewis Lewyn Popular Science J-6-2 Paramount San Francisco Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Banjo on My Knee 20th Century-Fox Studio Sound Department E. H. Hansen The Charge of the Light Brigade Warner Bros. Studio Sound Department Nathan Levinson Dodsworth United Artists Studio Sound Department Thomas T. Moulton General Spanky Hal Roach Studio Sound Department Elmer A. Raguse Mr. Deeds Goes to Town Columbia Studio Sound Department John Livadary The Texas Rangers Paramount Studio Sound Department Franklin B. Hansen That Girl from Paris Paramount Studio Sound Department J. O. Aalberg Three Smart Girls Universal Studio Sound Department Homer G. Tasker The Story of Louis Pasteur Pierre Collings Sheridan Gibney Fury Norman Krasna The Great Ziegfeld William Anthony McGuire San Francisco Robert Hopkins Three Smart Girls Adele Comandini The Story of Louis Pasteur Pierre Collings Sheridan Gibney After the Thin Man Frances Goodrich Albert Hackett Dodsworth Sidney Howard Mr. Deeds Goes to Town Robert Riskin My Man Godfrey Eric Hatch Morris Ryskind Captains Courageous Spencer Tracy Conquest Charles Boyer A Star Is Born Fredric March Night Must Fall Robert Montgomery The Life of Emile Zola Paul Muni The Life of Emile Zola Joseph Schildkraut The Awful Truth Ralph Bellamy The Hurricane Thomas Mitchell Lost Horizon H. B. Warner Topper Roland Young The Good Earth Luise Rainer The Awful Truth Irene Dunne Camille Greta Garbo A Star Is Born Janet Gaynor Stella Dallas Barbara Stanwyck In Old Chicago Alice Brady Stage Door Andrea Leeds Stella Dallas Anne Shirley Dead End Claire Trevor Night Must Fall Dame May Whitty Lost Horizon Stephen Goosson Conquest Cedric Gibbons William Horning A Damsel in Distress Carroll Clark Dead End Richard Day Every Day's a Holiday Wiard Ihnen The Life of Emile Zola Anton Grot Manhattan Merry-Go-Round John Victor Mackay The Prisoner of Zenda Lyle Wheeler Souls at Sea Roland Anderson Hans Dreier Walter Wanger's Vogues of 1938 Alexander Toluboff Wee Willie Winkie William S. Darling David Hall You're a Sweetheart Jack Otterson In Old Chicago Robert Webb The Life of Emile Zola Russ Saunders Lost Horizon C. C. Coleman Jr. Souls at Sea Hal Walker A Star Is Born Eric Stacey The Life of Emile Zola Warner Bros. The Awful Truth Columbia Captains Courageous Metro-Goldwyn-Mayer Dead End Samuel Goldwyn The Good Earth Metro-Goldwyn-Mayer In Old Chicago 20th Century-Fox Lost Horizon Columbia One Hundred Men and a Girl Universal Stage Door RKO Radio A Star Is Born Selznick International Pictures The Good Earth Karl Freund Dead End Gregg Toland Wings Over Honolulu Joseph Valentine A Damsel in Distress Hermes Pan Ali Baba Goes to Town Sammy Lee A Day at the Races Dave Gould Ready, Willing and Able Bobby Connolly Thin Ice Harry Losee Waikiki Wedding LeRoy Prinz Varsity Show Busby Berkeley The Awful Truth Leo McCarey The Good Earth Sidney Franklin The Life of Emile Zola William Dieterle Stage Door Gregory La Cava A Star Is Born William Wellman Lost Horizon Gene Havlick Gene Milford The Awful Truth Al Clark Captains Courageous Elmo Vernon The Good Earth Basil Wrangell One Hundred Men and a Girl Bernard W. Burton One Hundred Men and a Girl Universal Studio Music Department Charles Previn The Hurricane Samuel Goldwyn Studio Music Department Alfred Newman In Old Chicago 20th Century-Fox Studio Music Department Louis Silvers The Life of Emile Zola Warner Bros. Studio Music Department Max Steiner Leo Forbstein Lost Horizon Columbia Studio Music Department Morris Stoloff Dimitri Tiomkin Make a Wish Principal Productions Dr. Hugo Riesenfeld Maytime Metro-Goldwyn-Mayer Studio Music Department Nat W. Finston Herbert Stothart Portia on Trial Republic Studio Music Department Alberto Colombo The Prisoner of Zenda Selznick International Pictures Music Department Alfred Newman Quality Street RKO Radio Studio Music Department Roy Webb Snow White and the Seven Dwarfs Walt Disney Studio Music Department Frank Churchill Leigh Harline Paul J. Smith Something to Sing about Grand National Studio Music Department C. Bakaleinikoff Victor Schertzinger Souls at Sea Paramount Studio Music Department W. Franke Harling Boris Morros Milan Roder Way Out West Hal Roach Studio Music Department Marvin Hatley Sweet Leilani Waikiki Wedding Harry Owens Remember Me Mr. Dodd Takes the Air Al Dubin Harry Warren That Old Feeling Walter Wanger's Vogues of 1938 Lew Brown Sammy Fain They Can't Take That Away from Me Shall We Dance George Gershwin Ira Gershwin Whispers in the Dark Artists and Models Frederick Hollander Leo Robin The Old Mill Walt Disney Educated Fish Paramount The Little Match Girl Charles Mintz The Private Life of the Gannets Skibo Productions A Night at the Movies Metro-Goldwyn-Mayer Romance of Radium Pete Smith Torture Money Metro-Goldwyn-Mayer Deep South RKO Radio Should Wives Work? RKO Radio Penny Wisdom Pete Smith The Man Without a Country Warner Bros. Popular Science J-7-1 Paramount The Hurricane Hal Roach Studio Music Department Marvin Hatley Thomas T. Moulton The Girl Said No Grand National Studio Sound Department A. E. Kaye Hitting a New High RKO Radio Studio Sound Department John Aalberg In Old Chicago 20th Century-Fox Studio Sound Department E. H. Hansen The Life of Emile Zola Warner Bros. Studio Sound Department Nathan Levinson Lost Horizon Columbia Studio Sound Department John Livadary Maytime Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer One Hundred Men and a Girl Universal Studio Sound Department Homer G. Tasker Topper Hal Roach Studio Sound Department Elmer A. Raguse Wells Fargo Paramount Studio Sound Department Loren L. Ryder A Star Is Born Robert Carson William A. Wellman Black Legion Robert Lord In Old Chicago Niven Busch The Life of Emile Zola Heinz Herald Geza Herczeg One Hundred Men and a Girl Hans Kraly The Life of Emile Zola Heinz Herald Geza Herczeg Norman Reilly Raine The Awful Truth Vina Delmar Captains Courageous Marc Connelly John Lee Mahin Dale Van Every Stage Door Morris Ryskind Anthony Veiller A Star Is Born Alan Campbell Robert Carson Dorothy Parker Boys Town Spencer Tracy Algiers Charles Boyer Angels with Dirty Faces James Cagney The Citadel Robert Donat Pygmalion Leslie Howard Kentucky Walter Brennan Four Daughters John Garfield Algiers Gene Lockhart Marie Antoinette Robert Morley If I Were King Basil Rathbone Jezebel Bette Davis White Banners Fay Bainter Pygmalion Wendy Hiller Marie Antoinette Norma Shearer Three Comrades Margaret Sullavan Jezebel Fay Bainter Of Human Hearts Beulah Bondi Merrily We Live Billie Burke You Can't Take It with You Spring Byington The Great Waltz Miliza Korjus The Adventures of Robin Hood Carl J. Weyl The Adventures of Tom Sawyer Lyle Wheeler Alexander's Ragtime Band Bernard Herzbrun Boris Leven Algiers Alexander Toluboff Carefree Van Nest Polglase The Goldwyn Follies Richard Day Holiday Lionel Banks Stephen Goosson If I Were King Hans Dreier John Goodman Mad about Music Jack Otterson Marie Antoinette Cedric Gibbons Merrily We Live Charles D. Hall You Can't Take It with You Columbia The Adventures of Robin Hood Warner Bros.-First National Alexander's Ragtime Band 20th Century-Fox Boys Town Metro-Goldwyn-Mayer The Citadel Metro-Goldwyn-Mayer Four Daughters Warner Bros.-First National Grand Illusion Realization D'Art Cinematographique Jezebel Warner Bros. Pygmalion Metro-Goldwyn-Mayer Test Pilot Metro-Goldwyn-Mayer The Great Waltz Joseph Ruttenberg Algiers James Wong Howe Army Girl Ernest Miller Harry Wild The Buccaneer Victor Milner Jezebel Ernest Haller Mad about Music Joseph Valentine Merrily We Live Norbert Brodine Suez Peverell Marley Vivacious Lady Robert de Grasse You Can't Take It with You Joseph Walker The Young in Heart Leon Shamroy You Can't Take It with You Frank Capra Angels with Dirty Faces Michael Curtiz Boys Town Norman Taurog The Citadel King Vidor Four Daughters Michael Curtiz The Adventures of Robin Hood Ralph Dawson Alexander's Ragtime Band Barbara McLean The Great Waltz Tom Held Test Pilot Tom Held You Can't Take It with You Gene Havlick The Adventures of Robin Hood Erich Wolfgang Korngold Army Girl Victor Young Block-Heads Marvin Hatley Blockade Werner Janssen Breaking the Ice Victor Young The Cowboy and the Lady Alfred Newman If I Were King Richard Hageman Marie Antoinette Herbert Stothart Pacific Liner Russell Bennett Suez Louis Silvers The Young in Heart Franz Waxman Alexander's Ragtime Band Alfred Newman Carefree Victor Baravalle Girls' School Morris Stoloff Gregory Stone The Goldwyn Follies Alfred Newman Jezebel Max Steiner Mad about Music Charles Previn Frank Skinner Storm Over Bengal Cy Feuer Sweethearts Herbert Stothart There Goes My Heart Marvin Hatley Tropic Holiday Boris Morros The Young in Heart Franz Waxman Thanks for the Memory The Big Broadcast of 1938 Ralph Rainger Leo Robin A Mist Over the Moon The Lady Objects Oscar Hammerstein II Ben Oakland Always and Always Mannequin Chet Forrest Edward Ward Bob Wright Change Partners Carefree Irving Berlin Dust Under Western Stars Johnny Marvin Jeepers Creepers Going Places Johnny Mercer Harry Warren Merrily We Live Merrily We Live Phil Charig Arthur Quenzer My Own That Certain Age Harold Adamson Jimmy McHugh Now It Can Be Told Alexander's Ragtime Band Irving Berlin The Cowboy and the Lady The Cowboy and the Lady Lionel Newman Arthur Quenzer Ferdinand the Bull Walt Disney Brave Little Tailor Walt Disney Good Scouts Walt Disney Hunky and Spunky Paramount Mother Goose Goes Hollywood Walt Disney That Mothers Might Live Metro-Goldwyn-Mayer The Great Heart Metro-Goldwyn-Mayer Timber Toppers 20th Century-Fox Declaration of Independence Warner Bros. Swingtime in the Movies Warner Bros. They're Always Caught Metro-Goldwyn-Mayer The Cowboy and the Lady United Artists Studio Sound Department Thomas T. Moulton Army Girl Republic Studio Sound Department Charles L. Lootens Four Daughters Warner Bros. Studio Sound Department Nathan Levinson If I Were King Paramount Studio Sound Department Loren L. Ryder Merrily We Live Hal Roach Studio Sound Department Elmer A. Raguse Suez 20th Century-Fox Studio Sound Department Edmund H. Hansen Sweethearts Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer That Certain Age Universal Studio Sound Departmentr Bernard B. Brown Vivacious Lady RKO Radio Studio Sound Department John Aalberg You Can't Take It with You Columbia Studio Sound Department John Livadary Boys Town Eleanore Griffin Dore Schary Alexander's Ragtime Band Irving Berlin Angels with Dirty Faces Rowland Brown Blockade John Howard Lawson Mad about Music Marcella Burke Frederick Kohner Test Pilot Frank Wead Pygmalion Ian Dalrymple Cecil Lewis W. P. Lipscomb George Bernard Shaw Boys Town John Meehan Dore Schary The Citadel Ian Dalrymple Elizabeth Hill Frank Wead Four Daughters Lenore Coffee Julius J. Epstein You Can't Take It with You Robert Riskin Goodbye, Mr. Chips Robert Donat Gone with the Wind Clark Gable Wuthering Heights Laurence Olivier Babes in Arms Mickey Rooney Mr. Smith Goes to Washington James Stewart Stagecoach Thomas Mitchell Juarez Brian Aherne Mr. Smith Goes to Washington Harry Carey Beau Geste Brian Donlevy Mr. Smith Goes to Washington Claude Rains Gone with the Wind Vivien Leigh Dark Victory Bette Davis Love Affair Irene Dunne Ninotchka Greta Garbo Goodbye, Mr. Chips Greer Garson Gone with the Wind Hattie McDaniel Gone with the Wind Olivia de Havilland Wuthering Heights Geraldine Fitzgerald Drums Along the Mohawk Edna May Oliver Love Affair Maria Ouspenskaya Gone with the Wind Lyle Wheeler Beau Geste Hans Dreier Robert Odell Captain Fury Charles D. Hall First Love Martin Obzina Jack Otterson Love Affair Al Herman Van Nest Polglase Man of Conquest John Victor Mackay Mr. Smith Goes to Washington Lionel Banks The Private Lives of Elizabeth and Essex Anton Grot The Rains Came William Darling George Dudley Stagecoach Alexander Toluboff The Wizard of Oz Cedric Gibbons William A. Horning Wuthering Heights James Basevi Gone with the Wind Selznick International Pictures Dark Victory Warner Bros.-First National Goodbye, Mr. Chips Metro-Goldwyn-Mayer Love Affair RKO Radio Mr. Smith Goes to Washington Columbia Ninotchka Metro-Goldwyn-Mayer Of Mice and Men Hal Roach Stagecoach Walter Wanger The Wizard of Oz Metro-Goldwyn-Mayer Wuthering Heights Samuel Goldwyn Wuthering Heights Gregg Toland First Love Joseph Valentine The Great Victor Herbert Victor Milner Gunga Din Joseph H. August Intermezzo Gregg Toland Juarez Tony Gaudio Lady of the Tropics George Folsey Of Mice and Men Norbert Brodine Only Angels Have Wings Joseph Walker The Rains Came Arthur Miller Stagecoach Bert Glennon Gone with the Wind Ernest Haller Ray Rennahan Drums Along the Mohawk Bert Glennon Ray Rennahan Four Feathers Osmond Borradaile Georges Perinal The Mikado Bernard Knowles William V. Skall The Private Lives of Elizabeth and Essex W. Howard Greene Sol Polito The Wizard of Oz Hal Rosson Gone with the Wind Victor Fleming Goodbye, Mr. Chips Sam Wood Mr. Smith Goes to Washington Frank Capra Stagecoach John Ford Wuthering Heights William Wyler Gone with the Wind Hal C. Kern James E. Newcom Goodbye, Mr. Chips Charles Frend Mr. Smith Goes to Washington Al Clark Gene Havlick The Rains Came Barbara McLean Stagecoach Otho Lovering Dorothy Spencer The Wizard of Oz Herbert Stothart Dark Victory Max Steiner Eternally Yours Werner Janssen Golden Boy Victor Young Gone with the Wind Max Steiner Gulliver's Travels Victor Young The Man in the Iron Mask Lud Gluskin Lucien Moraweck Man of Conquest Victor Young Nurse Edith Cavell Anthony Collins Of Mice and Men Aaron Copland The Rains Came Alfred Newman Wuthering Heights Alfred Newman Stagecoach Richard Hageman Frank Harling John Leipold Leo Shuken Babes in Arms Roger Edens George E. Stoll First Love Charles Previn The Great Victor Herbert Phil Boutelje Arthur Lange The Hunchback of Notre Dame Alfred Newman Intermezzo Lou Forbes Mr. Smith Goes to Washington Dimitri Tiomkin Of Mice and Men Aaron Copland The Private Lives of Elizabeth and Essex Erich Wolfgang Korngold She Married a Cop Cy Feuer Swanee River Louis Silvers They Shall Have Music Alfred Newman Way Down South Victor Young Over the Rainbow The Wizard of Oz Harold Arlen E. Y. Harburg Faithful Forever Gulliver's Travels Ralph Rainger Leo Robin I Poured My Heart Into a Song Second Fiddle Irving Berlin Wishing Love Affair Buddy de Sylva The Ugly Duckling Walt Disney Detouring America Warner Bros. Peace on Earth Metro-Goldwyn-Mayer The Pointer Walt Disney Busy Little Bears Paramount Information Please RKO Radio Prophet Without Honor Metro-Goldwyn-Mayer Sword Fishing Warner Bros. Sons of Liberty Warner Bros. Drunk Driving Metro-Goldwyn-Mayer Five Times Five RKO Radio When Tomorrow Comes Universal Studio Sound Department Bernard B. Brown Balalaika Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Gone with the Wind Samuel Goldwyn Studio Sound Department Thomas T. Moulton Goodbye, Mr. Chips Denham Studio Sound Department A. W. Watkins The Great Victor Herbert Paramount Studio Sound Department Loren L. Ryder The Hunchback of Notre Dame RKO Radio Studio Sound Department John Aalberg Man of Conquest Republic Studio Sound Department Charles L. Lootens Mr. Smith Goes to Washington Columbia Studio Sound Department John Livadary Of Mice and Men Hal Roach Studio Sound Department Elmer A. Raguse The Private Lives of Elizabeth and Essex Warner Bros. Studio Sound Department Nathan Levinson The Rains Came 20th Century-Fox Studio Sound Department E. H. Hansen The Rains Came E. H. Hansen Fred Sersen Gone with the Wind Fred Albin John R. Cosgrove Arthur Johns Only Angels Have Wings Roy Davidson Edwin C. Hahn The Private Lives of Elizabeth and Essex Byron Haskin Nathan Levinson Topper Takes a Trip Roy Seawright Union Pacific Farciot Edouart Gordon Jennings Loren Ryder The Wizard of Oz A. Arnold Gillespie Douglas Shearer Mr. Smith Goes to Washington Lewis R. Foster Bachelor Mother Felix Jackson Love Affair Mildred Cram Leo McCarey Ninotchka Melchior Lengyel Young Mr. Lincoln Lamar Trotti Gone with the Wind Sidney Howard Goodbye, Mr. Chips Eric Maschwitz R. C. Sherriff Claudine West Mr. Smith Goes to Washington Sidney Buchman Ninotchka Charles Brackett Walter Reisch Billy Wilder Wuthering Heights Ben Hecht Charles MacArthur The Philadelphia Story James Stewart The Great Dictator Charles Chaplin The Grapes of Wrath Henry Fonda Abe Lincoln in Illinois Raymond Massey Rebecca Laurence Olivier The Westerner Walter Brennan Foreign Correspondent Albert Basserman They Knew What They Wanted William Gargan The Great Dictator Jack Oakie The Letter James Stephenson Kitty Foyle Ginger Rogers The Letter Bette Davis Rebecca Joan Fontaine The Philadelphia Story Katharine Hepburn Our Town Martha Scott The Grapes of Wrath Jane Darwell Rebecca Judith Anderson The Philadelphia Story Ruth Hussey All This, and Heaven Too Barbara O'Neil Primrose Path Marjorie Rambeau Pride and Prejudice Cedric Gibbons Paul Groesse Arise, My Love Hans Dreier Robert Usher Arizona Lionel Banks Robert Peterson The Boys from Syracuse John Otterson The Dark Command John Victor Mackay Foreign Correspondent Alexander Golitzen Lillian Russell Richard Day Joseph C. Wright My Favorite Wife Mark-Lee Kirk Van Nest Polglase My Son, My Son! John DuCasse Schulze Our Town Lewis J. Rachmil Rebecca Lyle Wheeler The Sea Hawk Anton Grot The Westerner James Basevi The Thief of Bagdad Vincent Korda Bitter Sweet John S. Detlie Cedric Gibbons Down Argentine Way Richard Day Joseph C. Wright North West Mounted Police Roland Anderson Hans Dreier Rebecca Selznick International Pictures All This, and Heaven Too Warner Bros. Foreign Correspondent Walter Wanger The Grapes of Wrath 20th Century-Fox The Great Dictator Charles Chaplin Kitty Foyle RKO Radio The Letter Warner Bros. The Long Voyage Home Argosy-Wanger Our Town Sol Lesser The Philadelphia Story Metro-Goldwyn-Mayer Rebecca George Barnes Abe Lincoln in Illinois James Wong Howe All This, and Heaven Too Ernest Haller Arise, My Love Charles B. Lang Jr. Boom Town Harold Rosson Foreign Correspondent Rudolph Maté The Letter Gaetano (Tony) Gaudio The Long Voyage Home Gregg Toland Spring Parade Joseph Valentine Waterloo Bridge Joseph Ruttenberg The Thief of Bagdad Georges Perinal Bitter Sweet Allen Davey Oliver T. Marsh The Blue Bird Arthur Miller Ray Rennahan Down Argentine Way Ray Rennahan Leon Shamroy North West Mounted Police W. Howard Greene Victor Milner Northwest Passage William V. Skall Sidney Wagner The Grapes of Wrath John Ford Kitty Foyle Sam Wood The Letter William Wyler The Philadelphia Story George Cukor Rebecca Alfred Hitchcock North West Mounted Police Anne Bauchens The Grapes of Wrath Robert E. Simpson The Letter Warren Low The Long Voyage Home Sherman Todd Rebecca Hal C. Kern Pinocchio Leigh Harline Paul J. Smith Ned Washington Arizona Victor Young The Dark Command Victor Young The Fight for Life Louis Gruenberg The Great Dictator Meredith Willson The House of the Seven Gables Frank Skinner The Howards of Virginia Richard Hageman The Letter Max Steiner The Long Voyage Home Richard Hageman The Mark of Zorro Alfred Newman My Favorite Wife Roy Webb North West Mounted Police Victor Young One Million B.C. Werner Heymann Our Town Aaron Copland Rebecca Franz Waxman The Thief of Bagdad Miklos Rozsa Waterloo Bridge Herbert Stothart Tin Pan Alley Alfred Newman Arise, My Love Victor Young Hit Parade of 1941 Cy Feuer Irene Anthony Collins Our Town Aaron Copland The Sea Hawk Erich Wolfgang Korngold Second Chorus Artie Shaw Spring Parade Charles Previn Strike Up the Band Roger Edens Georgie Stoll When You Wish Upon a Star Pinocchio Leigh Harline Ned Washington Down Argentine Way Down Argentine Way Mack Gordon Harry Warren I'd Know You Anywhere You'll Find Out Jimmy McHugh Johnny Mercer It's a Blue World Music in My Heart Chet Forrest Bob Wright Love of My Life Second Chorus Johnny Mercer Artie Shaw Only Forever Rhythm on the River John Burke James Monaco Our Love Affair Strike Up the Band Roger Edens Arthur Freed Waltzing in the Clouds Spring Parade Gus Kahn Robert Stolz Who Am I? Hit Parade of 1941 Walter Bullock Jule Styne The Great Mcginty Preston Sturges Angels Over Broadway Ben Hecht Dr. Ehrlich's Magic Bullet Norman Burnside Heinz Herald John Huston Foreign Correspondent Charles Bennett Joan Harrison The Great Dictator Charles Chaplin The Milky Way Metro-Goldwyn-Mayer Puss Gets the Boot Metro-Goldwyn-Mayer A Wild Hare Leon Schlesinger Quicker `N a Wink Pete Smith London Can Take It Warner Bros. More about Nostradamus Metro-Goldwyn-Mayer Siege RKO Radio Teddy, the Rough Rider Warner Bros. Eyes of the Navy Metro-Goldwyn-Mayer Service with the Colors Warner Bros. Strike Up the Band Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Behind the News Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Captain Caution Hal Roach Studio Sound Department Elmer A. Raguse The Grapes of Wrath 20th Century-Fox Studio Sound Department E. H. Hansen The Howards of Virginia General Service Sound Department Jack Whitney Kitty Foyle RKO Radio Studio Sound Department John Aalberg North West Mounted Police Paramount Studio Sound Department Loren L. Ryder Our Town Samuel Goldwyn Studio Sound Department Thomas T. Moulton The Sea Hawk Warner Bros. Studio Sound Department Nathan Levinson Spring Parade Universal Studio Sound Department Bernard B. Brown Too Many Husbands Columbia Studio Sound Department John Livadary The Thief of Bagdad Lawrence Butler Jack Whitney The Blue Bird E. H. Hansen Fred Sersen Boom Town A. Arnold Gillespie Douglas Shearer The Boys from Syracuse Bernard B. Brown John P. Fulton Joseph Lapis Dr. Cyclops Farciot Edouart Gordon Jennings Foreign Correspondent Paul Eagler Thomas T. Moulton The Invisible Man Returns Bernard B. Brown John P. Fulton William Hedgecock The Long Voyage Home R. O. Binger R. T. Layton Thomas T. Moulton One Million B.C. Elmer Raguse Roy Seawright Rebecca Jack Cosgrove Arthur Johns The Sea Hawk Byron Haskin Nathan Levinson Swiss Family Robinson John O. Aalberg Vernon L. Walker Typhoon Farciot Edouart Gordon Jennings Loren Ryder Women in War William Bradford Howard J. Lydecker Herbert Norsch Ellis J. Thackery Arise, My Love Benjamin Glazer John S. Toldy Comrade X Walter Reisch Edison, the Man Hugo Butler Dore Schary My Favorite Wife Leo McCarey Bella Spewack Samuel Spewack The Westerner Stuart N. Lake The Philadelphia Story Donald Ogden Stewart The Grapes of Wrath Nunnally Johnson Kitty Foyle Dalton Trumbo The Long Voyage Home Dudley Nichols Rebecca Joan Harrison Robert E. Sherwood Sergeant York Gary Cooper Penny Serenade Cary Grant All That Money Can Buy Walter Huston Here Comes Mr. Jordan Robert Montgomery Citizen Kane Orson Welles How Green Was My Valley Donald Crisp Sergeant York Walter Brennan The Devil and Miss Jones Charles Coburn Here Comes Mr. Jordan James Gleason The Maltese Falcon Sydney Greenstreet Suspicion Joan Fontaine The Little Foxes Bette Davis Hold Back the Dawn Olivia de Havilland Blossoms in the Dust Greer Garson Ball of Fire Barbara Stanwyck The Great Lie Mary Astor How Green Was My Valley Sara Allgood The Little Foxes Patricia Collinge The Little Foxes Teresa Wright Sergeant York Margaret Wycherly How Green Was My Valley Richard Day Nathan Juran Thomas Little Citizen Kane Perry Ferguson Van Nest Polglase Al Fields Darrell Silvera The Flame of New Orleans Martin Obzina Jack Otterson Russell A. Gausman Hold Back the Dawn Hans Dreier Robert Usher Sam Comer Ladies in Retirement Lionel Banks George Montgomery The Little Foxes Stephen Goosson Howard Bristol Sergeant York John Hughes Fred MacLean Sis Hopkins The Son of Monte Cristo John DuCasse Schulze Edward G. Boyle Sundown Alexander Golitzen Richard Irvine That Hamilton Woman Vincent Korda Julia Heron When Ladies Meet Randall Duell Cedric Gibbons Edwin B. Willis Blossoms in the Dust Cedric Gibbons Urie McCleary Edwin B. Willis Blood and Sand Richard Day Joseph C. Wright Thomas Little Louisiana Purchase Raoul Pene du Bois Stephen A. Seymour How Green Was My Valley 20th Century-Fox Blossoms in the Dust Metro-Goldwyn-Mayer Citizen Kane Mercury Here Comes Mr. Jordan Columbia Hold Back the Dawn Paramount The Little Foxes Samuel Goldwyn The Maltese Falcon Warner Bros. One Foot in Heaven Warner Bros. Sergeant York Warner Bros. Suspicion RKO Radio How Green Was My Valley Arthur Miller The Chocolate Soldier Karl Freund Citizen Kane Gregg Toland Dr. Jekyll and Mr. Hyde Joseph Ruttenberg Here Comes Mr. Jordan Joseph Walker Hold Back the Dawn Leo Tover Sergeant York Sol Polito Sun Valley Serenade Edward Cronjager Sundown Charles Lang That Hamilton Woman Rudolph Maté Blood and Sand Ernest Palmer Ray Rennahan Aloma of the South Seas Wilfred M. Cline William Snyder Karl Struss Billy the Kid William V. Skall Leonard Smith Blossoms in the Dust Karl Freund W. Howard Greene Dive Bomber Bert Glennon Louisiana Purchase Harry Hallenberger Ray Rennahan How Green Was My Valley John Ford Citizen Kane Orson Welles Here Comes Mr. Jordan Alexander Hall The Little Foxes William Wyler Sergeant York Howard Hawks Churchill's Island National Film Board of Canada Adventures in the Bronx Film Associates Bomber United States Office for Emergency Management Film Unit Christmas Under Fire British Ministry of Information Letter from Home British Ministry of Information Life of a Thoroughbred Truman Talley Norway in Revolt The March of Time A Place To Live Philadelphia Housing Association Russian Soil Amkino Soldiers of the Sky Truman Talley War Clouds in the Pacific National Film Board of Canada Sergeant York William Holmes Citizen Kane Robert Wise Dr. Jekyll and Mr. Hyde Harold F. Kress How Green Was My Valley James B. Clark The Little Foxes Daniel Mandell All That Money Can Buy Bernard Herrmann Back Street Frank Skinner Ball of Fire Alfred Newman Cheers for Miss Bishop Edward Ward Citizen Kane Bernard Herrmann Dr. Jekyll and Mr. Hyde Franz Waxman Hold Back the Dawn Victor Young How Green Was My Valley Alfred Newman King of the Zombies Edward Kay Ladies in Retirement Morris Stoloff Ernst Toch The Little Foxes Meredith Willson Lydia Miklos Rozsa Mercy Island Cy Feuer Walter Scharf Sergeant York Max Steiner So Ends Our Night Louis Gruenberg Sundown Miklos Rozsa Suspicion Franz Waxman Tanks a Million Edward Ward That Uncertain Feeling Werner Heymann This Woman Is Mine Richard Hageman Dumbo Frank Churchill Oliver Wallace All-American Co-Ed Edward Ward Birth of the Blues Robert Emmett Dolan Buck Privates Charles Previn The Chocolate Soldier Bronislau Kaper Herbert Stothart Ice-Capades Cy Feuer The Strawberry Blonde Heinz Roemheld Sun Valley Serenade Emil Newman Sunny Anthony Collins You'll Never Get Rich Morris Stoloff The Last Time I Saw Paris Lady Be Good Oscar Hammerstein II Jerome Kern Baby Mine Dumbo Frank Churchill Ned Washington Be Honest with Me Ridin' on a Rainbow Gene Autry Fred Rose Blues in the Night Blues in the Night Harold Arlen Johnny Mercer Boogie Woogie Bugle Boy of Company B Buck Privates Hugh Prince Don Raye Chattanooga Choo Choo Sun Valley Serenade Mack Gordon Harry Warren Dolores Las Vegas Nights Lou Alter Frank Loesser Out of the Silence All-American Co-Ed Lloyd B. Norlind Since I Kissed My Baby Goodbye You'll Never Get Rich Cole Porter Citizen Kane Herman J. Mankiewicz Orson Welles The Devil and Miss Jones Norman Krasna Sergeant York Harry Chandlee Abem Finkel John Huston Howard Koch Tall, Dark and Handsome Karl Tunberg Darrell Ware Tom, Dick and Harry Paul Jarrico Lend a Paw Walt Disney Boogie Woogie Bugle Boy of Company B Walter Lantz Hiawatha's Rabbit Hunt Leon Schlesinger How War Came Columbia The Night before Christmas Metro-Goldwyn-Mayer Rhapsody in Rivets Leon Schlesinger Rhythm in the Ranks George Pal The Rookie Bear Metro-Goldwyn-Mayer Superman Max Fleischer Truant Officer Donald Walt Disney Of Pups and Puzzles Metro-Goldwyn-Mayer Army Champions Pete Smith Beauty and the Beach Paramount Down on the Farm Paramount Forty Boys and a Song Warner Bros. Kings of the Turf Warner Bros. Sagebrush and Silver 20th Century-Fox Main Street on the March! Metro-Goldwyn-Mayer Alive in the Deep Woodard Productions, Inc. Forbidden Passage Metro-Goldwyn-Mayer The Gay Parisian Warner Bros. The Tanks are Coming United States Army That Hamilton Woman General Service Sound Department Jack Whitney Appointment for Love Universal Studio Sound Department Bernard B. Brown Ball of Fire Samuel Goldwyn Studio Sound Department Thomas T. Moulton The Chocolate Soldier Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Citizen Kane RKO Radio Studio Sound Department John Aalberg The Devil Pays Off Republic Studio Sound Department Charles Lootens How Green Was My Valley 20th Century-Fox Studio Sound Department E. H. Hansen The Men in Her Life Columbia Studio Sound Department John Livadary Sergeant York Paramount Studio Sound Department Loren Ryder Skylark Paramount Studio Sound Department Loren Ryder Topper Returns Hal Roach Studio Sound Department Elmer Raguse I Wanted Wings Farciot Edouart Gordon Jennings Louis Mesenkop Aloma of the South Seas Farciot Edouart Gordon Jennings Louis Mesenkop Dive Bomber Byron Haskin Nathan Levinson Flight Command A. Arnold Gillespie Douglas Shearer The Invisible Woman John Fulton John Hall The Sea Wolf Byron Haskin Nathan Levinson That Hamilton Woman Lawrence Butler William H. Wilmarth Topper Returns Elmer Raguse Roy Seawright A Yank in the R.a.F. E. H. Hansen Fred Sersen Here Comes Mr. Jordan Harry Segall Ball of Fire Thomas Monroe Billy Wilder The Lady Eve Monckton Hoffe Meet John Doe Richard Connell Robert Presnell Night Train Gordon Wellesley Here Comes Mr. Jordan Sidney Buchman Seton I. Miller Hold Back the Dawn Charles Brackett Billy Wilder How Green Was My Valley Philip Dunne The Little Foxes Lillian Hellman The Maltese Falcon John Huston Yankee Doodle Dandy James Cagney Random Harvest Ronald Colman The Pride of the Yankees Gary Cooper Mrs. Miniver Walter Pidgeon The Pied Piper Monty Woolley Johnny Eager Van Heflin Wake Island William Bendix Yankee Doodle Dandy Walter Huston Tortilla Flat Frank Morgan Mrs. Miniver Henry Travers Mrs. Miniver Greer Garson Now, Voyager Bette Davis Woman of the Year Katharine Hepburn My Sister Eileen Rosalind Russell The Pride of the Yankees Teresa Wright Mrs. Miniver Teresa Wright Now, Voyager Gladys Cooper The Magnificent Ambersons Agnes Moorehead Random Harvest Susan Peters Mrs. Miniver Dame May Whitty This Above All Richard Day Joseph Wright Thomas Little George Washington Slept Here Mark-Lee Kirk Max Parker Casey Roberts The Magnificent Ambersons Albert S. D'Agostino Al Fields Darrell Silvera The Pride of the Yankees Perry Ferguson Howard Bristol Random Harvest Randall Duell Cedric Gibbons Jack Moore Edwin B. Willis The Shanghai Gesture Boris Leven Boris Leven Silver Queen Ralph Berger Emile Kuri The Spoilers John B. Goodman Jack Otterson Russell A. Gausman Edward R. Robinson Take a Letter, Darling Roland Anderson Hans Dreier Sam Comer The Talk of the Town Lionel Banks Rudolph Sternad Fay Babcock My Gal Sal Richard Day Joseph Wright Thomas Little Arabian Nights Alexander Golitzen Jack Otterson Russell A. Gausman Ira S. Webb Captains of the Clouds Ted Smith Casey Roberts Jungle Book Vincent Korda Julia Heron Reap the Wild Wind Roland Anderson Hans Dreier George Sawley Mrs. Miniver Metro-Goldwyn-Mayer The Invaders Ortus Kings Row Warner Bros. The Magnificent Ambersons Mercury The Pied Piper 20th Century-Fox The Pride of the Yankees Samuel Goldwyn Random Harvest Metro-Goldwyn-Mayer The Talk of the Town Columbia Wake Island Paramount Yankee Doodle Dandy Warner Bros. Mrs. Miniver Joseph Ruttenberg Kings Row James Wong Howe The Magnificent Ambersons Stanley Cortez Moontide Charles Clarke The Pied Piper Edward Cronjager The Pride of the Yankees Rudolph Maté Take a Letter, Darling John Mescall The Talk of the Town Ted Tetzlaff Ten Gentlemen from West Point Leon Shamroy This Above All Arthur Miller The Black Swan Leon Shamroy Arabian Nights W. Howard Greene Milton Krasner William V. Skall Captains of the Clouds Sol Polito Jungle Book W. Howard Greene Reap the Wild Wind Victor Milner William V. Skall To the Shores of Tripoli Edward Cronjager William V. Skall Mrs. Miniver William Wyler Kings Row Sam Wood Random Harvest Mervyn LeRoy Wake Island John Farrow Yankee Doodle Dandy Michael Curtiz The Battle of Midway United States Navy Kokoda Front Line! Australian News & Information Bureau Moscow Strikes Back Artkino Prelude to War United States Army Special Services Africa, Prelude to Victory The March of Time Combat Report United States Army Signal Corps Conquer By the Clock Frederic Ullman Jr. The Grain That Built a Hemisphere Walt Disney Henry Browne, Farmer United States Department of Agriculture High Stakes in the East The Netherlands Information Bureau High Over the Borders National Film Board of Canada Inside Fighting China National Film Board of Canada It's Everybody's War United States Office of War Information Listen to Britain British Ministry of Information Little Belgium Belgian Ministry of Information Little Isles of Freedom Edgar Loew Victor Stoloff Mr. Blabbermouth! United States Office of War Information Mr. Gardenia Jones United States Office of War Information The New Spirit Walt Disney The Price of Victory William H. Pine A Ship Is Born United States Merchant Marine Twenty-One Miles British Ministry of Information We Refuse To Die William C. Thomas White Eagle Concanen Films Winning Your Wings United States Army Air Force The Pride of the Yankees Daniel Mandell Mrs. Miniver Harold F. Kress The Talk of the Town Otto Meyer This Above All Walter Thompson Yankee Doodle Dandy George Amy Now, Voyager Max Steiner Arabian Nights Frank Skinner Bambi Frank Churchill Edward Plumb The Black Swan Alfred Newman The Corsican Brothers Dimitri Tiomkin Flying Tigers Victor Young The Gold Rush Max Terr I Married a Witch Roy Webb Joan of Paris Roy Webb Jungle Book Miklos Rozsa Klondike Fury Edward Kay The Pride of the Yankees Leigh Harline Random Harvest Herbert Stothart The Shanghai Gesture Richard Hageman Silver Queen Victor Young Take a Letter, Darling Victor Young The Talk of the Town Frederick Hollander Morris Stoloff To Be Or Not To Be Werner Heymann Yankee Doodle Dandy Ray Heindorf Heinz Roemheld Flying with Music Edward Ward For Me and My Gal Roger Edens Georgie Stoll Holiday Inn Robert Emmett Dolan It Started with Eve Charles Previn Hans Salter Johnny Doughboy Walter Scharf My Gal Sal Alfred Newman You Were Never Lovelier Leigh Harline White Christmas Holiday Inn Irving Berlin Always in My Heart Always in My Heart Kim Gannon Ernesto Lecuona Dearly Beloved You Were Never Lovelier Jerome Kern Johnny Mercer How about You? Babes on Broadway Ralph Freed Burton Lane I've Got a Gal in Kalamazoo Orchestra Wives Mack Gordon Harry Warren It Seems I Heard That Song before Youth on Parade Sammy Cahn Jule Styne Love Is a Song Bambi Frank Churchill Larry Morey Pennies for Peppino Flying with Music Chet Forrest Edward Ward Bob Wright Pig Foot Pete Hellzapoppin' Gene de Paul Don Raye There's a Breeze on Lake Louise The Mayor of 44th Street Mort Greene Harry Revel Woman of the Year Michael Kanin Ring Lardner Jr. One of Our Aircraft Is Missing Michael Powell Emeric Pressburger Road to Morocco Frank Butler Don Hartman Wake Island W. R. Burnett Frank Butler The War Against Mrs. Hadley George Oppenheimer Der Fuehrer's Face Walt Disney All Out for "V" 20th Century-Fox Blitz Wolf Metro-Goldwyn-Mayer Juke Box Jamboree Walter Lantz Pigs in a Polka Leon Schlesinger Tulips Shall Grow George Pal Speaking of Animals and Their Families Paramount Desert Wonderland 20th Century-Fox Marines in the Making Pete Smith United States Marine Band Warner Bros. Beyond the Line of Duty Warner Bros. Don't Talk Metro-Goldwyn-Mayer Private Smith of the U.S.a. RKO Radio Yankee Doodle Dandy Warner Bros. Studio Sound Department Nathan Levinson Arabian Nights Universal Studio Sound Department Bernard B. Brown Bambi Walt Disney Studio Sound Department Sam Slyfield Flying Tigers Republic Studio Sound Department Daniel Bloomberg Friendly Enemies Sound Service, Inc. Jack Whitney The Gold Rush RCA Sound James Fields Mrs. Miniver Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Once Upon a Honeymoon RKO Radio Studio Sound Department Steve Dunn The Pride of the Yankees Samuel Goldwyn Studio Sound Department Thomas T. Moulton Road to Morocco Paramount Studio Sound Department Loren Ryder This Above All 20th Century-Fox Studio Sound Department E. H. Hansen You Were Never Lovelier Columbia Studio Sound Department John Livadary Reap the Wild Wind Farciot Edouart Gordon Jennings The Black Swan Roger Heman George Leverett Fred Sersen Desperate Journey Byron Haskin Nathan Levinson Flying Tigers Daniel J. Bloomberg Howard Lydecker Invisible Agent Bernard B. Brown John Fulton Jungle Book Lawrence Butler William H. Wilmarth Mrs. Miniver A. Arnold Gillespie Warren Newcombe Douglas Shearer The Navy Comes Through James G. Stewart Vernon L. Walker One of Our Aircraft Is Missing Ronald Neame C. C. Stevens The Pride of the Yankees Ray Binger Jack Cosgrove Thomas T. Moulton The Invaders Emeric Pressburger Holiday Inn Irving Berlin The Pride of the Yankees Paul Gallico The Talk of the Town Sidney Harmon Yankee Doodle Dandy Robert Buckner Mrs. Miniver George Froeschel James Hilton Claudine West Arthur Wimperis The Invaders Rodney Ackland Emeric Pressburger The Pride of the Yankees Herman J. Mankiewicz Jo Swerling Random Harvest George Froeschel Claudine West Arthur Wimperis The Talk of the Town Sidney Buchman Irwin Shaw Watch on the Rhine Paul Lukas Casablanca Humphrey Bogart For Whom the Bell Tolls Gary Cooper Madame Curie Walter Pidgeon The Human Comedy Mickey Rooney The More the Merrier Charles Coburn The Song of Bernadette Charles Bickford Sahara J. Carrol Naish Casablanca Claude Rains For Whom the Bell Tolls Akim Tamiroff The Song of Bernadette Jennifer Jones The More the Merrier Jean Arthur For Whom the Bell Tolls Ingrid Bergman The Constant Nymph Joan Fontaine Madame Curie Greer Garson For Whom the Bell Tolls Katina Paxinou The Song of Bernadette Gladys Cooper So Proudly We Hail! Paulette Goddard The Song of Bernadette Anne Revere Watch on the Rhine Lucile Watson The Song of Bernadette James Basevi William Darling Thomas Little Five Graves to Cairo Hans Dreier Ernst Fegte Bertram Granger Flight for Freedom Carroll Clark Albert S. D'Agostino Harley Miller Darrell Silvera Madame Curie Cedric Gibbons Paul Groesse Hugh Hunt Edwin B. Willis Mission to Moscow Carl Weyl George J. Hopkins The North Star Perry Ferguson Howard Bristol Phantom of the Opera Alexander Golitzen John B. Goodman Russell A. Gausman Ira S. Webb For Whom the Bell Tolls Haldane Douglas Hans Dreier Bertram Granger The Gang's All Here James Basevi Joseph C. Wright Thomas Little This Is the Army John Hughes Lt. John Koenig George J. Hopkins Thousands Cheer Daniel Cathcart Cedric Gibbons Jacques Mersereau Edwin B. Willis Casablanca Warner Bros. For Whom the Bell Tolls Paramount Heaven Can Wait 20th Century-Fox The Human Comedy Metro-Goldwyn-Mayer In Which We Serve Two Cities Madame Curie Metro-Goldwyn-Mayer The More the Merrier Columbia The Ox-Bow Incident 20th Century-Fox The Song of Bernadette 20th Century-Fox Watch on the Rhine Warner Bros. The Song of Bernadette Arthur Miller Air Force Elmer Dyer James Wong Howe Charles Marshall Casablanca Arthur Edeson Corvette K-225 Tony Gaudio Five Graves to Cairo John Seitz The Human Comedy Harry Stradling Madame Curie Joseph Ruttenberg The North Star James Wong Howe Sahara Rudolph Maté So Proudly We Hail! Charles Lang Phantom of the Opera W. Howard Greene Hal Mohr For Whom the Bell Tolls Ray Rennahan Heaven Can Wait Edward Cronjager Hello, Frisco, Hello Charles G. Clarke Allen Davey Lassie Come Home Leonard Smith Thousands Cheer George Folsey Casablanca Michael Curtiz Heaven Can Wait Ernst Lubitsch The Human Comedy Clarence Brown The More the Merrier George Stevens The Song of Bernadette Henry King Desert Victory British Ministry of Information Baptism of Fire United States Army The Battle of Russia United States Department of War Special Service Division For God and Country United States Army Pictorial Service Report from the Aleutians United States Army Pictorial Service Silent Village British Ministry of Information War Department Report United States Office of Strategic Services Field Photographic Bureau We've Come a Long, Long Way Negro Marches On, Inc. December 7th United States Navy Bismarck Convoy Smashed Australian Department of Information Film Unit Children of Mars RKO Radio Day of Battle United States Office of War Information Domestic Motion Picture Bureau The Dutch Tradition National Film Board of Canada Kill Or Be Killed British Ministry of Information The Labor Front National Film Board of Canada Land of My Mother Polish Information Centre Life Line United States Army Pictorial Service Plan for Destruction Metro-Goldwyn-Mayer The Rear Gunner United States Department of War Servant of a Nation Union of South Africa Swedes in America United States Office of War Information Overseas Motion Picture Bureau Task Force United States Coast Guard To the People of the United States Walter Wanger Tomorrow We Fly United States Navy Bureau of Aeronautics The Voice That Thrilled the World Warner Bros. Water - Friend Or Enemy Walt Disney Wings Up United States Army Air Force 1st Motion Picture Unit Youth in Crisis The March of Time Air Force George Amy Casablanca Owen Marks Five Graves to Cairo Doane Harrison For Whom the Bell Tolls John Link Sherman Todd The Song of Bernadette Barbara McLean The Song of Bernadette Alfred Newman The Amazing Mrs. Holliday Hans J. Salter Frank Skinner Casablanca Max Steiner Commandos Strike at Dawn Louis Gruenberg Morris Stoloff The Fallen Sparrow C. Bakaleinikoff Roy Webb For Whom the Bell Tolls Victor Young Hangmen Also Die Hanns Eisler Hi Diddle Diddle Phil Boutelje In Old Oklahoma Walter Scharf Johnny Come Lately Leigh Harline The Kansan Gerard Carbonara Lady of Burlesque Arthur Lange Madame Curie Herbert Stothart The Moon and Sixpence Dimitri Tiomkin The North Star Aaron Copland Victory Through Air Power Edward H. Plumb Paul J. Smith Oliver G. Wallace This Is the Army Ray Heindorf Coney Island Alfred Newman Hit Parade of 1943 Walter Scharf Phantom of the Opera Edward Ward Saludos Amigos Edward H. Plumb Paul J. Smith Charles Wolcott The Sky's the Limit Leigh Harline Something to Shout about Morris Stoloff Stage Door Canteen Frederic E. Rich Star Spangled Rhythm Robert Emmett Dolan Thousands Cheer Herbert Stothart You'll Never Know Hello, Frisco, Hello Mack Gordon Harry Warren A Change of Heart Hit Parade of 1943 Harold Adamson Jule Styne Black Magic Star Spangled Rhythm Harold Arlen Johnny Mercer Happiness Is a Thing Called Joe Cabin in the Sky Harold Arlen E. Y. Harburg My Shining Hour The Sky's the Limit Harold Arlen Johnny Mercer Saludos Amigos Saludos Amigos Ned Washington Charles Wolcott Say a Pray'r for the Boys Over There Hers To Hold Jimmy McHugh Herb Magidson They're Either Too Young Or Too Old Thank Your Lucky Stars Frank Loesser Arthur Schwartz We Mustn't Say Goodbye Stage Door Canteen Al Dubin James Monaco You'd Be So Nice To Come Home to Something To Shout About Cole Porter Princess O'Rourke Norman Krasna Air Force Dudley Nichols In Which We Serve Noel Coward The North Star Lillian Hellman So Proudly We Hail! Allan Scott Yankee Doodle Mouse Frederick Quimby The 500 Hats of Bartholomew Cubbins George Pal The Dizzy Acrobat Walter Lantz Greetings Bait! Leon Schlesinger Imagination Dave Fleischer Reason and Emotion Walt Disney Amphibious Fighters Grantland Rice Cavalcade of Dance with Veloz and Yolanda Gordon Hollingshead Champions Carry on Edmund Reek Hollywood in Uniform Ralph Staub Seeing Hands Pete Smith Heavenly Music Jerry Bresler Sam Coslow Letter to a Hero Frederic Ullman Jr. Mardi Gras Walter MacEwen Women at War Gordon Hollingshead This Land Is Mine RKO Radio Studio Sound Department Stephen Dunn Hangmen Also Die Sound Service, Inc. Jack Whitney In Old Oklahoma Republic Studio Sound Department Daniel J. Bloomberg Madame Curie Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer The North Star Samuel Goldwyn Studio Sound Department Thomas T. Moulton Phantom of the Opera Universal Studio Sound Department Bernard B. Brown Riding High Paramount Studio Sound Department Loren L. Ryder Sahara Columbia Studio Sound Department John Livadary Saludos Amigos Walt Disney Studio Sound Department C. O. Slyfield So This Is Washington RCA Sound J. L. Fields The Song of Bernadette 20th Century-Fox Studio Sound Department E. H. Hansen This Is the Army Warner Bros. Studio Sound Department Nathan Levinson Crash Dive Roger Heman Fred Sersen Air Force Hans Koenekamp Nathan Levinson Rex Wimpy Bombardier Roy Granville James G. Stewart Vernon L. Walker The North Star R. O. Binger Thomas T. Moulton Clarence Slifer So Proudly We Hail! George Dutton Farciot Edouart Gordon Jennings Stand By for Action A. Arnold Gillespie Donald Jahraus Michael Steinore The Human Comedy William Saroyan Action in the North Atlantic Guy Gilpatric Destination Tokyo Steve Fisher The More the Merrier Frank Ross Robert Russell Shadow of a Doubt Gordon McDonell Casablanca Julius J. Epstein Philip G. Epstein Howard Koch Holy Matrimony Nunnally Johnson The More the Merrier Richard Flournoy Lewis R. Foster Frank Ross Robert Russell The Song of Bernadette George Seaton Watch on the Rhine Dashiell Hammett Going My Way Bing Crosby Gaslight Charles Boyer Going My Way Barry Fitzgerald None But the Lonely Heart Cary Grant Wilson Alexander Knox Going My Way Barry Fitzgerald The Seventh Cross Hume Cronyn Mr. Skeffington Claude Rains Laura Clifton Webb Since You Went Away Monty Woolley Gaslight Ingrid Bergman Since You Went Away Claudette Colbert Mr. Skeffington Bette Davis Mrs. Parkington Greer Garson Double Indemnity Barbara Stanwyck None But the Lonely Heart Ethel Barrymore Since You Went Away Jennifer Jones Gaslight Angela Lansbury Dragon Seed Aline MacMahon Mrs. Parkington Agnes Moorehead Gaslight William Ferrari Cedric Gibbons Paul Huldschinsky Edwin B. Willis Address Unknown Lionel Banks Walter Holscher Joseph Kish The Adventures of Mark Twain John J. Hughes Fred MacLean Casanova Brown Perry Ferguson Julia Heron Laura Leland Fuller Lyle Wheeler Thomas Little No Time for Love Hans Dreier Robert Usher Sam Comer Since You Went Away Mark-Lee Kirk Victor A. Gangelin Song of the Open Road Step Lively Carroll Clark Albert S. D'Agostino Claude Carpenter Darrell Silvera Wilson Wiard Ihnen Thomas Little The Climax Alexander Golitzen John B. Goodman Russell A. Gausman Ira S. Webb Cover Girl Lionel Banks Cary Odell Fay Babcock The Desert Song Charles Novi Jack McConaghy Kismet Daniel B. Cathcart Cedric Gibbons Richard Pefferle Edwin B. Willis Lady in the Dark Hans Dreier Raoul Pene du Bois Ray Moyer The Princess and the Pirate Ernst Fegte Howard Bristol Going My Way Paramount Double Indemnity Paramount Gaslight Metro-Goldwyn-Mayer Since You Went Away Selznick International Pictures Wilson 20th Century-Fox Laura Joseph LaShelle Double Indemnity John Seitz Dragon Seed Sidney Wagner Gaslight Joseph Ruttenberg Going My Way Lionel Lindon Lifeboat Glen MacWilliams Since You Went Away Stanley Cortez Lee Garmes Thirty Seconds Over Tokyo Harold Rosson Robert Surtees The Uninvited Charles Lang The White Cliffs of Dover George Folsey Wilson Leon Shamroy Cover Girl Allen M. Davey Rudolph Maté Home in Indiana Edward Cronjager Kismet Charles Rosher Lady in the Dark Ray Rennahan Meet Me in St. Louis George Folsey Going My Way Leo McCarey Double Indemnity Billy Wilder Laura Otto Preminger Lifeboat Alfred Hitchcock Wilson Henry King The Fighting Lady United States Navy Resisting Enemy Interrogation United States Army Air Force With the Marines at Tarawa United States Marine Corps Arturo Toscanini United States Office of War Information Overseas Motion Picture Bureau New Americans RKO Radio Wilson Barbara McLean Going My Way Leroy Stone Janie Owen Marks None But the Lonely Heart Roland Gross Since You Went Away Hal C. Kern James E. Newcom Since You Went Away Max Steiner Address Unknown Morris Stoloff Ernst Toch The Adventures of Mark Twain Max Steiner The Bridge of San Luis Rey Dimitri Tiomkin Casanova Brown Arthur Lange Christmas Holiday H. J. Salter Double Indemnity Miklos Rozsa The Fighting Seabees Walter Scharf Roy Webb The Hairy Ape Michel Michelet Edward Paul It Happened Tomorrow Robert Stolz Jack London Frederic Efrem Rich Kismet Herbert Stothart None But the Lonely Heart C. Bakaleinikoff Hanns Eisler The Princess and the Pirate David Rose Summer Storm Karl Hajos Three Russian Girls Franke Harling Up in Mabel's Room Edward Paul Voice in the Wind Michel Michelet Wilson Alfred Newman Woman of the Town Miklos Rozsa Cover Girl Carmen Dragon Morris Stoloff Brazil Walter Scharf Higher and Higher C. Bakaleinikoff Hollywood Canteen Ray Heindorf Irish Eyes are Smiling Alfred Newman Knickerbocker Holiday Werner R. Heymann Kurt Weill Lady in the Dark Robert Emmett Dolan Lady, Let's Dance Edward Kay Meet Me in St. Louis Georgie Stoll The Merry Monahans H. J. Salter Minstrel Man Leo Erdody Ferde Grofe Sensations of 1945 Mahlon Merrick Song of the Open Road Charles Previn Up in Arms Louis Forbes Ray Heindorf Swinging on a Star Going My Way Johnny Burke James Van Heusen I Couldn't Sleep a Wink Last Night Higher and Higher Harold Adamson Jimmy McHugh I'll Walk Alone Follow the Boys Sammy Cahn Jule Styne I'm Making Believe Sweet and Lowdown Mack Gordon James V. Monaco Long Ago and Far Away Cover Girl Ira Gershwin Jerome Kern Now I Know Up in Arms Harold Arlen Ted Koehler Remember Me to Carolina Minstrel Man Harry Revel Paul Webster Rio De Janeiro Brazil Ary Barroso Ned Washington Silver Shadows and Golden Dreams Lady, Let's Dance Charles Newman Lew Pollack Sweet Dreams Sweetheart Hollywood Canteen M. K. Jerome Ted Koehler The Trolley Song Meet Me in St. Louis Ralph Blane Hugh Martin Too Much in Love Song of the Open Road Kim Gannon Walter Kent Wilson Lamar Trotti Hail the Conquering Hero Preston Sturges The Miracle of Morgan's Creek Preston Sturges Two Girls and a Sailor Richard Connell Gladys Lehman Wing and a Prayer Jerome Cady Mouse Trouble Frederick C. Quimby And To Think I Saw It on Mulberry Street George Pal Dog, Cat and Canary Screen Gems Fish Fry Walter Lantz How To Play Football Walt Disney My Boy Johnny Paul Terry Swooner Crooner Warner Bros. Who's Who in Animal Land Jerry Fairbanks Blue Grass Gentlemen Edmund Reek Jammin' the Blues Gordon Hollingshead Movie Pests Pete Smith Screen Snapshots' 50th Anniversary of Motion Pictures Ralph Staub I Won't Play Gordon Hollingshead Bombalera Louis Harris Main Street Today Jerry Bresler Herbert Moulton Wilson 20th Century-Fox Studio Sound Department E. H. Hansen Brazil Republic Studio Sound Department Daniel J. Bloomberg Casanova Brown Samuel Goldwyn Studio Sound Department Thomas T. Moulton Cover Girl Columbia Studio Sound Department John Livadary Double Indemnity Paramount Studio Sound Department Loren L. Ryder His Butler's Sister Universal Studio Sound Department Bernard B. Brown Hollywood Canteen Warner Bros. Studio Sound Department Nathan Levinson It Happened Tomorrow Sound Service, Inc. Jack Whitney Kismet Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Music in Manhattan RKO Radio Studio Sound Department Stephen Dunn Voice in the Wind RCA Sound W. M. Dalgleish Thirty Seconds Over Tokyo A. Arnold Gillespie Donald Jahraus Warren Newcombe Douglas Shearer The Adventures of Mark Twain John Crouse Paul Detlefsen Nathan Levinson Days of Glory Roy Granville James G. Stewart Vernon L. Walker Secret Command David Allen Ray Cory Harry Kusnick Russell Malmgren Robert Wright Since You Went Away John R. Cosgrove Arthur Johns The Story of Dr. Wassell George Dutton Farciot Edouart Gordon Jennings Wilson Roger Heman Fred Sersen Going My Way Leo McCarey A Guy Named Joe David Boehm Chandler Sprague Lifeboat John Steinbeck None Shall Escape Alfred Neumann Joseph Than The Sullivans Edward Doherty Jules Schermer Going My Way Frank Butler Frank Cavett Double Indemnity Raymond Chandler Billy Wilder Gaslight John L. Balderston Walter Reisch John Van Druten Laura Jay Dratler Samuel Hoffenstein Betty Reinhardt Meet Me in St. Louis Irving Brecher Fred F. Finkelhoffe The Lost Weekend Ray Milland The Bells of St. Mary's Bing Crosby Anchors Aweigh Gene Kelly The Keys of the Kingdom Gregory Peck A Song To Remember Cornel Wilde A Tree Grows in Brooklyn James Dunn Spellbound Michael Chekhov The Corn Is Green John Dall G. I. Joe Robert Mitchum A Medal for Benny J. Carrol Naish Mildred Pierce Joan Crawford The Bells of St. Mary's Ingrid Bergman The Valley of Decision Greer Garson Love Letters Jennifer Jones Leave Her to Heaven Gene Tierney National Velvet Anne Revere Mildred Pierce Eve Arden Mildred Pierce Ann Blyth The Picture of Dorian Gray Angela Lansbury The Corn Is Green Joan Loring Blood on the Sun Wiard Ihnen A. Roland Fields Experiment Perilous Albert S. D'Agostino Jack Okey Claude Carpenter Darrell Silvera The Keys of the Kingdom James Basevi William Darling Frank E. Hughes Thomas Little Love Letters Roland Anderson Hans Dreier Sam Comer Ray Moyer The Picture of Dorian Gray Cedric Gibbons Hans Peters John Bonar Hugh Hunt Edwin B. Willis Frenchman's Creek Hans Dreier Ernst Fegte Sam Comer Leave Her to Heaven Maurice Ransford Lyle Wheeler Thomas Little National Velvet Cedric Gibbons Urie McCleary Mildred Griffiths Edwin B. Willis San Antonio Ted Smith Jack McConaghy A Thousand and One Nights Stephen Goosson Rudolph Sternad Frank Tuttle The Lost Weekend Paramount Anchors Aweigh Metro-Goldwyn-Mayer The Bells of St. Mary's Rainbow Productions Mildred Pierce Warner Bros. Spellbound Selznick International Pictures The Picture of Dorian Gray Harry Stradling The Keys of the Kingdom Arthur Miller The Lost Weekend John F. Seitz Mildred Pierce Ernest Haller Spellbound George Barnes Leave Her to Heaven Leon Shamroy Anchors Aweigh Charles Boyle Robert Planck National Velvet Leonard Smith A Song to Remember Allen M. Davey Tony Gaudio The Spanish Main George Barnes The Lost Weekend Billy Wilder The Bells of St. Mary's Leo McCarey National Velvet Clarence Brown The Southerner Jean Renoir Spellbound Alfred Hitchcock The True Glory The Governments of Great Britain and the United States of America The Last Bomb United States Army Air Force Hitler Lives? Gordon Hollingshead Library of Congress United States Office of War Information Overseas Motion Picture Bureau To the Shores of Iwo Jima United States Marine Corps National Velvet Robert J. Kern The Bells of St. Mary's Harry Marker The Lost Weekend Doane Harrison Objective, Burma! George Amy A Song to Remember Charles Nelson Spellbound Miklos Rozsa The Bells of St. Mary's Robert Emmett Dolan Brewster's Millions Lou Forbes Captain Kidd Werner Janssen The Enchanted Cottage Roy Webb Flame of Barbary Coast Dale Butts Morton Scott G. I. Honeymoon Edward J. Kay G. I. Joe Louis Applebaum Ann Ronell Guest Wife Daniele Amfitheatrof Guest in the House Werner Janssen The Keys of the Kingdom Alfred Newman The Lost Weekend Miklos Rozsa Love Letters Victor Young The Man Who Walked Alone Karl Hajos Objective, Burma! Franz Waxman Paris - Underground Alexander Tansman A Song to Remember Miklos Rozsa Morris Stoloff The Southerner Werner Janssen This Love of Ours H. J. Salter The Valley of Decision Herbert Stothart The Woman in the Window Hugo Friedhofer Arthur Lange Anchors Aweigh Georgie Stoll Belle of the Yukon Arthur Lange Can't Help Singing Jerome Kern H. J. Salter Hitchhike to Happiness Morton Scott Incendiary Blonde Robert Emmett Dolan Rhapsody in Blue Ray Heindorf Max Steiner State Fair Charles Henderson Alfred Newman Sunbonnet Sue Edward J. Kay The Three Caballeros Edward Plumb Paul J. Smith Charles Wolcott Tonight and Every Night Marlin Skiles Morris Stoloff Why Girls Leave Home Walter Greene Wonder Man Lou Forbes Ray Heindorf It Might As Well Be Spring State Fair Oscar Hammerstein II Richard Rodgers Accentuate the Positive Here Come the Waves Harold Arlen Johnny Mercer Anywhere Tonight and Every Night Sammy Cahn Jule Styne Aren't You Glad You're You? The Bells of St. Mary's Johnny Burke James Van Heusen Endlessly Earl Carroll Vanities Kim Gannon Walter Kent I Fall in Love Too Easily Anchors Aweigh Sammy Cahn Jule Styne I'll Buy That Dream Sing Your Way Home Herb Magidson Allie Wrubel Linda G. I. Joe Ann Ronell Love Letters Love Letters Eddie Heyman Victor Young More and More Can't Help Singing E. Y. Harburg Jerome Kern Sleighride in July Belle of the Yukon Johnny Burke James Van Heusen So in Love Wonder Man Leo Robin David Rose Some Sunday Morning San Antonio Ray Heindorf M. K. Jerome Ted Koehler The Cat and the Canary Why Girls Leave Home Ray Evans Jay Livingston Marie-Louise Richard Schweizer Dillinger Philip Yordan Music for Millions Myles Connolly Salty O'Rourke Milton Holmes What Next, Corporal Hargrove? Harry Kurnitz Quiet Please! Frederick Quimby Donald's Crime Walt Disney Jasper and the Beanstalk George Pal Life with Feathers Eddie Selzer Mighty Mouse in Gypsy Life Paul Terry The Poet and Peasant Walter Lantz Rippling Romance Screen Gems Stairway to Light Jerry Bresler Herbert Moulton Along the Rainbow Trail Edmund Reek Screen Snapshots' 25th Anniversary Ralph Staub Story of a Dog Gordon Hollingshead White Rhapsody Grantland Rice Your National Gallery Thomas Mead Joseph O'Brien Star in the Night Gordon Hollingshead A Gun in His Hand Jerry Bresler Chester Franklin The Jury Goes Round 'N' Round Jules White The Little Witch George Templeton The Bells of St. Mary's RKO Radio Studio Sound Department Stephen Dunn Flame of Barbary Coast Republic Studio Sound Department Daniel J. Bloomberg Lady on a Train Universal Studio Sound Department Bernard B. Brown Leave Her to Heaven 20th Century-Fox Studio Sound Department Thomas T. Moulton Rhapsody in Blue Warner Bros. Studio Sound Department Nathan Levinson A Song to Remember Columbia Studio Sound Department John P. Livadary The Southerner General Service Jack Whitney They Were Expendable Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer The Three Caballeros Walt Disney Studio Sound Department C. O. Slyfield Three Is a Family RCA Sound W. V. Wolfe The Unseen Paramount Studio Sound Department Loren L. Ryder Wonder Man Samuel Goldwyn Studio Sound Department Gordon Sawyer Wonder Man John Fulton Arthur W. Johns Captain Eddie Sol Halprin Roger Heman Harry Leonard Fred Sersen Spellbound Jack Cosgrove They Were Expendable A. Arnold Gillespie Donald Jahraus Robert A. MacDonald Michael Steinore A Thousand and One Nights Ray Bomba Lawrence W. Butler The House on 92nd Street Charles G. Booth The Affairs of Susan Laszlo Gorog Thomas Monroe A Medal for Benny John Steinbeck Jack Wagner Objective, Burma! Alvah Bessie A Song to Remember Ernst Marischka The Lost Weekend Charles Brackett Billy Wilder G. I. Joe Leopold Atlas Guy Endore Philip Stevenson Mildred Pierce Ranald MacDougall Pride of the Marines Albert Maltz A Tree Grows in Brooklyn Frank Davis Tess Slesinger The Best Years of Our Lives Fredric March Henry V Laurence Olivier The Jolson Story Larry Parks The Yearling Gregory Peck It's a Wonderful Life James Stewart The Best Years of Our Lives Harold Russell The Green Years Charles Coburn The Jolson Story William Demarest Notorious Claude Rains The Razor's Edge Clifton Webb To Each His Own Olivia de Havilland Brief Encounter Celia Johnson Duel in the Sun Jennifer Jones Sister Kenny Rosalind Russell The Yearling Jane Wyman The Razor's Edge Anne Baxter The Spiral Staircase Ethel Barrymore Duel in the Sun Lillian Gish Saratoga Trunk Flora Robson Anna and the King of Siam Gale Sondergaard Anna and the King of Siam William Darling Lyle Wheeler Frank E. Hughes Thomas Little Kitty Hans Dreier Walter Tyler Sam Comer Ray Moyer The Razor's Edge Richard Day Nathan Juran Paul S. Fox Thomas Little The Yearling Cedric Gibbons Paul Groesse Edwin B. Willis Caesar and Cleopatra John Bryan Henry V Carmen Dillon Paul Sheriff The Best Years of Our Lives Samuel Goldwyn Henry V J. Arthur Rank-Two Cities Films It's a Wonderful Life Liberty Films The Razor's Edge 20th Century-Fox The Yearling Metro-Goldwyn-Mayer Anna and the King of Siam Arthur Miller The Green Years George Folsey The Yearling Arthur Arling Charles Rosher Leonard Smith The Jolson Story Joseph Walker The Best Years of Our Lives William Wyler Brief Encounter David Lean It's a Wonderful Life Frank Capra The Killers Robert Siodmak The Yearling Clarence Brown Seeds of Destiny United States Department of War Atomic Power The March of Time Life at the Zoo Artkino Paramount News Issue #37 (Twentieth Anniversary Issue! 1927.....1947) Paramount Traffic with the Devil Herbert Morgan The Best Years of Our Lives Daniel Mandell It's a Wonderful Life William Hornbeck The Jolson Story William Lyon The Killers Arthur Hilton The Yearling Harold Kress The Best Years of Our Lives Hugo Friedhofer Anna and the King of Siam Bernard Herrmann Henry V William Walton Humoresque Franz Waxman The Killers Miklos Rozsa The Jolson Story Morris Stoloff Blue Skies Robert Emmett Dolan Centennial Summer Alfred Newman The Harvey Girls Lennie Hayton Night and Day Ray Heindorf Max Steiner On the Atchison, Topeka and the Santa Fe The Harvey Girls Johnny Mercer Harry Warren All Through the Day Centennial Summer Oscar Hammerstein II Jerome Kern I Can't Begin to Tell You The Dolly Sisters Mack Gordon James Monaco Ole Buttermilk Sky Canyon Passage Jack Brooks Hoagy Carmichael You Keep Coming Back Like a Song Blue Skies Irving Berlin The Seventh Veil Muriel Box Sydney Box The Blue Dahlia Raymond Chandler Children of Paradise Jacques Prevert Notorious Ben Hecht Road to Utopia Melvin Frank Norman Panama The Cat Concerto Frederick Quimby Chopin's Musical Moments Walter Lantz John Henry and the Inky Poo George Pal Squatter's Rights Walt Disney Walky Talky Hawky Edward Selzer Facing Your Danger Gordon Hollingshead Dive-Hi Champs Jack Eaton Golden Horses Edmund Reek Smart As a Fox Gordon Hollingshead Sure Cures Pete Smith A Boy and His Dog Gordon Hollingshead College Queen George B. Templeton Hiss and Yell Jules White The Luckiest Guy in the World Jerry Bresler The Jolson Story Columbia Studio Sound Department John Livadary The Best Years of Our Lives Samuel Goldwyn Studio Sound Department Gordon Sawyer It's a Wonderful Life RKO Radio Studio Sound Department John Aalberg Blithe Spirit Thomas Howard A Stolen Life Nathan Levinson William McGann Vacation from Marriage Clemence Dane The Dark Mirror Vladimir Pozner The Strange Love of Martha Ivers Jack Patrick The Stranger Victor Trivas To Each His Own Charles Brackett The Best Years of Our Lives Robert E. Sherwood Anna and the King of Siam Sally Benson Talbot Jennings Brief Encounter Anthony Havelock-Allan David Lean Ronald Neame The Killers Anthony Veiller Open City Sergio Amidei F. Fellini A Double Life Ronald Colman Body and Soul John Garfield Gentleman's Agreement Gregory Peck Life with Father William Powell Mourning Becomes Electra Michael Redgrave Miracle on 34th Street Edmund Gwenn The Farmer's Daughter Charles Bickford Ride the Pink Horse Thomas Gomez Crossfire Robert Ryan Kiss of Death Richard Widmark The Farmer's Daughter Loretta Young Possessed Joan Crawford Smash-Up - the Story of a Woman Susan Hayward Gentleman's Agreement Dorothy McGuire Mourning Becomes Electra Rosalind Russell Gentleman's Agreement Celeste Holm The Paradine Case Ethel Barrymore Crossfire Gloria Grahame The Egg and I Marjorie Main Gentleman's Agreement Anne Revere Great Expectations John Bryan Wilfred Shingleton The Foxes of Harrow Maurice Ransford Lyle Wheeler Paul S. Fox Thomas Little Black Narcissus Alfred Junge Life with Father Robert M. Haas George James Hopkins Gentleman's Agreement 20th Century-Fox The Bishop's Wife Samuel Goldwyn Crossfire RKO Radio Great Expectations J. Arthur Rank-Cineguild Miracle on 34th Street 20th Century-Fox Great Expectations Guy Green The Ghost and Mrs. Muir Charles Lang Jr. Green Dolphin Street George Folsey Black Narcissus Jack Cardiff Life with Father Peverell Marley William V. Skall Mother Wore Tights Harry Jackson Gentleman's Agreement Elia Kazan The Bishop's Wife Henry Koster Crossfire Edward Dmytryk A Double Life George Cukor Great Expectations David Lean Design for Death Richard O. Fleischer Sid Rogell Theron Warth Journey Into Medicine United States Department of State Office of Information and Educational Exchange The World Is Rich Paul Rotha First Steps United Nations Division of Films and Visual Information Passport to Nowhere Frederic Ullman Jr. School in the Mailbox Australian News & Information Bureau Body and Soul Francis Lyon Robert Parrish The Bishop's Wife Monica Collingwood Gentleman's Agreement Harmon Jones Green Dolphin Street George White Odd Man Out Fergus McDonnell A Double Life Dr. Miklos Rozsa The Bishop's Wife Hugo Friedhofer Captain from Castile Alfred Newman Forever Amber David Raksin Life with Father Max Steiner Mother Wore Tights Alfred Newman Fiesta Johnny Green My Wild Irish Rose Ray Heindorf Max Steiner Road to Rio Robert Emmett Dolan Song of the South Daniele Amfitheatrof Paul J. Smith Charles Wolcott Zip-a-Dee-Doo-Dah Song of the South Ray Gilbert Allie Wrubel A Gal in Calico The Time, the Place and the Girl Leo Robin Arthur Schwartz I Wish I Didn't Love You So The Perils of Pauline Frank Loesser Pass That Peace Pipe Good News Ralph Blane Roger Edens Hugh Martin You Do Mother Wore Tights Mack Gordon Josef Myrow The Bachelor and the Bobby-Soxer Sidney Sheldon Body and Soul Abraham Polonsky A Double Life Ruth Gordon Garson Kanin Monsieur Verdoux Charles Chaplin Shoe-Shine Sergio Amidei Adolfo Franci C. G. Viola Cesare Zavattini Tweetie Pie Edward Selzer Chip An' Dale Walt Disney Dr. Jekyll and Mr. Mouse Frederick Quimby Pluto's Blue Note Walt Disney Tubby the Tuba George Pal Good-Bye Miss Turlock Herbert Moulton Brooklyn, U.S.a. Thomas Mead Moon Rockets Jerry Fairbanks Now You See It Pete Smith So You Want to Be in Pictures Gordon Hollingshead Climbing the Matterhorn Irving Allen Champagne for Two Harry Grey Fight of the Wild Stallions Thomas Mead Give Us the Earth Herbert Morgan A Voice Is Born: The Story of Niklos Gafni Ben Blake The Bishop's Wife Samuel Goldwyn Studio Sound Department Gordon Sawyer Green Dolphin Street Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer T-Men Sound Service, Inc. Jack R. Whitney Green Dolphin Street A. Arnold Gillespie Warren Newcombe Douglas Shearer Michael Steinore Unconquered George Dutton Farciot Edouart Devereux Jennings Gordon Jennings Wallace Kelley Paul Lerpae Miracle on 34th Street Valentine Davies A Cage of Nightingales Georges Chaperot Rene Wheeler It Happened on Fifth Avenue Herbert Clyde Lewis Frederick Stephani Kiss of Death Eleazar Lipsky Smash-Up - the Story of a Woman Frank Cavett Dorothy Parker Miracle on 34th Street George Seaton Boomerang! Richard Murphy Crossfire John Paxton Gentleman's Agreement Moss Hart Great Expectations Anthony Havelock-Allan David Lean Ronald Neame Hamlet Laurence Olivier Johnny Belinda Lew Ayres The Search Montgomery Clift When My Baby Smiles at Me Dan Dailey Sitting Pretty Clifton Webb The Treasure of the Sierra Madre Walter Huston Johnny Belinda Charles Bickford Joan of Arc José Ferrer I Remember Mama Oscar Homolka The Luck of the Irish Cecil Kellaway Johnny Belinda Jane Wyman Joan of Arc Ingrid Bergman The Snake Pit Olivia de Havilland I Remember Mama Irene Dunne Sorry, Wrong Number Barbara Stanwyck Key Largo Claire Trevor I Remember Mama Barbara Bel Geddes I Remember Mama Ellen Corby Johnny Belinda Agnes Moorehead Hamlet Jean Simmons Hamlet Roger K. Furse Carmen Dillon Johnny Belinda Robert Haas William Wallace The Red Shoes Hein Heckroth Arthur Lawson Joan of Arc Richard Day Joseph Kish Edwin Casey Roberts Hamlet J. Arthur Rank-Two Cities Films Johnny Belinda Warner Bros. The Red Shoes J. Arthur Rank-Archers The Snake Pit 20th Century-Fox The Treasure of the Sierra Madre Warner Bros. The Naked City William Daniels A Foreign Affair Charles B. Lang Jr. I Remember Mama Nicholas Musuraca Johnny Belinda Ted McCord Portrait of Jennie Joseph August Joan of Arc Winton Hoch William V. Skall Joseph Valentine Green Grass of Wyoming Charles G. Clarke The Loves of Carmen William Snyder The Three Musketeers Robert Planck Hamlet Roger K. Furse B. F.'S Daughter Irene Joan of Arc Dorothy Jeakins Karinska The Emperor Waltz Edith Head Gile Steele The Treasure of the Sierra Madre John Huston Hamlet Laurence Olivier Johnny Belinda Jean Negulesco The Search Fred Zinnemann The Snake Pit Anatole Litvak The Secret Land Orville O. Dull The Quiet One Janice Loeb Toward Independence United States Army Heart to Heart Herbert Morgan Operation Vittles United States Army Air Force The Naked City Paul Weatherwax Joan of Arc Frank Sullivan Johnny Belinda David Weisbart Red River Christian Nyby The Red Shoes Reginald Mills The Red Shoes Brian Easdale Hamlet William Walton Joan of Arc Hugo Friedhofer Johnny Belinda Max Steiner The Snake Pit Alfred Newman Easter Parade Roger Edens Johnny Green The Emperor Waltz Victor Young The Pirate Lennie Hayton Romance on the High Seas Ray Heindorf When My Baby Smiles at Me Alfred Newman Buttons and Bows The Paleface Ray Evans Jay Livingston For Every Man There's a Woman Casbah Harold Arlen Leo Robin It's Magic Romance on the High Seas Sammy Cahn Jule Styne The Woody Woodpecker Song Wet Blanket Policy Ramey Idriss George Tibbles This Is the Moment That Lady in Ermine Frederick Hollander Leo Robin The Little Orphan Fred Quimby Mickey and the Seal Walt Disney Mouse Wreckers Edward Selzer Robin Hoodlum United Productions of America Tea for Two Hundred Walt Disney Symphony of a City Edmund H. Reek Annie Was a Wonder Herbert Moulton Cinderella Horse Gordon Hollingshead So You Want to Be on the Radio Gordon Hollingshead You Can't Win Pete Smith Seal Island Walt Disney Calgary Stampede Gordon Hollingshead Going to Blazes Herbert Morgan Samba-Mania Harry Grey Snow Capers Thomas Mead The Snake Pit 20th Century-Fox Studio Sound Department Thomas T. Moulton Johnny Belinda Warner Bros. Studio Sound Department Col. Nathan O. Levinson Moonrise Republic Studio Sound Department Daniel J. Bloomberg Portrait of Jennie Paul Eagler Charles Freeman J. McMillan Johnson Russell Shearman Clarence Slifer James G. Stewart Deep Waters Ralph Hammeras Roger Heman Fred Sersen Edward Snyder The Search Richard Schweizer David Wechsler Louisiana Story Frances Flaherty Robert Flaherty The Naked City Malvin Wald Red River Borden Chase The Red Shoes Emeric Pressburger The Treasure of the Sierra Madre John Huston A Foreign Affair Charles Brackett Richard L. Breen Billy Wilder Johnny Belinda Allen Vincent Irmgard Von Cube The Search Richard Schweizer David Wechsler The Snake Pit Millen Brand Frank Partos All the King's Men Broderick Crawford Champion Kirk Douglas Twelve O'Clock High Gregory Peck The Hasty Heart Richard Todd Sands of Iwo Jima John Wayne Twelve O'Clock High Dean Jagger All the King's Men John Ireland Champion Arthur Kennedy The Heiress Ralph Richardson Battleground James Whitmore The Heiress Olivia de Havilland Pinky Jeanne Crain My Foolish Heart Susan Hayward Edward, My Son Deborah Kerr Come to the Stable Loretta Young All the King's Men Mercedes McCambridge Pinky Ethel Barrymore Come to the Stable Celeste Holm Come to the Stable Elsa Lanchester Pinky Ethel Waters The Heiress Harry Horner John Meehan Emile Kuri Come to the Stable Lyle Wheeler Joseph C. Wright Paul S. Fox Thomas Little Madame Bovary Cedric Gibbons Jack Martin Smith Richard A. Pefferle Edwin B. Willis Little Women Cedric Gibbons Paul Groesse Jack D. Moore Edwin B. Willis The Adventures of Don Juan Edward Carrere Lyle Reifsnider Saraband William Kellner Jim Morahan Michael Relph All the King's Men Robert Rossen Productions Battleground Metro-Goldwyn-Mayer The Heiress Paramount A Letter to Three Wives 20th Century-Fox Twelve O'Clock High 20th Century-Fox Battleground Paul C. Vogel Champion Frank Planer Come to the Stable Joseph LaShelle The Heiress Leo Tover Prince of Foxes Leon Shamroy She Wore a Yellow Ribbon Winton Hoch The Barkleys of Broadway Harry Stradling Jolson Sings Again William Snyder Little Women Robert Planck Charles Schoenbaum Sand Charles G. Clarke The Heiress Edith Head Gile Steele Prince of Foxes Vittorio Nino Novarese The Adventures of Don Juan Marjorie Best Leah Rhodes Travilla Mother Is a Freshman Kay Nelson A Letter to Three Wives Joseph L. Mankiewicz All the King's Men Robert Rossen Battleground William A. Wellman The Fallen Idol Carol Reed The Heiress William Wyler Daybreak in Udi Crown Film Unit Kenji Comes Home Paul F. Heard A Chance To Live Richard de Rochemont So Much for So Little Edward Selzer 1848 French Cinema General Cooperative The Rising Tide St. Francis-Xavier University, Antigonish, Nova Scotia Champion Harry Gerstad All the King's Men Al Clark Robert Parrish Battleground John Dunning Sands of Iwo Jima Richard L. Van Enger The Window Frederic Knudtson The Heiress Aaron Copland Beyond the Forest Max Steiner Champion Dimitri Tiomkin On the Town Roger Edens Lennie Hayton Jolson Sings Again George Duning Morris Stoloff Look for the Silver Lining Ray Heindorf Baby, It's Cold Outside Neptune's Daughter Frank Loesser It's a Great Feeling It's a Great Feeling Sammy Cahn Jule Styne Lavender Blue So Dear to My Heart Eliot Daniel Larry Morey My Foolish Heart My Foolish Heart Ned Washington Victor Young Through a Long and Sleepless Night Come to the Stable Mack Gordon Alfred Newman For Scent-Imental Reasons Edward Selzer Canary Row Edward Selzer Hatch Up Your Troubles Fred Quimby The Magic Fluke Stephen Bosustow Toy Tinkers Walt Disney Aquatic House-Party Jack Eaton Roller Derby Girl Justin Herman So You Think You're Not Guilty Gordon Hollingshead Spills and Chills Walton C. Ament Water Trix Pete Smith Van Gogh Gaston Diehl Robert Haessens The Boy and the Eagle William Lasky Chase of Death Irving Allen The Grass Is Always Greener Gordon Hollingshead Snow Carnival Gordon Hollingshead Twelve O'Clock High 20th Century-Fox Studio Sound Department Thomas T. Moulton Once More, My Darling Universal-International Studio Sound Department Leslie I. Carey Sands of Iwo Jima Republic Studio Sound Department Daniel J. Bloomberg Mighty Joe Young ARKO Productions Tulsa Walter Wanger Pictures The Stratton Story Douglas Morrow Come to the Stable Clare Boothe Luce It Happens Every Spring Valentine Davies Shirley W. Smith Sands of Iwo Jima Harry Brown White Heat Virginia Kellogg A Letter to Three Wives Joseph L. Mankiewicz All the King's Men Robert Rossen The Bicycle Thief Cesare Zavattini Champion Carl Foreman The Fallen Idol Graham Greene Battleground Robert Pirosh Jolson Sings Again Sidney Buchman Paisan Sergio Amidei Federico Fellini Alfred Hayes Marcello Pagliero Roberto Rossellini Passport to Pimlico T. E. B. Clarke The Quiet One Helen Levitt Janice Loeb Sidney Meyers Cyrano De Bergerac José Ferrer The Magnificent Yankee Louis Calhern Sunset Blvd. William Holden Harvey James Stewart Father of the Bride Spencer Tracy All about Eve George Sanders Broken Arrow Jeff Chandler Mister 880 Edmund Gwenn The Asphalt Jungle Sam Jaffe Sunset Blvd. Erich von Stroheim Born Yesterday Judy Holliday All about Eve Anne Baxter All about Eve Bette Davis Caged Eleanor Parker Sunset Blvd. Gloria Swanson Harvey Josephine Hull Caged Hope Emerson All about Eve Celeste Holm Sunset Blvd. Nancy Olson All about Eve Thelma Ritter Sunset Blvd. Hans Dreier John Meehan Sam Comer Ray Moyer All about Eve George W. Davis Lyle Wheeler Thomas Little Walter M. Scott The Red Danube Cedric Gibbons Hans Peters Hugh Hunt Edwin B. Willis Samson and Delilah Hans Dreier Walter Tyler Sam Comer Ray Moyer Annie Get Your Gun Cedric Gibbons Paul Groesse Richard A. Pefferle Edwin B. Willis Destination Moon Ernst Fegte George Sawley All about Eve 20th Century-Fox Born Yesterday Columbia Father of the Bride Metro-Goldwyn-Mayer King Solomon's Mines Metro-Goldwyn-Mayer Sunset Blvd. Paramount The Third Man Robert Krasker All about Eve Milton Krasner The Asphalt Jungle Harold Rosson The Furies Victor Milner Sunset Blvd. John F. Seitz King Solomon's Mines Robert Surtees Annie Get Your Gun Charles Rosher Broken Arrow Ernest Palmer The Flame and the Arrow Ernest Haller Samson and Delilah George Barnes All about Eve Edith Head Charles LeMaire Born Yesterday Jean Louis The Magnificent Yankee Walter Plunkett Samson and Delilah Edith Head Dorothy Jeakins Elois Jenssen Gile Steele Gwen Wakeling The Black Rose Michael Whittaker That Forsyte Woman Walter Plunkett Valles All about Eve Joseph L. Mankiewicz The Asphalt Jungle John Huston Born Yesterday George Cukor Sunset Blvd. Billy Wilder The Third Man Carol Reed The Titan: Story of Michelangelo Robert Snyder With These Hands Jack Arnold Lee Goodman Why Korea? Edmund Reek The Fight: Science Against Cancer Guy Glover The Stairs Film Documents, Inc. King Solomon's Mines Conrad A. Nervig Ralph E. Winters All about Eve Barbara McLean Annie Get Your Gun James E. Newcom Sunset Blvd. Doane Harrison Arthur Schmidt The Third Man Oswald Hafenrichter Sunset Blvd. Franz Waxman All about Eve Alfred Newman The Flame and the Arrow Max Steiner No Sad Songs for Me George Duning Samson and Delilah Victor Young Annie Get Your Gun Adolph Deutsch Roger Edens Cinderella Paul J. Smith Oliver Wallace I'll Get By Lionel Newman Three Little Words Andre Previn The West Point Story Ray Heindorf Mona Lisa Captain Carey, U.S.a. Ray Evans Jay Livingston Be My Love The Toast of New Orleans Nicholas Brodszky Sammy Cahn Bibbidi-Bobbidi-Boo Cinderella Mack David Al Hoffman Jerry Livingston Mule Train Singing Guns Fred Glickman Hy Heath Johnny Lange Wilhelmina Wabash Avenue Mack Gordon Josef Myrow Gerald Mcboing-Boing Stephen Bosustow Jerry's Cousin Fred Quimby Trouble Indemnity Stephen Bosustow Grandad of Races Gordon Hollingshead Blaze Busters Robert Youngson Wrong Way Butch Pete Smith In Beaver Valley Walt Disney Grandma Moses Falcon Films, Inc. My Country 'Tis of Thee Gordon Hollingshead All about Eve 20th Century-Fox Studio Sound Department Thomas T. Moulton Cinderella Walt Disney Studio Sound Department C. O. Slyfield Louisa Universal-International Studio Sound Department Leslie I. Carey Our Very Own Samuel Goldwyn Studio Sound Department Gordon Sawyer Trio Pinewood Studio Sound Department Cyril Crowhurst Destination Moon George Pal Productions Samson and Delilah Cecil B. DeMille Productions Panic in the Streets Edna Anhalt Edward Anhalt Bitter Rice Giuseppe De Santis Carlo Lizzani The Gunfighter William Bowers Andre de Toth Mystery Street Leonard Spigelgass When Willie Comes Marching Home Sy Gomberg All about Eve Joseph L. Mankiewicz The Asphalt Jungle John Huston Ben Maddow Born Yesterday Albert Mannheimer Broken Arrow Albert Maltz Father of the Bride Frances Goodrich Albert Hackett Sunset Blvd. Charles Brackett D. M. Marshman Jr. Billy Wilder Adam's Rib Ruth Gordon Garson Kanin Caged Virginia Kellogg Bernard C. Schoenfeld The Men Carl Foreman No Way Out Joseph L. Mankiewicz Lesser Samuels The African Queen Humphrey Bogart A Streetcar Named Desire Marlon Brando A Place in the Sun Montgomery Clift Bright Victory Arthur Kennedy Death of a Salesman Fredric March A Streetcar Named Desire Karl Malden Quo Vadis Leo Genn Death of a Salesman Kevin McCarthy Quo Vadis Peter Ustinov Come Fill the Cup Gig Young A Streetcar Named Desire Vivien Leigh The African Queen Katharine Hepburn Detective Story Eleanor Parker A Place in the Sun Shelley Winters The Blue Veil Jane Wyman A Streetcar Named Desire Kim Hunter The Blue Veil Joan Blondell Death of a Salesman Mildred Dunnock Detective Story Lee Grant The Mating Season Thelma Ritter A Streetcar Named Desire Richard Day George James Hopkins Fourteen Hours Leland Fuller Lyle Wheeler Thomas Little Fred J. Rode House on Telegraph Hill John DeCuir Lyle Wheeler Paul S. Fox Thomas Little La Ronde D'Eaubonne Too Young to Kiss Cedric Gibbons Paul Groesse Jack D. Moore Edwin B. Willis An American in Paris Preston Ames Cedric Gibbons Keogh Gleason Edwin B. Willis David and Bathsheba George Davis Lyle Wheeler Paul S. Fox Thomas Little On the Riviera Leland Fuller Lyle Wheeler Joseph C. Wright Thomas Little Walter M. Scott Quo Vadis Edward Carfagno Cedric Gibbons William A. Horning Tales of Hoffmann Hein Heckroth Hugh Hunt An American in Paris Arthur Freed Decision before Dawn Anatole Litvak Frank McCarthy A Place in the Sun George Stevens Quo Vadis Sam Zimbalist A Streetcar Named Desire Charles K. Feldman A Place in the Sun William C. Mellor Death of a Salesman Frank Planer The Frogmen Norbert Brodine Strangers on a Train Robert Burks A Streetcar Named Desire Harry Stradling An American in Paris John Alton Alfred Gilks David and Bathsheba Leon Shamroy Quo Vadis William V. Skall Robert Surtees Show Boat Charles Rosher When Worlds Collide W. Howard Greene John F. Seitz A Place in the Sun Edith Head Kind Lady Walter Plunkett Gile Steele The Model and the Marriage Broker Charles LeMaire Renie The Mudlark Margaret Furse Edward Stevenson A Streetcar Named Desire Lucinda Ballard An American in Paris Orry-Kelly Walter Plunkett Irene Sharaff David and Bathsheba Charles LeMaire Edward Stevenson The Great Caruso Helen Rose Gile Steele Quo Vadis Herschel McCoy Tales of Hoffmann Hein Heckroth A Place in the Sun George Stevens The African Queen John Huston An American in Paris Vincente Minnelli Detective Story William Wyler A Streetcar Named Desire Elia Kazan Kon-Tiki Olle Nordemar I Was a Communist for the F.B.I. Bryan Foy Benjy Los Angeles Orthopaedic Hospital Paramount Pictures Corporation Fred Zinnemann One Who Came Back Owen Crump Disabled American Veterans The Seeing Eye Gordon Hollingshead A Place in the Sun William Hornbeck An American in Paris Adrienne Fazan Decision before Dawn Dorothy Spencer Quo Vadis Ralph E. Winters The Well Chester Schaeffer A Place in the Sun Franz Waxman David and Bathsheba Alfred Newman Death of a Salesman Alex North Quo Vadis Miklos Rozsa A Streetcar Named Desire Alex North An American in Paris Saul Chaplin Johnny Green Alice in Wonderland Oliver Wallace The Great Caruso Peter Herman Adler Johnny Green On the Riviera Alfred Newman Show Boat Adolph Deutsch Conrad Salinger In the Cool, Cool, Cool of the Evening Here Comes the Groom Hoagy Carmichael Johnny Mercer A Kiss to Build a Dream on The Strip Oscar Hammerstein II Bert Kalmar Harry Ruby Never Golden Girl Eliot Daniel Lionel Newman Too Late Now Royal Wedding Burton Lane Alan Jay Lerner Wonder Why Rich, Young and Pretty Nicholas Brodszky Sammy Cahn Two Mouseketeers Fred Quimby Lambert, the Sheepish Lion Walt Disney Rooty Toot Toot Stephen Bosustow World of Kids Robert Youngson Ridin' the Rails Jack Eaton The Story of Time Robert G. Leffingwell Nature's Half Acre Walt Disney Balzac Les Films du Compass Danger Under the Sea Tom Mead The Great Caruso Metro-Goldwyn-Mayer Studio Sound Department Douglas Shearer Bright Victory Universal-International Studio Sound Department Leslie I. Carey I Want You Samuel Goldwyn Studio Sound Department Gordon Sawyer A Streetcar Named Desire Warner Bros. Studio Sound Department Col. Nathan Levinson Two Tickets to Broadway RKO Radio Studio Sound Department John O. Aalberg When Worlds Collide Paramount Seven Days to Noon James Bernard Paul Dehn Bullfighter and the Lady Budd Boetticher Ray Nazarro The Frogmen Oscar Millard Here Comes the Groom Liam O'Brien Robert Riskin Teresa Alfred Hayes Stewart Stern A Place in the Sun Harry Brown Michael Wilson The African Queen James Agee John Huston Detective Story Robert Wyler Philip Yordan La Ronde Jacques Natanson Max Ophuls A Streetcar Named Desire Tennessee Williams An American in Paris Alan Jay Lerner The Big Carnival Walter Newman Lesser Samuels Billy Wilder David and Bathsheba Philip Dunne Go for Broke! Robert Pirosh The Well Clarence Greene Russell Rouse High Noon Gary Cooper Viva Zapata! Marlon Brando The Bad and the Beautiful Kirk Douglas Moulin Rouge José Ferrer The Lavender Hill Mob Alec Guinness Viva Zapata! Anthony Quinn My Cousin Rachel Richard Burton The Big Sky Arthur Hunnicutt The Quiet Man Victor McLaglen Sudden Fear Jack Palance Come Back, Little Sheba Shirley Booth Sudden Fear Joan Crawford The Star Bette Davis The Member of the Wedding Julie Harris With a Song in My Heart Susan Hayward The Bad and the Beautiful Gloria Grahame Singin' in the Rain Jean Hagen Moulin Rouge Colette Marchand Come Back, Little Sheba Terry Moore With a Song in My Heart Thelma Ritter The Bad and the Beautiful Edward Carfagno Cedric Gibbons Keogh Gleason Edwin B. Willis Carrie Roland Anderson Hal Pereira Emile Kuri My Cousin Rachel John DeCuir Lyle Wheeler Walter M. Scott Rashomon Matsuyama H. Motsumoto Viva Zapata! Leland Fuller Lyle Wheeler Claude Carpenter Thomas Little Moulin Rouge Paul Sheriff Marcel Vertes Hans Christian Andersen Clave Richard Day Howard Bristol The Merry Widow Cedric Gibbons Paul Groesse Arthur Krams Edwin B. Willis The Quiet Man Frank Hotaling John McCarthy Jr. Charles Thompson The Snows of Kilimanjaro John DeCuir Lyle Wheeler Paul S. Fox Thomas Little The Greatest Show on Earth Cecil B. DeMille High Noon Stanley Kramer Ivanhoe Pandro S. Berman Moulin Rouge Romulus Films The Quiet Man Merian C. Cooper John Ford The Bad and the Beautiful Robert Surtees The Big Sky Russell Harlan My Cousin Rachel Joseph LaShelle Navajo Virgil E. Miller Sudden Fear Charles B. Lang Jr. The Quiet Man Winton C. Hoch Archie Stout Hans Christian Andersen Harry Stradling Ivanhoe F. A. Young Million Dollar Mermaid George J. Folsey The Snows of Kilimanjaro Leon Shamroy The Bad and the Beautiful Helen Rose Affair in Trinidad Jean Louis Carrie Edith Head My Cousin Rachel Dorothy Jeakins Charles LeMaire Sudden Fear Sheila O'Brien Moulin Rouge Marcel Vertes The Greatest Show on Earth Edith Head Dorothy Jeakins Miles White Hans Christian Andersen Clave Madame Karinska Mary Wills The Merry Widow Helen Rose Gile Steele With a Song in My Heart Charles LeMaire The Quiet Man John Ford Five Fingers Joseph L. Mankiewicz The Greatest Show on Earth Cecil B. DeMille High Noon Fred Zinnemann Moulin Rouge John Huston The Sea Around Us Irwin Allen The Hoaxters Dore Schary Navajo Hall Bartlett Neighbours Norman McLaren Devil Take Us Herbert Morgan The Garden Spider (Epeira Diadema) Alberto Ancilotto Man Alive! Stephen Bosustow High Noon Harry Gerstad Elmo Williams Come Back, Little Sheba Warren Low Flat Top William Austin The Greatest Show on Earth Anne Bauchens Moulin Rouge Ralph Kemplen High Noon Dimitri Tiomkin Ivanhoe Miklos Rozsa Miracle of Fatima Max Steiner The Thief Herschel Burke Gilbert Viva Zapata! Alex North With a Song in My Heart Alfred Newman Hans Christian Andersen Walter Scharf The Jazz Singer Ray Heindorf Max Steiner The Medium Gian-Carlo Menotti Singin' in the Rain Lennie Hayton High Noon (Do Not Forsake Me, Oh My Darlin') High Noon Dimitri Tiomkin Ned Washington Am I in Love Son of Paleface Jack Brooks Because You're Mine Because You're Mine Nicholas Brodszky Sammy Cahn Thumbelina Hans Christian Andersen Frank Loesser Zing a Little Zong Just for You Leo Robin Harry Warren Johann Mouse Fred Quimby Little Johnny Jet Fred Quimby Madeline Stephen Bosustow Pink and Blue Blues Stephen Bosustow Romance of Transportation Tom Daly Light in the Window: The Art of Vermeer Boris Vermont Athletes of the Saddle Jack Eaton Desert Killer Gordon Hollingshead Neighbours Norman McLaren Royal Scotland Crown Film Unit Water Birds Walt Disney Bridge of Time London Film Production Devil Take Us Herbert Morgan Thar She Blows! Gordon Hollingshead Breaking the Sound Barrier London Film Sound Department Hans Christian Andersen Samuel Goldwyn Studio Sound Department Gordon Sawyer The Promoter Pinewood Studios Sound Department The Quiet Man Republic Studio Sound Department Daniel J. Bloomberg With a Song in My Heart 20th Century-Fox Studio Sound Department Thomas T. Moulton Plymouth Adventure Metro-Goldwyn-Mayer The Greatest Show on Earth Frank Cavett Frederic M. Frank Theodore St. John My Son John Leo McCarey The Narrow Margin Martin Goldsmith Jack Leonard The Pride of St. Louis Guy Trosper The Sniper Edna Anhalt Edward Anhalt The Bad and the Beautiful Charles Schnee Five Fingers Michael Wilson High Noon Carl Foreman The Man in the White Suit John Dighton Roger MacDougall Alexander Mackendrick The Quiet Man Frank S. Nugent The Lavender Hill Mob T. E. B. Clarke The Atomic City Sydney Boehm Breaking the Sound Barrier Terence Rattigan Pat and Mike Ruth Gordon Garson Kanin Viva Zapata! John Steinbeck Stalag 17 William Holden Julius Caesar Marlon Brando The Robe Richard Burton From Here to Eternity Montgomery Clift From Here to Eternity Burt Lancaster From Here to Eternity Frank Sinatra Roman Holiday Eddie Albert Shane Brandon De Wilde Shane Jack Palance Stalag 17 Robert Strauss Roman Holiday Audrey Hepburn Lili Leslie Caron Mogambo Ava Gardner From Here to Eternity Deborah Kerr The Moon Is Blue Maggie McNamara From Here to Eternity Donna Reed Mogambo Grace Kelly Hondo Geraldine Page Torch Song Marjorie Rambeau Pickup on South Street Thelma Ritter Julius Caesar Edward Carfagno Cedric Gibbons Hugh Hunt Edwin B. Willis Martin Luther Paul Markwitz Fritz Maurischat The President's Lady Leland Fuller Lyle Wheeler Paul S. Fox Roman Holiday Hal Pereira Walter Tyler Titanic Maurice Ransford Lyle Wheeler Stuart Reiss The Robe George W. Davis Lyle Wheeler Paul S. Fox Walter M. Scott Knights of the Round Table Alfred Junge Hans Peters John Jarvis Lili Cedric Gibbons Paul Groesse Arthur Krams Edwin B. Willis The Story of Three Loves Preston Ames Edward Carfagno Cedric Gibbons Gabriel Scognamillo Keogh Gleason Arthur Krams Jack D. Moore Edwin B. Willis Young Bess Cedric Gibbons Urie McCleary Jack D. Moore Edwin B. Willis From Here to Eternity Buddy Adler Julius Caesar John Houseman The Robe Frank Ross Roman Holiday William Wyler Shane George Stevens From Here to Eternity Burnett Guffey The Four Poster Hal Mohr Julius Caesar Joseph Ruttenberg Martin Luther Joseph C. Brun Roman Holiday Henri Alekan Frank Planer Shane Loyal Griggs All the Brothers Were Valiant George Folsey Beneath the 12-Mile Reef Edward Cronjager Lili Robert Planck The Robe Leon Shamroy Roman Holiday Edith Head The Actress Walter Plunkett Dream Wife Herschel McCoy Helen Rose From Here to Eternity Jean Louis The President's Lady Charles LeMaire Renie The Robe Charles LeMaire Emile Santiago The Band Wagon Mary Ann Nyberg Call Me Madam Irene Sharaff How To Marry a Millionaire Charles LeMaire Travilla Young Bess Walter Plunkett From Here to Eternity Fred Zinnemann Lili Charles Walters Roman Holiday William Wyler Shane George Stevens Stalag 17 Billy Wilder The Living Desert Walt Disney The Conquest of Everest Leon Clore John Taylor Grahame Tharp A Queen Is Crowned Castleton Knight The Alaskan Eskimo Walt Disney The Living City John Barnes Operation Blue Jay United States Army Signal Corps They Planted a Stone James Carr The Word John Adams John Healy From Here to Eternity William Lyon Crazylegs Irvine (Cotton) Warburton The Moon Is Blue Otto Ludwig Roman Holiday Robert Swink The War of the Worlds Everett Douglas Lili Bronislau Kaper Above and Beyond Hugo Friedhofer From Here to Eternity George Duning Morris Stoloff Julius Caesar Miklos Rozsa This Is Cinerama Louis Forbes Call Me Madam Alfred Newman The 5,000 Fingers of Dr. T Frederick Hollander Morris Stoloff The Band Wagon Adolph Deutsch Calamity Jane Ray Heindorf Kiss Me Kate Saul Chaplin Andre Previn Secret Love Calamity Jane Sammy Fain Paul Francis Webster My Flaming Heart Small Town Girl Nicholas Brodszky Leo Robin Sadie Thompson's Song (Blue Pacific Blues) Miss Sadie Thompson Lester Lee Ned Washington That's Amore The Caddy Jack Brooks Harry Warren The Moon Is Blue The Moon Is Blue Sylvia Fine Herschel Burke Gilbert Toot, Whistle, Plunk and Boom Walt Disney Christopher Crumpet Stephen Bosustow From a to Z-Z-Z-Z Edward Selzer Rugged Bear Walt Disney The Tell Tale Heart Stephen Bosustow The Merry Wives of Windsor Overture Johnny Green Christ Among the Primitives Vincenzo Lucci-Chiarissi Herring Hunt National Film Board of Canada Joy of Living Boris Vermont Wee Water Wonders Jack Eaton Bear Country Walt Disney Ben and Me Walt Disney Return to Glennascaul Dublin Gate Theatre Productions Vesuvius Express Otto Lang Winter Paradise Cedric Francis From Here to Eternity Columbia Studio Sound Department John P. Livadary Calamity Jane Warner Bros. Studio Sound Department William A. Mueller Knights of the Round Table Metro-Goldwyn-Mayer Studio Sound Department A. W. Watkins The Mississippi Gambler Universal-International Studio Sound Department Leslie I. Carey The War of the Worlds Paramount Studio Sound Department Loren L. Ryder The War of the Worlds Paramount Studio Roman Holiday Ian McLellan Hunter Dalton Trumbo Above and Beyond Beirne Lay Jr. The Captain's Paradise Alec Coppel Hondo Louis L'Amour Little Fugitive Ray Ashley Morris Engel Ruth Orkin From Here to Eternity Daniel Taradash The Cruel Sea Eric Ambler Lili Helen Deutsch Roman Holiday John Dighton Ian McLellan Hunter Shane A. B. Guthrie Jr. Titanic Charles Brackett Richard Breen Walter Reisch The Band Wagon Betty Comden Adolph Green The Desert Rats Richard Murphy The Naked Spur Harold Jack Bloom Sam Rolfe Take the High Ground Millard Kaufman On the Waterfront Marlon Brando The Caine Mutiny Humphrey Bogart The Country Girl Bing Crosby A Star Is Born James Mason Adventures of Robinson Crusoe Dan O'Herlihy The Barefoot Contessa Edmond O'Brien On the Waterfront Lee J. Cobb On the Waterfront Karl Malden On the Waterfront Rod Steiger The Caine Mutiny Tom Tully The Country Girl Grace Kelly Carmen Jones Dorothy Dandridge A Star Is Born Judy Garland Sabrina Audrey Hepburn Magnificent Obsession Jane Wyman On the Waterfront Eva Marie Saint Executive Suite Nina Foch Broken Lance Katy Jurado The High and the Mighty Jan Sterling The High and the Mighty Claire Trevor On the Waterfront Richard Day The Country Girl Roland Anderson Hal Pereira Sam Comer Grace Gregory Executive Suite Edward Carfagno Cedric Gibbons Emile Kuri Edwin B. Willis Le Plaisir Max Ophuls Sabrina Hal Pereira Walter Tyler Sam Comer Ray Moyer 20,000 Leagues Under the Sea John Meehan Emile Kuri Brigadoon Preston Ames Cedric Gibbons Keogh Gleason Edwin B. Willis Desiree Leland Fuller Lyle Wheeler Paul S. Fox Walter M. Scott Red Garters Roland Anderson Hal Pereira Sam Comer Ray Moyer A Star Is Born Gene Allen Malcolm Bert Irene Sharaff George James Hopkins On the Waterfront Sam Spiegel The Caine Mutiny Stanley Kramer The Country Girl William Perlberg Seven Brides for Seven Brothers Jack Cummings Three Coins in the Fountain Sol C. Siegel On the Waterfront Boris Kaufman The Country Girl John F. Warren Executive Suite George Folsey Rogue Cop John Seitz Sabrina Charles Lang Jr. Three Coins in the Fountain Milton Krasner The Egyptian Leon Shamroy Rear Window Robert Burks Seven Brides for Seven Brothers George Folsey The Silver Chalice William V. Skall Sabrina Edith Head The Earrings of Madame De... Georges Annenkov Rosine Delamare Executive Suite Helen Rose Indiscretion of an American Wife Christian Dior It Should Happen to You Jean Louis Gate of Hell Sanzo Wada Brigadoon Irene Sharaff Desiree René Hubert Charles LeMaire A Star Is Born Jean Louis Mary Ann Nyberg Irene Sharaff There's No Business Like Show Business Charles LeMaire Travilla Miles White On the Waterfront Elia Kazan The Country Girl George Seaton The High and the Mighty William Wellman Rear Window Alfred Hitchcock Sabrina Billy Wilder The Vanishing Prairie Walt Disney The Stratford Adventure Guy Glover Thursday's Children Morse Films World Wide Pictures Jet Carrier Otto Lang Rembrandt: A Self-Portrait Morrie Roizman On the Waterfront Gene Milford 20,000 Leagues Under the Sea Elmo Williams The Caine Mutiny Henry Batista William A. Lyon The High and the Mighty Ralph Dawson Seven Brides for Seven Brothers Ralph E. Winters The High and the Mighty Dimitri Tiomkin The Caine Mutiny Max Steiner Genevieve Larry Adler Muir Mathieson On the Waterfront Leonard Bernstein The Silver Chalice Franz Waxman Seven Brides for Seven Brothers Saul Chaplin Adolph Deutsch Carmen Jones Herschel Burke Gilbert The Glenn Miller Story Joseph Gershenson Henry Mancini A Star Is Born Ray Heindorf There's No Business Like Show Business Alfred Newman Lionel Newman Three Coins in the Fountain Three Coins in the Fountain Sammy Cahn Jule Styne Count Your Blessings Instead of Sheep White Christmas Irving Berlin Hold My Hand Susan Slept Here Jack Lawrence Richard Myers The High and the Mighty The High and the Mighty Dimitri Tiomkin Ned Washington The Man That Got Away A Star Is Born Harold Arlen Ira Gershwin When Magoo Flew Stephen Bosustow Crazy Mixed Up Pup Walter Lantz Pigs Is Pigs Walt Disney Sandy Claws Edward Selzer Touché Pussy Cat Fred Quimby This Mechanical Age Robert Youngson The First Piano Quartette Otto Lang The Strauss Fantasy Johnny Green A Time Out of War Denis Sanders Terry Sanders Beauty and the Bull Cedric Francis Jet Carrier Otto Lang Siam Walt Disney The Glenn Miller Story Universal-International Studio Sound Department Leslie I. Carey Brigadoon Metro-Goldwyn-Mayer Studio Sound Department Wesley C. Miller The Caine Mutiny Columbia Studio Sound Department John P. Livadary Rear Window Paramount Studio Sound Department Loren L. Ryder Susan Slept Here RKO Radio Studio Sound Department John O. Aalberg 20,000 Leagues Under the Sea Walt Disney Studios Hell and High Water 20th Century-Fox Studio Them! Warner Bros. Studio Broken Lance Philip Yordan Bread, Love and Dreams Ettore Margadonna Forbidden Games François Boyer Night People Jed Harris Tom Reed There's No Business Like Show Business Lamar Trotti The Country Girl George Seaton The Caine Mutiny Stanley Roberts Rear Window John Michael Hayes Sabrina Ernest Lehman Samuel Taylor Billy Wilder Seven Brides for Seven Brothers Frances Goodrich Albert Hackett Dorothy Kingsley On the Waterfront Budd Schulberg The Barefoot Contessa Joseph L. Mankiewicz Genevieve William Rose The Glenn Miller Story Oscar Brodney Valentine Davies Knock on Wood Melvin Frank Norman Panama Marty Ernest Borgnine Love Me Or Leave Me James Cagney East of Eden James Dean The Man with the Golden Arm Frank Sinatra Bad Day at Black Rock Spencer Tracy Mister Roberts Jack Lemmon Trial Arthur Kennedy Marty Joe Mantell Rebel Without a Cause Sal Mineo Picnic Arthur O'Connell The Rose Tattoo Anna Magnani I'll Cry Tomorrow Susan Hayward Summertime Katharine Hepburn Love Is a Many-Splendored Thing Jennifer Jones Interrupted Melody Eleanor Parker East of Eden Jo Van Fleet Marty Betsy Blair Pete Kelly's Blues Peggy Lee The Rose Tattoo Marisa Pavan Rebel Without a Cause Natalie Wood The Rose Tattoo Tambi Larsen Hal Pereira Sam Comer Arthur Krams Blackboard Jungle Randall Duell Cedric Gibbons Henry Grace Edwin B. Willis I'll Cry Tomorrow Malcolm Brown Cedric Gibbons Hugh B. Hunt Edwin B. Willis The Man with the Golden Arm Joseph C. Wright Darrell Silvera Marty Edward S. Haworth Walter Simonds Robert Priestley Picnic William Flannery Jo Mielziner Robert Priestley Daddy Long Legs John DeCuir Lyle Wheeler Paul S. Fox Walter M. Scott Guys and Dolls Oliver Smith Joseph C. Wright Howard Bristol Love Is a Many-Splendored Thing George W. Davis Lyle Wheeler Walter M. Scott Jack Stubbs To Catch a Thief Joseph McMillan Johnson Hal Pereira Sam Comer Arthur Krams Marty Harold Hecht Love Is a Many-Splendored Thing Buddy Adler Mister Roberts Leland Hayward Picnic Fred Kohlmar The Rose Tattoo Hal B. Wallis The Rose Tattoo James Wong Howe Blackboard Jungle Russell Harlan I'll Cry Tomorrow Arthur E. Arling Marty Joseph LaShelle Queen Bee Charles Lang To Catch a Thief Robert Burks Guys and Dolls Harry Stradling Love Is a Many-Splendored Thing Leon Shamroy A Man Called Peter Harold Lipstein Oklahoma! Robert Surtees I'll Cry Tomorrow Helen Rose The Pickwick Papers Beatrice Dawson Queen Bee Jean Louis The Rose Tattoo Edith Head Ugetsu Tadaoto Kainoscho Love Is a Many-Splendored Thing Charles LeMaire Guys and Dolls Irene Sharaff Interrupted Melody Helen Rose To Catch a Thief Edith Head The Virgin Queen Charles LeMaire Mary Wills Marty Delbert Mann Bad Day at Black Rock John Sturges East of Eden Elia Kazan Picnic Joshua Logan Summertime David Lean Helen Keller in Her Story Nancy Hamilton Heartbreak Ridge Rene Risacher Men Against the Arctic Walt Disney The Battle of Gettysburg Dore Schary The Face of Lincoln Wilbur T. Blume Picnic William A. Lyon Charles Nelson Blackboard Jungle Ferris Webster The Bridges at Toko-Ri Alma Macrorie Oklahoma! George Boemler Gene Ruggiero The Rose Tattoo Warren Low Love Is a Many-Splendored Thing Alfred Newman Battle Cry Max Steiner The Man with the Golden Arm Elmer Bernstein Picnic George Duning The Rose Tattoo Alex North Oklahoma! Robert Russell Bennett Jay Blackton Adolph Deutsch Daddy Long Legs Alfred Newman Guys and Dolls Jay Blackton Cyril J. Mockridge It's Always Fair Weather Andre Previn Love Me Or Leave Me Percy Faith George Stoll Love Is a Many-Spendored Thing Love Is a Many-splendored Thing Sammy Fain Paul Francis Webster Love(Is the) Tender Trap The Tender Trap Sammy Cahn James Van Heusen I'll Never Stop Loving You Love Me Or Leave Me Nicholas Brodszky Sammy Cahn Something's Gotta Give Daddy Long Legs Johnny Mercer Unchained Melody Unchained Alex North Hy Zaret Speedy Gonzales Edward Selzer Good Will to Men Joseph Barbera William Hanna Fred Quimby The Legend of Rock-a-Bye Point Walter Lantz No Hunting Walt Disney Survival City Edmund Reek 3rd Ave. El Carson Davidson Gadgets Galore Robert Youngson Three Kisses Justin Herman The Face of Lincoln Wilbur T. Blume 24-Hour Alert Cedric Francis The Battle of Gettysburg Dore Schary On the Twelfth Day... George K. Arthur Switzerland Walt Disney Oklahoma! Todd-AO Sound Department Fred Hynes Love Is a Many-Splendored Thing 20th Century-Fox Studio Sound Department Carl W. Faulkner Love Me Or Leave Me Metro-Goldwyn-Mayer Studio Sound Department Wesley C. Miller Mister Roberts Warner Bros. Studio Sound Department William A. Mueller Not As a Stranger Radio Corporation of America Sound Department Watson Jones The Bridges at Toko-Ri Paramount Studio The Dam Busters Associated British Picture Corporation, Ltd. The Rains of Ranchipur 20th Century-Fox Studio Love Me Or Leave Me Daniel Fuchs The Private War of Major Benson Joe Connelly Bob Mosher Rebel Without a Cause Nicholas Ray The Sheep Has Five Legs Jean Marsan Jacques Perret Raoul Ploquin Henry Troyat Henri Verneuil Strategic Air Command Beirne Lay Jr. Marty Paddy Chayefsky Bad Day at Black Rock Millard Kaufman Blackboard Jungle Richard Brooks East of Eden Paul Osborn Love Me Or Leave Me Daniel Fuchs Isobel Lennart Interrupted Melody Sonya Levien William Ludwig The Court-Martial of Billy Mitchell Emmet Lavery Milton Sperling It's Always Fair Weather Betty Comden Adolph Green Mr. Hulot's Holiday Henri Marquet Jacques Tati The Seven Little Foys Jack Rose Melville Shavelson The King and I Yul Brynner Giant James Dean Lust for Life Kirk Douglas Giant Rock Hudson Richard III Sir Laurence Olivier Lust for Life Anthony Quinn Bus Stop Don Murray Friendly Persuasion Anthony Perkins The Bold and the Brave Mickey Rooney Written on the Wind Robert Stack Anastasia Ingrid Bergman Baby Doll Carroll Baker The Rainmaker Katharine Hepburn The Bad Seed Nancy Kelly The King and I Deborah Kerr Written on the Wind Dorothy Malone Baby Doll Mildred Dunnock The Bad Seed Eileen Heckart Giant Mercedes McCambridge The Bad Seed Patty McCormack Somebody Up There Likes Me Malcolm F. Brown Cedric Gibbons F. Keogh Gleason Edwin B. Willis The Magnificent Seven Takashi Matsuyama The Proud and the Profane A. Earl Hedrick Hal Pereira Samuel M. Comer Frank R. McKelvy The Solid Gold Cadillac Ross Bellah Louis Diage William R. Kiernan Teenage Rebel Jack Martin Smith Lyle R. Wheeler Stuart A. Reiss Walter M. Scott The King and I John DeCuir Lyle R. Wheeler Paul S. Fox Walter M. Scott Around the World in 80 Days Ken Adam James W. Sullivan Ross J. Dowd Giant Boris Leven Ralph S. Hurst Lust for Life Preston Ames Cedric Gibbons Hans Peters F. Keogh Gleason Edwin B. Willis The Ten Commandments Albert Nozaki Hal Pereira Walter H. Tyler Samuel M. Comer Ray Moyer Around the World in 80 Days Michael Todd Friendly Persuasion William Wyler Giant Henry Ginsberg George Stevens The King and I Charles Brackett The Ten Commandments Cecil B. DeMille Somebody Up There Likes Me Joseph Ruttenberg Baby Doll Boris Kaufman The Bad Seed Hal Rosson The Harder They Fall Burnett Guffey Stagecoach to Fury Walter Strenge Around the World in 80 Days Lionel Lindon The Eddy Duchin Story Harry Stradling The King and I Leon Shamroy The Ten Commandments Loyal Griggs War and Peace Jack Cardiff The Solid Gold Cadillac Jean Louis The Magnificent Seven Kohei Ezaki The Power and the Prize Helen Rose The Proud and the Profane Edith Head Teenage Rebel Charles LeMaire Mary Wills The King and I Irene Sharaff Around the World in 80 Days Miles White Giant Marjorie Best Moss Mabry The Ten Commandments Arnold Friberg Edith Head Dorothy Jeakins John Jensen Ralph Jester War and Peace Marie De Matteis Giant George Stevens Around the World in 80 Days Michael Anderson Friendly Persuasion William Wyler The King and I Walter Lang War and Peace King Vidor The Silent World Jacques-Yves Cousteau The Naked Eye Louis Clyde Stoumen Where Mountains Float The Government Film Committee of Denmark The True Story of the Civil War Louis Clyde Stoumen A City Decides Charles Guggenheim & Associates, Inc. The Dark Wave John Healy The House Without a Name Valentine Davies Man in Space Ward Kimball Around the World in 80 Days Gene Ruggiero Paul Weatherwax The Brave One Merrill G. White Giant Philip W. Anderson Fred Bohanan William Hornbeck Somebody Up There Likes Me Albert Akst The Ten Commandments Anne Bauchens La Strada Italy Dino De Laurentiis Carlo Ponti The Captain of Kopenick West Germany Walter Koppel Gyula Trebitsch Gervaise France Annie Dorfmann Harp of Burma Japan Masayuki Takagi Qivitoq Denmark O. Dalsgaard-Olsen Around the World in 80 Days Victor Young Anastasia Alfred Newman Between Heaven and Hell Hugo Friedhofer Giant Dimitri Tiomkin The Rainmaker Alex North The King and I Ken Darby Alfred Newman The Best Things in Life are Free Lionel Newman The Eddy Duchin Story George Duning Morris Stoloff High Society (Mgm) Saul Chaplin Johnny Green Meet Me in Las Vegas Johnny Green George Stoll Whatever Will Be, Will Be (Que Sera, Sera) The Man Who Knew Too Much Ray Evans Jay Livingston Friendly Persuasion (Thee I Love) Friendly Persuasion Dimitri Tiomkin Paul Francis Webster Julie Julie Tom Adair Leith Stevens True Love High Society Cole Porter Written on the Wind Written on the Wind Sammy Cahn Victor Young Around the World in 80 Days John Farrow S.J. Perelman James Poe Baby Doll Tennessee Williams Friendly Persuasion Michael Wilson Giant Fred Guiol Ivan Moffat Lust for Life Norman Corwin The Red Balloon Albert Lamorisse The Bold and the Brave Robert Lewin Julie Andrew L. Stone La Strada Federico Fellini Tullio Pinelli The Ladykillers William Rose Mister Magoo's Puddle Jumper Stephen Bosustow Gerald Mcboing-Boing on Planet Moo Stephen Bosustow The Jay Walker Stephen Bosustow Crashing the Water Barrier Konstantin Kalser I Never Forget a Face Robert Youngson Time Stood Still Cedric Francis The Bespoke Overcoat Romulus Films Cow Dog Larry Lansburgh The Dark Wave John Healy Samoa Walt Disney The King and I 20th Century-Fox Studio Sound Department Carl Faulkner The Brave One King Bros. Productions, Inc., Sound Department John Myers The Eddy Duchin Story Columbia Studio Sound Department John Livadary Friendly Persuasion Samuel Goldwyn Studio Sound Department Gordon Sawyer Westrex Sound Services, Inc. Gordon R. Glennan The Ten Commandments Paramount Studio Sound Department Loren L. Ryder The Ten Commandments John Fulton Forbidden Planet A. Arnold Gillespie Wesley C. Miller Irving Ries The Brave One Dalton Trumbo The Eddy Duchin Story Leo Katcher High Society Edward Bernds Elwood Ullman The Proud and the Beautiful Jean Paul Sartre Umberto D. Cesare Zavattini The Bridge on the River Kwai Alec Guinness Sayonara Marlon Brando A Hatful of Rain Anthony Franciosa Witness for the Prosecution Charles Laughton Wild Is the Wind Anthony Quinn Sayonara Red Buttons A Farewell to Arms Vittorio De Sica The Bridge on the River Kwai Sessue Hayakawa Peyton Place Arthur Kennedy Peyton Place Russ Tamblyn The Three Faces of Eve Joanne Woodward Heaven Knows, Mr. Allison Deborah Kerr Wild Is the Wind Anna Magnani Raintree County Elizabeth Taylor Peyton Place Lana Turner Sayonara Miyoshi Umeki The Bachelor Party Carolyn Jones Witness for the Prosecution Elsa Lanchester Peyton Place Hope Lange Peyton Place Diane Varsi Sayonara Ted Haworth Robert Priestley Funny Face George W. Davis Hal Pereira Sam Comer Ray Moyer Les Girls Gene Allen William A. Horning Richard Pefferle Edwin B. Willis Pal Joey Walter Holscher Louis Diage William Kiernan Raintree County William A. Horning Urie McCleary Hugh Hunt Edwin B. Willis The Bridge on the River Kwai Sam Spiegel 12 Angry Men Henry Fonda Reginald Rose Peyton Place Jerry Wald Sayonara William Goetz Witness for the Prosecution Arthur Hornblow Jr. The Bridge on the River Kwai Jack Hildyard An Affair To Remember Milton Krasner Funny Face Ray June Peyton Place William Mellor Sayonara Ellsworth Fredericks Les Girls Orry-Kelly An Affair to Remember Charles LeMaire Funny Face Hubert de Givenchy Edith Head Pal Joey Jean Louis Raintree County Walter Plunkett The Bridge on the River Kwai David Lean 12 Angry Men Sidney Lumet Peyton Place Mark Robson Sayonara Joshua Logan Witness for the Prosecution Billy Wilder Albert Schweitzer Jerome Hill On the Bowery Lionel Rogosin Torero! Manuel Barbachano Ponce The Bridge on the River Kwai Peter Taylor Gunfight at the O.K. Corral Warren Low Pal Joey Viola Lawrence Jerome Thoms Sayonara Philip W. Anderson Arthur P. Schmidt Witness for the Prosecution Daniel Mandell The Nights of Cabiria Italy The Devil Came at Night West Germany Gates of Paris France Mother India India Nine Lives Norway The Bridge on the River Kwai Malcolm Arnold An Affair to Remember Hugo Friedhofer Boy on a Dolphin Hugo Friedhofer Perri Paul Smith Raintree County Johnny Green All the Way The Joker Is Wild Sammy Cahn James Van Heusen An Affair to Remember An Affair To Remember Harold Adamson Leo McCarey Harry Warren April Love April Love Sammy Fain Paul Francis Webster Tammy Tammy and the Bachelor Ray Evans Jay Livingston Wild Is the Wind Wild is the Wind Dimitri Tiomkin Ned Washington The Bridge on the River Kwai Pierre Boulle Carl Foreman Michael Wilson 12 Angry Men Reginald Rose Heaven Knows, Mr. Allison John Huston John Lee Mahin Peyton Place John Michael Hayes Sayonara Paul Osborn Birds Anonymous Edward Selzer One Droopy Knight Joseph Barbera William Hanna Tabasco Road Edward Selzer Trees and Jamaica Daddy Stephen Bosustow The Truth about Mother Goose Walt Disney The Wetback Hound Larry Lansburgh A Chairy Tale Norman McLaren City of Gold Tom Daly Foothold on Antarctica James Carr Portugal Ben Sharpsteen Sayonara Warner Bros. Studio Sound Department George Groves Gunfight at the O.K. Corral Paramount Studio Sound Department George Dutton Les Girls Metro-Goldwyn-Mayer Studio Sound Department Dr. Wesley C. Miller Pal Joey Columbia Studio Sound Department John P. Livadary Witness for the Prosecution Samuel Goldwyn Studio Sound Department Gordon E. Sawyer The Enemy Below Walter Rossi The Spirit of St. Louis Louis Lichtenfield Designing Woman George Wells Funny Face Leonard Gershe Man of a Thousand Faces R. Wright Campbell Ivan Goff Ben Roberts Ralph Wheelwright The Tin Star Joel Kane Dudley Nichols Barney Slater Vitelloni Federico Fellini Ennio Flaiano Tullio Pinelli Separate Tables David Niven The Defiant Ones Tony Curtis Cat on a Hot Tin Roof Paul Newman The Defiant Ones Sidney Poitier The Old Man and the Sea Spencer Tracy The Big Country Burl Ives The Defiant Ones Theodore Bikel The Brothers Karamazov Lee J. Cobb Some Came Running Arthur Kennedy Teacher's Pet Gig Young I Want To Live! Susan Hayward Separate Tables Deborah Kerr Some Came Running Shirley MacLaine Auntie Mame Rosalind Russell Cat on a Hot Tin Roof Elizabeth Taylor Separate Tables Wendy Hiller Auntie Mame Peggy Cass Some Came Running Martha Hyer Lonelyhearts Maureen Stapleton The Defiant Ones Cara Williams Gigi Preston Ames William A. Horning Keogh Gleason Henry Grace Auntie Mame Malcolm Bert George James Hopkins Bell, Book and Candle Cary Odell Louis Diage A Certain Smile John DeCuir Lyle R. Wheeler Paul S. Fox Walter M. Scott Vertigo Henry Bumstead Hal Pereira Sam Comer Frank McKelvy Gigi Arthur Freed Auntie Mame Warner Bros. Cat on a Hot Tin Roof Lawrence Weingarten The Defiant Ones Stanley Kramer Separate Tables Harold Hecht The Defiant Ones Sam Leavitt Desire Under the Elms Daniel L. Fapp I Want to Live! Lionel Lindon Separate Tables Charles Lang Jr. The Young Lions Joe MacDonald Gigi Joseph Ruttenberg Auntie Mame Harry Stradling Sr. Cat on a Hot Tin Roof William Daniels The Old Man and the Sea James Wong Howe South Pacific Leon Shamroy Gigi Cecil Beaton Bell, Book and Candle Jean Louis The Buccaneer Edith Head John Jensen Ralph Jester A Certain Smile Charles LeMaire Mary Wills Some Came Running Walter Plunkett Gigi Vincente Minnelli Cat on a Hot Tin Roof Richard Brooks The Defiant Ones Stanley Kramer I Want to Live! Robert Wise The Inn of the Sixth Happiness Mark Robson White Wilderness Ben Sharpsteen Antarctic Crossing James Carr The Hidden World Robert Snyder Psychiatric Nursing Nathan Zucker Ama Girls Ben Sharpsteen Employees Only Kenneth G. Brown Journey Into Spring Ian Ferguson The Living Stone Tom Daly Overture Thorold Dickinson Gigi Adrienne Fazan Auntie Mame William Ziegler Cowboy Al Clark William A. Lyon The Defiant Ones Frederic Knudtson I Want to Live! William Hornbeck My Uncle France Arms and the Man West Germany La Venganza Spain The Road a Year Long Yugoslavia The Usual Unidentified Thieves Italy The Old Man and the Sea Dimitri Tiomkin The Big Country Jerome Moross Separate Tables David Raksin White Wilderness Oliver Wallace The Young Lions Hugo Friedhofer Gigi Andre Previn The Bolshoi Ballet Yuri Faier G. Rozhdestvensky Damn Yankees Ray Heindorf Mardi Gras Lionel Newman South Pacific Ken Darby Alfred Newman Gigi Gigi Alan Jay Lerner Frederick Loewe A Certain Smile A Certain Smile Sammy Fain Paul Francis Webster A Very Precious Love Marjorie Morningstar Sammy Fain Paul Francis Webster Almost in Your Arms (Love Song from 'Houseboat') Houseboat Ray Evans Jay Livingston To Love and Be Loved Some Came Running Sammy Cahn James Van Heusen Gigi Alan Jay Lerner Cat on a Hot Tin Roof Richard Brooks James Poe The Horse's Mouth Alec Guinness I Want to Live! Nelson Gidding Don Mankiewicz Separate Tables John Gay Terence Rattigan Knighty Knight Bugs John W. Burton Paul Bunyan Walt Disney Sidney's Family Tree William M. Weiss Grand Canyon Walt Disney Journey Into Spring Ian Ferguson The Kiss John Patrick Hayes Snows of Aorangi New Zealand Screen Board T Is for Tumbleweed James A. Lebenthal South Pacific Todd-AO Sound Departmentr Fred Hynes I Want to Live! Samuel Goldwyn Studio Sound Department Gordon E. Sawyer A Time to Love and a Time to Die Universal-International Studio Sound Department Leslie I. Carey Vertigo Paramount Studio Sound Department George Dutton The Young Lions 20th Century-Fox Studio Sound Department Carl Faulkner Tom Thumb Tom Howard Torpedo Run A. Arnold Gillespie Harold Humbrock The Defiant Ones Harold Jacob Smith Nedrick Young The Goddess Paddy Chayefsky Houseboat Jack Rose Melville Shavelson The Sheepman William Bowers James Edward Grant Teacher's Pet Fay Kanin Michael Kanin Ben-Hur Charlton Heston Room at the Top Laurence Harvey Some Like It Hot Jack Lemmon The Last Angry Man Paul Muni Anatomy of a Murder James Stewart Ben-Hur Hugh Griffith Anatomy of a Murder Arthur O'Connell Anatomy of a Murder George C. Scott The Young Philadelphians Robert Vaughn The Diary of Anne Frank Ed Wynn Room at the Top Simone Signoret Pillow Talk Doris Day The Nun's Story Audrey Hepburn Suddenly, Last Summer Katharine Hepburn Suddenly, Last Summer Elizabeth Taylor The Diary of Anne Frank Shelley Winters Room at the Top Hermione Baddeley Imitation of Life Susan Kohner Imitation of Life Juanita Moore Pillow Talk Thelma Ritter The Diary of Anne Frank George W. Davis Lyle R. Wheeler Stuart A. Reiss Walter M. Scott Career Hal Pereira Walter Tyler Sam Comer Arthur Krams The Last Angry Man Carl Anderson William Kiernan Some Like It Hot Ted Haworth Edward G. Boyle Suddenly, Last Summer William Kellner Oliver Messel Scot Slimon Ben-Hur Edward Carfagno William A. Horning Hugh Hunt The Big Fisherman John DeCuir Julia Heron Journey to the Center of the Earth Franz Bachelin Herman A. Blumenthal Lyle R. Wheeler Joseph Kish Walter M. Scott North By Northwest Robert Boyle William A. Horning Merrill Pye Henry Grace Frank McKelvy Pillow Talk Richard H. Riedel Russell A. Gausman Ruby R. Levitt Ben-Hur Sam Zimbalist Anatomy of a Murder Otto Preminger The Diary of Anne Frank George Stevens The Nun's Story Henry Blanke Room at the Top James Woolf John Woolf The Diary of Anne Frank William C. Mellor Anatomy of a Murder Sam Leavitt Career Joseph LaShelle Some Like It Hot Charles Lang Jr. The Young Philadelphians Harry Stradling Sr. Ben-Hur Robert L. Surtees The Big Fisherman Lee Garmes The Five Pennies Daniel L. Fapp The Nun's Story Franz Planer Porgy and Bess Leon Shamroy Some Like It Hot Orry-Kelly Career Edith Head The Diary of Anne Frank Charles LeMaire Mary Wills The Gazebo Helen Rose The Young Philadelphians Howard Shoup Ben-Hur Elizabeth Haffenden The Best of Everything Adele Palmer The Big Fisherman Renie The Five Pennies Edith Head Porgy and Bess Irene Sharaff Ben-Hur William Wyler The Diary of Anne Frank George Stevens The Nun's Story Fred Zinnemann Room at the Top Jack Clayton Some Like It Hot Billy Wilder Serengeti Shall Not Die Bernhard Grzimek The Race for Space David L. Wolper Glass Bert Haanstra Donald in Mathmagic Land Walt Disney From Generation to Generation Edward F. Cullen Ben-Hur John D. Dunning Ralph E. Winters Anatomy of a Murder Louis R. Loeffler North By Northwest George Tomasini The Nun's Story Walter Thompson On the Beach Frederic Knudtson Black Orpheus France The Bridge West Germany The Great War Italy Paw Denmark The Village on the River The Netherlands Ben-Hur Miklos Rozsa The Diary of Anne Frank Alfred Newman The Nun's Story Franz Waxman On the Beach Ernest Gold Pillow Talk Frank DeVol Porgy and Bess Ken Darby Andre Previn The Five Pennies Leith Stevens Li'l Abner Joseph J. Lilley Nelson Riddle Say One for Me Lionel Newman Sleeping Beauty George Bruns High Hopes A Hole in the Head Sammy Cahn James Van Heusen Strange are the Ways of Love The Young Land Dimitri Tiomkin Ned Washington The Best of Everything The Best of Everything Sammy Cahn Alfred Newman The Five Pennies The Five Pennies Sylvia Fine The Hanging Tree The Hanging Tree Mack David Jerry Livingston Room at the Top Neil Paterson Anatomy of a Murder Wendell Mayes Ben-Hur Karl Tunberg The Nun's Story Robert Anderson Some Like It Hot I. A. L. Diamond Billy Wilder Moonbird John Hubley Mexicali Shmoes John W. Burton Noah's Ark Walt Disney The Violinist Ernest Pintoff The Golden Fish Jacques-Yves Cousteau Between the Tides Ian Ferguson Mysteries of the Deep Walt Disney The Running, Jumping and Standing-Still Film Peter Sellers Skyscraper Shirley Clarke Irving Jacoby Willard Van Dyke Ben-Hur Metro-Goldwyn-Mayer Studio Sound Department Franklin E. Milton Journey to the Center of the Earth 20th Century-Fox Studio Sound Department Carl Faulkner Libel! Metro-Goldwyn-Mayer London Studio Sound Department A. W. Watkins The Nun's Story Warner Bros. Studio Sound Department George R. Groves Porgy and Bess Samuel Goldwyn Studio Sound Department Gordon E. Sawyer Todd-AO Sound Department Fred Hynes Ben-Hur A. Arnold Gillespie Milo Lory Robert MacDonald Journey to the Center of the Earth L. B. Abbott Carl Faulkner James B. Gordon Pillow Talk Clarence Greene Maurice Richlin Russell Rouse Stanley Shapiro The 400 Blows Marcel Moussy Francois Truffaut North By Northwest Ernest Lehman Operation Petticoat Paul King Maurice Richlin Stanley Shapiro Joseph Stone Wild Strawberries Ingmar Bergman Elmer Gantry Burt Lancaster Sons and Lovers Trevor Howard The Apartment Jack Lemmon The Entertainer Laurence Olivier Inherit the Wind Spencer Tracy Spartacus Peter Ustinov Murder, Inc. Peter Falk The Apartment Jack Kruschen Exodus Sal Mineo The Alamo Chill Wills Butterfield 8 Elizabeth Taylor Sunrise at Campobello Greer Garson The Sundowners Deborah Kerr The Apartment Shirley MacLaine Never on Sunday Melina Mercouri Elmer Gantry Shirley Jones The Sundowners Glynis Johns The Dark at the Top of the Stairs Shirley Knight Psycho Janet Leigh Sons and Lovers Mary Ure The Apartment Alexander Trauner Edward G. Boyle The Facts of Life Joseph McMillan Johnson Kenneth A. Reid Ross Dowd Psycho Robert Clatworthy Joseph Hurley George Milo Sons and Lovers Tom Morahan Lionel Couch Visit to a Small Planet Hal Pereira Walter Tyler Sam Comer Arthur Krams Spartacus Alexander Golitzen Eric Orbom Russell A. Gausman Julia Heron Cimarron George W. Davis Addison Hehr Henry Grace Hugh Hunt Otto Siegel It Started in Naples Roland Anderson Hal Pereira Arrigo Breschi Sam Comer Pepe Ted Haworth William Kiernan Sunrise at Campobello Edward Carrere George James Hopkins The Apartment Billy Wilder The Alamo John Wayne Elmer Gantry Bernard Smith Sons and Lovers Jerry Wald The Sundowners Fred Zinnemann Sons and Lovers Freddie Francis The Apartment Joseph LaShelle The Facts of Life Charles B. Lang Jr. Inherit the Wind Ernest Laszlo Psycho John L. Russell Spartacus Russell Metty The Alamo William H. Clothier Butterfield 8 Charles Harten Joseph Ruttenberg Exodus Sam Leavitt Pepe Joe MacDonald The Facts of Life Edith Head Edward Stevenson Never on Sunday Deni Vachlioti The Rise and Fall of Legs Diamond Howard Shoup Seven Thieves Bill Thomas The Virgin Spring Marik Vos Spartacus Bill Thomas Valles Can-Can Irene Sharaff Midnight Lace Irene Pepe Edith Head Sunrise at Campobello Marjorie Best The Apartment Billy Wilder Never on Sunday Jules Dassin Psycho Alfred Hitchcock Sons and Lovers Jack Cardiff The Sundowners Fred Zinnemann The Horse with the Flying Tail Larry Lansburgh Rebel in Paradise Robert D. Fraser Giuseppina James Hill Beyond Silence United States Information Agency A City Called Copenhagen Statens Filmcentral, The Danish Government Film Office George Grosz' Interregnum Altina Carey Charles Carey Universe Colin Low The Apartment Daniel Mandell The Alamo Stuart Gilmore Inherit the Wind Frederic Knudtson Pepe Al Clark Viola Lawrence Spartacus Robert Lawrence The Virgin Spring Sweden Kapo Italy La Verité France Macario Mexico The Ninth Circle Yugoslavia Exodus Ernest Gold The Alamo Dimitri Tiomkin Elmer Gantry Andre Previn The Magnificent Seven Elmer Bernstein Spartacus Alex North Song Without End (The Story of Franz Liszt) Morris Stoloff Harry Sukman Bells are Ringing Andre Previn Can-Can Nelson Riddle Let's Make Love Earle H. Hagen Lionel Newman Pepe Johnny Green Never on Sunday Never on Sunday Manos Hadjidakis Faraway Part of Town Pepe Andre Previn Dory Langdon The Facts of Life The Facts of Life Johnny Mercer The Green Leaves of Summer The Alamo Dimitri Tiomkin Paul Francis Webster The Second Time Around High Time Sammy Cahn James Van Heusen Elmer Gantry Richard Brooks Inherit the Wind Harold Jacob Smith Nedrick Young Sons and Lovers T. E. B. Clarke Gavin Lambert The Sundowners Isobel Lennart Tunes of Glory James Kennaway Munro William L. Snyder Goliath II Walt Disney High Note Warner Bros. Mouse and Garden Warner Bros. A Place in the Sun Frantisek Vystrecil Day of the Painter Ezra R. Baker The Creation of Woman Ismail Merchant Charles F. Schwep Islands of the Sea Walt Disney A Sport Is Born Leslie Winik The Alamo Samuel Goldwyn Studio Sound Departmentnes Gordon E. Sawyer Todd-AO Sound Department Fred Hynes Sound Director The Apartment Samuel Goldwyn Studio Sound Department Gordon E. Sawyer Cimarron Metro-Goldwyn-Mayer Studio Sound Department Franklin E. Milton Pepe Columbia Studio Sound Department Charles Rice Sunrise at Campobello Warner Bros. Studio Sound Department George R. Groves The Time Machine Tim Baar Gene Warren The Last Voyage A.J. Lohman The Apartment I. A. L. Diamond Billy Wilder The Angry Silence Michael Craig Bryan Forbes Richard Gregson The Facts of Life Melvin Frank Norman Panama Hiroshima, Mon Amour Marguerite Duras Never on Sunday Jules Dassin Judgment at Nuremberg Maximilian Schell Fanny Charles Boyer The Hustler Paul Newman Judgment at Nuremberg Spencer Tracy The Mark Stuart Whitman West Side Story George Chakiris Judgment at Nuremberg Montgomery Clift Pocketful of Miracles Peter Falk The Hustler Jackie Gleason The Hustler George C. Scott Two Women Sophia Loren Breakfast at Tiffany's Audrey Hepburn The Hustler Piper Laurie Summer and Smoke Geraldine Page Splendor in the Grass Natalie Wood West Side Story Rita Moreno The Children's Hour Fay Bainter Judgment at Nuremberg Judy Garland The Roman Spring of Mrs. Stone Lotte Lenya Summer and Smoke Una Merkel The Hustler Harry Horner Gene Callahan The Absent-Minded Professor Carroll Clark Hal Gausman Emile Kuri The Children's Hour Fernando Carrere Edward G. Boyle Judgment at Nuremberg Rudolph Sternad George Milo La Dolce Vita Piero Gherardi West Side Story Boris Leven Victor A. Gangelin Breakfast at Tiffany's Roland Anderson Hal Pereira Sam Comer Ray Moyer El Cid Veniero Colasanti John Moore Flower Drum Song Alexander Golitzen Joseph Wright Howard Bristol Summer and Smoke Hal Pereira Walter Tyler Sam Comer Arthur Krams West Side Story Robert Wise Fanny Joshua Logan The Guns of Navarone Carl Foreman The Hustler Robert Rossen Judgment at Nuremberg Stanley Kramer The Hustler Eugen Shuftan The Absent-Minded Professor Edward Colman The Children's Hour Franz F. Planer Judgment at Nuremberg Ernest Laszlo One, Two, Three Daniel L. Fapp West Side Story Daniel L. Fapp Fanny Jack Cardiff Flower Drum Song Russell Metty A Majority of One Harry Stradling Sr. One-Eyed Jacks Charles Lang Jr. La Dolce Vita Piero Gherardi The Children's Hour Dorothy Jeakins Claudelle Inglish Howard Shoup Judgment at Nuremberg Jean Louis Yojimbo Yoshiro Muraki West Side Story Irene Sharaff Babes in Toyland Bill Thomas Back Street Jean Louis Flower Drum Song Irene Sharaff Pocketful of Miracles Edith Head Walter Plunkett West Side Story Jerome Robbins Robert Wise The Guns of Navarone J. Lee Thompson The Hustler Robert Rossen Judgment at Nuremberg Stanley Kramer La Dolce Vita Federico Fellini Le Ciel Et La Boue (Sky Above and Mud Beneath) Arthur Cohn Rene Lafuite La Grande Olimpiade (Olympic Games 1960) dell Istituto Nazionale Luce, Comitato Organizzatore Del Giochi Della XVII Olimpiade Project Hope Frank P. Bibas Breaking the Language Barrier United States Air Force Cradle of Genius Tom Hayes Jim O'Connor Kahl Dido-Film-GmbH L'Uomo in Grigio (The Man in Gray) Benedetto Benedetti West Side Story Thomas Stanford Fanny William H. Reynolds The Guns of Navarone Alan Osbiston Judgment at Nuremberg Frederic Knudtson The Parent Trap Philip W. Anderson Through a Glass Darkly Sweden Harry and the Butler Denmark Immortal Love Japan The Important Man Mexico Placido Spain Breakfast at Tiffany's Henry Mancini El Cid Miklos Rozsa Fanny Morris Stoloff Harry Sukman The Guns of Navarone Dimitri Tiomkin Summer and Smoke Elmer Bernstein West Side Story Saul Chaplin Johnny Green Irwin Kostal Sid Ramin Babes in Toyland George Bruns Flower Drum Song Ken Darby Alfred Newman Khovanshchina Dimitri Shostakovich Paris Blues Duke Ellington Moon River Breakfast at Tiffany's Henry Mancini Johnny Mercer Bachelor in Paradise Bachelor in Paradise Mack David Henry Mancini Love Theme from El Cid (The Falcon and the Dove) El Cid Miklos Rozsa Paul Francis Webster Pocketful of Miracles Pocketful of Miracles Sammy Cahn James Van Heusen Town Without Pity Town Without Pity Dimitri Tiomkin Ned Washington Judgment at Nuremberg Abby Mann Breakfast at Tiffany's George Axelrod The Guns of Navarone Carl Foreman The Hustler Sidney Carroll Robert Rossen West Side Story Ernest Lehman Ersatz (The Substitute) Zagreb Film Aquamania Walt Disney Beep Prepared Chuck Jones Nelly's Folly Chuck Jones The Pied Piper of Guadalupe Friz Freleng Seawards the Great Ships Lester A. Schoenfeld Films Ballon Vole (Play Ball!) Ciné-Documents The Face of Jesus Dr. John D. Jennings Rooftops of New York Robert Gaffney Very Nice, Very Nice National Film Board of Canada West Side Story Samuel Goldwyn Studio Sound Department Gordon E. Sawyer Todd-AO Sound Department Fred Hynes The Children's Hour Samuel Goldwyn Studio Sound Department Gordon E. Sawyer Flower Drum Song Revue Studio Sound Department Waldon O. Watson The Guns of Navarone Shepperton Studio Sound Department John Cox The Parent Trap Walt Disney Studio Sound Department Robert O. Cook The Guns of Navarone Vivian C. Greenham Bill Warrington The Absent-Minded Professor Eustace Lycett Robert A. Mattey Splendor in the Grass William Inge Ballad of a Soldier Grigori Chukhrai Valentin Yoshov General Della Rovere Sergio Amidei Diego Fabbri Indro Montanelli La Dolce Vita Federico Fellini Ennio Flaiano Tullio Pinelli Brunello Rondi Lover Come Back Paul Henning Stanley Shapiro To Kill a Mockingbird Gregory Peck Birdman of Alcatraz Burt Lancaster Days of Wine and Roses Jack Lemmon Divorce - Italian Style Marcello Mastroianni Lawrence of Arabia Peter O'Toole Sweet Bird of Youth Ed Begley What Ever Happened to Baby Jane? Victor Buono Birdman of Alcatraz Telly Savalas Lawrence of Arabia Omar Sharif Billy Budd Terence Stamp The Miracle Worker Anne Bancroft What Ever Happened to Baby Jane? Bette Davis Long Day's Journey Into Night Katharine Hepburn Sweet Bird of Youth Geraldine Page Days of Wine and Roses Lee Remick The Miracle Worker Patty Duke To Kill a Mockingbird Mary Badham Sweet Bird of Youth Shirley Knight The Manchurian Candidate Angela Lansbury Birdman of Alcatraz Thelma Ritter To Kill a Mockingbird Henry Bumstead Alexander Golitzen Oliver Emert Days of Wine and Roses Joseph Wright George James Hopkins The Longest Day Leon Barsacq Ted Haworth Vincent Korda Gabriel Bechir Period of Adjustment Edward Carfagno George W. Davis Henry Grace Dick Pefferle The Pigeon That Took Rome Roland Anderson Hal Pereira Sam Comer Frank R. McKelvy Lawrence of Arabia John Box John Stoll Dario Simoni Meredith Willson's The Music Man Paul Groesse George James Hopkins Mutiny on the Bounty George W. Davis J. McMillan Johnson Henry Grace Hugh Hunt That Touch of Mink Robert Clatworthy Alexander Golitzen George Milo The Wonderful World of the Brothers Grimm Edward Carfagno George W. Davis Henry Grace Dick Pefferle Lawrence of Arabia Sam Spiegel The Longest Day Darryl F. Zanuck Meredith Willson's The Music Man Morton Da Costa Mutiny on the Bounty Aaron Rosenberg To Kill a Mockingbird Alan J. Pakula The Longest Day Jean Bourgoin Henri Persin Walter Wottitz Birdman of Alcatraz Burnett Guffey To Kill a Mockingbird Russell Harlan Two for the Seesaw Ted McCord What Ever Happened to Baby Jane? Ernest Haller Lawrence of Arabia Fred A. Young Gypsy Harry Stradling Sr. Hatari! Russell Harlan Mutiny on the Bounty Robert L. Surtees The Wonderful World of the Brothers Grimm Paul C. Vogel What Ever Happened to Baby Jane? Norma Koch Days of Wine and Roses Don Feld The Man Who Shot Liberty Valance Edith Head The Miracle Worker Ruth Morley Phaedra Denny Vachlioti The Wonderful World of the Brothers Grimm Mary Wills Bon Voyage! Bill Thomas Gypsy Orry-Kelly Meredith Willson's The Music Man Dorothy Jeakins My Geisha Edith Head Lawrence of Arabia David Lean David and Lisa Frank Perry Divorce - Italian Style Pietro Germi The Miracle Worker Arthur Penn To Kill a Mockingbird Robert Mulligan Black Fox Louis Clyde Stoumen Alvorada (Brazil's Changing Face) Hugo Niebeling Dylan Thomas Jack Howells The John Glenn Story William L. Hendricks The Road to the Wall Robert Saudek Lawrence of Arabia Anne Coates The Longest Day Samuel E. Beetley The Manchurian Candidate Ferris Webster Meredith Willson's The Music Man William Ziegler Mutiny on the Bounty John McSweeney Jr. Sundays and Cybele France Electra Greece The Four Days of Naples Italy Keeper of Promises (The Given Word) Brazil Tlayucan Mexico Lawrence of Arabia Maurice Jarre Freud Jerry Goldsmith Mutiny on the Bounty Bronislau Kaper Taras Bulba Franz Waxman To Kill a Mockingbird Elmer Bernstein Meredith Willson's The Music Man Ray Heindorf Billy Rose's Jumbo George Stoll Gigot Michel Magne Gypsy Frank Perkins The Wonderful World of the Brothers Grimm Leigh Harline Days of Wine and Roses Days of Wine and Roses Henry Mancini Johnny Mercer Love Song from Mutiny on the Bounty (Follow Me) Mutiny on the Bounty Bronislau Kaper Paul Francis Webster Song from Two for the Seesaw (Second Chance) Two for the Seesaw Andre Previn Dory Langdon Tender Is the Night Tender Is the Night Sammy Fain Paul Francis Webster Walk on the Wild Side Walk on the Wild Side Elmer Bernstein Mack David To Kill a Mockingbird Horton Foote David and Lisa Eleanor Perry Lawrence of Arabia Robert Bolt Michael Wilson Lolita Vladimir Nabokov The Miracle Worker William Gibson The Hole Faith Hubley John Hubley Icarus Montgolfier Wright Jules Engel Now Hear This Warner Bros. Self Defense - for Cowards William L. Snyder Symposium on Popular Songs Walt Disney Heureux Anniversaire (Happy Anniversary) J.C. Carrière Pierre Etaix Big City Blues Charles Huguenot van der Linden Martina Huguenot van der Linden The Cadillac Robert Clouse The Cliff Dwellers (Formerly Titled "One Plus One") Hayward Anderson Pan Herman van der Horst Lawrence of Arabia Shepperton Studio Sound Department John Cox Bon Voyage! Walt Disney Studio Sound Department Robert O. Cook Meredith Willson's The Music Man Warner Bros. Studio Sound Department George R. Groves That Touch of Mink Universal City Studio Sound Department Waldon O. Watson What Ever Happened to Baby Jane? Glen Glenn Sound Department Joseph Kelly The Longest Day Robert MacDonald Jacques Maumont Mutiny on the Bounty A. Arnold Gillespie Milo Lory Divorce - Italian Style Ennio de Concini Pietro Germi Alfredo Giannetti Freud Charles Kaufman Wolfgang Reinhardt Last Year at Marienbad Alain Robbe-Grillet That Touch of Mink Nate Monaster Stanley Shapiro Through a Glass Darkly Ingmar Bergman Lilies of the Field Sidney Poitier Tom Jones Albert Finney This Sporting Life Richard Harris Cleopatra Rex Harrison Hud Paul Newman Hud Melvyn Douglas Twilight of Honor Nick Adams Captain Newman, M.D. Bobby Darin Tom Jones Hugh Griffith The Cardinal John Huston Hud Patricia Neal The L-Shaped Room Leslie Caron Irma La Douce Shirley MacLaine This Sporting Life Rachel Roberts Love with the Proper Stranger Natalie Wood The V.I.P.S Margaret Rutherford Tom Jones Diane Cilento Tom Jones Dame Edith Evans Tom Jones Joyce Redman Lilies of the Field Lilia Skala America America Gene Callahan Federico Fellini's 8-1/2 Piero Gherardi Hud Tambi Larsen Hal Pereira Robert Benton Sam Comer Love with the Proper Stranger Roland Anderson Hal Pereira Sam Comer Grace Gregory Twilight of Honor George W. Davis Paul Groesse Henry Grace Hugh Hunt Cleopatra Herman Blumenthal Hilyard Brown John DeCuir Boris Juraga Maurice Pelling Jack Martin Smith Elven Webb Paul S. Fox Ray Moyer Walter M. Scott The Cardinal Lyle Wheeler Gene Callahan Come Blow Your Horn Roland Anderson Hal Pereira Sam Comer James Payne How the West Was w George W. Davis William Ferrari Addison Hehr Henry Grace Don Greenwood Jr. Jack Mills Tom Jones Ralph Brinton Jocelyn Herbert Ted Marshall Josie MacAvin Tom Jones Tony Richardson America America Elia Kazan Cleopatra Walter Wanger How the West Was w Bernard Smith Lilies of the Field Ralph Nelson Hud James Wong Howe The Balcony George Folsey The Caretakers Lucien Ballard Lilies of the Field Ernest Haller Love with the Proper Stranger Milton Krasner Cleopatra Leon Shamroy The Cardinal Leon Shamroy How the West Was w William H. Daniels Milton Krasner Charles Lang Jr. Joseph LaShelle Irma La Douce Joseph LaShelle It's a Mad, Mad, Mad, Mad World Ernest Laszlo Federico Fellini's 8-1/2 Piero Gherardi Love with the Proper Stranger Edith Head The Stripper Travilla Toys in the Attic Bill Thomas Wives and Lovers Edith Head Cleopatra Vittorio Nino Novarese Renie Irene Sharaff The Cardinal Donald Brooks How the West Was w Walter Plunkett The Leopard Piero Tosi A New Kind of Love Edith Head Tom Jones Tony Richardson America America Elia Kazan The Cardinal Otto Preminger Federico Fellini's 8-1/2 Federico Fellini Hud Martin Ritt Robert Frost: A Lover's Quarrel with the World Robert Hughes Le Maillon Et La Chaine (The Link and the Chain) Paul de Roubaix Terminus Edgar Anstey The Yanks are Coming Marshall Flaum Chagall Simon Schiffrin The Five Cities of June George Stevens Jr. The Spirit of America Algernon G. Walker Thirty Million Letters Edgar Anstey To Live Again Mel London How the West Was w Harold F. Kress The Cardinal Louis R. Loeffler Cleopatra Dorothy Spencer The Great Escape Ferris Webster It's a Mad, Mad, Mad, Mad World Gene Fowler Jr. Robert C. Jones Frederic Knudtson Federico Fellini's 8-1/2 Italy Knife in the Water Poland Los Tarantos Spain The Red Lanterns Greece Twin Sisters of Kyoto Japan Tom Jones John Addison 55 Days at Peking Dimitri Tiomkin Cleopatra Alex North How the West Was w Ken Darby Alfred Newman It's a Mad, Mad, Mad, Mad World Ernest Gold Irma La Douce Andre Previn Bye Bye Birdie John Green A New Kind of Love Leith Stevens Sundays and Cybele Maurice Jarre The Sword in the Stone George Bruns Call Me Irresponsible Papa's Delicate Condition Sammy Cahn James Van Heusen Charade Charade Henry Mancini Johnny Mercer It's a Mad, Mad, Mad, Mad World It's a Mad, Mad, Mad, Mad World Mack David Ernest Gold More Mondo Cane Norman Newell Nino Oliviero Riz Ortolani So Little Time 55 Days at Peking Dimitri Tiomkin Paul Francis Webster Tom Jones John Osborne Captain Newman, M.D. Richard L. Breen Henry Ephron Phoebe Ephron Hud Harriet Frank Jr. Irving Ravetch Lilies of the Field James Poe Sundays and Cybele Serge Bourguignon Antoine Tudal The Critic Ernest Pintoff Automania 2000 John Halas The Game (Igra) Dusan Vukotic My Financial Career Tom Daly Colin Low Pianissimo Carmen D'Avino An Occurrence at Owl Creek Bridge Paul de Roubaix Marcel Ichac The Concert Ezra Baker Home-Made Car James Hill Six-Sided Triangle Christopher Miles That's Me Walker Stuart How the West Was w Metro-Goldwyn-Mayer Studio Sound Department Franklin E. Milton Bye Bye Birdie Columbia Studio Sound Department Charles Rice Captain Newman, M.D. Universal City Studio Sound Department Waldon O. Watson Cleopatra Todd-AO Sound Department Fred Hynes 20th Century-Fox Studio Sound Department James P. Corcoran It's a Mad, Mad, Mad, Mad World Samuel Goldwyn Studio Sound Department Gordon E. Sawyer It's a Mad, Mad, Mad, Mad World Walter G. Elliott A Gathering of Eagles Robert L. Bratton Cleopatra Emil Kosa Jr. The Birds Ub Iwerks How the West Was w James R. Webb America America Elia Kazan Federico Fellini's 8-1/2 Federico Fellini Ennio Flaiano Tullio Pinelli Brunello Rondi The Four Days of Naples Carlo Bernari Pasquale Festa Campanile Massimo Franciosa Nanni Loy Vasco Pratolini Love with the Proper Stranger Arnold Schulman My Fair Lady Rex Harrison Becket Richard Burton Becket Peter O'Toole Zorba the Greek Anthony Quinn Dr. Strangelove Or: How I Learned To Stop Worrying and Love the Bomb Peter Sellers Topkapi Peter Ustinov Becket John Gielgud My Fair Lady Stanley Holloway Seven Days in May Edmond O'Brien The Best Man Lee Tracy Mary Poppins Julie Andrews The Pumpkin Eater Anne Bancroft Marriage Italian Style Sophia Loren The Unsinkable Molly Brown Debbie Reynolds Seance on a Wet Afternoon Kim Stanley Zorba the Greek Lila Kedrova My Fair Lady Gladys Cooper The Chalk Garden Dame Edith Evans The Night of the Iguana Grayson Hall Hush...Hush, Sweet Charlotte Agnes Moorehead Zorba the Greek Vassilis Fotopoulos The Americanization of Emily George W. Davis Hans Peters Elliot Scott Robert R. Benton Henry Grace Hush...Hush, Sweet Charlotte William Glasgow Raphael Bretton The Night of the Iguana Stephen Grimes Seven Days in May Cary Odell Edward G. Boyle My Fair Lady Gene Allen Cecil Beaton George James Hopkins Becket John Bryan Maurice Carter Robert Cartwright Patrick McLoughlin Mary Poppins Carroll Clark William H. Tuntke Hal Gausman Emile Kuri The Unsinkable Molly Brown Preston Ames George W. Davis Henry Grace Hugh Hunt What a Way to Go! Ted Haworth Jack Martin Smith Stuart A. Reiss Walter M. Scott My Fair Lady Jack L. Warner Becket Hal B. Wallis Dr. Strangelove Or: How I Learned To Stop Worrying and Love the Bomb Stanley Kubrick Mary Poppins Walt Disney Bill Walsh Zorba the Greek Michael Cacoyannis Zorba the Greek Walter Lassally The Americanization of Emily Philip H. Lathrop Fate Is the Hunter Milton Krasner Hush...Hush, Sweet Charlotte Joseph Biroc The Night of the Iguana Gabriel Figueroa My Fair Lady Harry Stradling Becket Geoffrey Unsworth Cheyenne Autumn William H. Clothier Mary Poppins Edward Colman The Unsinkable Molly Brown Daniel L. Fapp The Night of the Iguana Dorothy Jeakins A House Is Not a Home Edith Head Hush...Hush, Sweet Charlotte Norma Koch Kisses for My President Howard Shoup The Visit René Hubert My Fair Lady Cecil Beaton Becket Margaret Furse Mary Poppins Tony Walton The Unsinkable Molly Brown Morton Haack What a Way to Go! Edith Head Moss Mabry My Fair Lady George Cukor Becket Peter Glenville Dr. Strangelove Or: How I Learned To Stop Worrying and Love the Bomb Stanley Kubrick Mary Poppins Robert Stevenson Zorba the Greek Michael Cacoyannis Jacques-Yves Cousteau's World Without Sun Jacques-Yves Cousteau The Finest Hours Jack Le Vien Four Days in November Mel Stuart The Human Dutch Bert Haanstra Over There, 1914-18 Jean Aurel Nine from Little Rock Charles Guggenheim 140 Days Under the World Oxley Hughan Geoffrey Scott Breaking the Habit Henry Jacobs John Korty Children Without Charles Guggenheim Kenojuak National Film Board of Canada Mary Poppins Cotton Warburton Becket Anne Coates Father Goose Ted J. Kent Hush...Hush, Sweet Charlotte Michael Luciano My Fair Lady William Ziegler Yesterday, Today and Tomorrow Italy Raven's End Sweden Sallah Israel The Umbrellas of Cherbourg France Woman in the Dunes Japan Mary Poppins Richard M. Sherman Robert B. Sherman Becket Laurence Rosenthal The Fall of the Roman Empire Dimitri Tiomkin Hush...Hush, Sweet Charlotte Frank DeVol The Pink Panther Henry Mancini My Fair Lady Andre Previn A Hard Day's Night George Martin Mary Poppins Irwin Kostal Robin and the 7 Hoods Nelson Riddle The Unsinkable Molly Brown Robert Armbruster Leo Arnaud Jack Elliott Jack Hayes Calvin Jackson Leo Shuken Chim Chim Cher-Ee Mary Poppins Richard M. Sherman Robert B. Sherman Dear Heart Dear Heart Ray Evans Jay Livingston Henry Mancini Hush...Hush, Sweet Charlotte Hush...Hush, Sweet Charlotte Mack David Frank DeVol My Kind of Town Robin and the 7 Hoods Sammy Cahn James Van Heusen Where Love Has Gone Where Love Has Gone Sammy Cahn James Van Heusen Becket Edward Anhalt Dr. Strangelove Or: How I Learned To Stop Worrying and Love the Bomb Peter George Stanley Kubrick Terry Southern Mary Poppins Don DaGradi Bill Walsh My Fair Lady Alan Jay Lerner Zorba the Greek Michael Cacoyannis The Pink Phink David H. DePatie Friz Freleng Christmas Cracker National Film Board of Canada How To Avoid Friendship William L. Snyder Nudnik #2 William L. Snyder Casals Conducts: 1964 Edward Schreiber Help! My Snowman's Burning Down Carson Davidson The Legend of Jimmy Blue Eyes Robert Clouse My Fair Lady Warner Bros. Studio Sound Department WGeorge R. Groves Becket Shepperton Studio Sound Department John Cox Father Goose Universal City Studio Sound Department Waldon O. Watson Mary Poppins Walt Disney Studio Sound Department Robert O. Cook The Unsinkable Molly Brown Metro-Goldwyn-Mayer Studio Sound Department Franklin E. Milton Goldfinger Norman Wanstall The Lively Set Robert L. Bratton Mary Poppins Peter Ellenshaw Hamilton Luske Eustace Lycett 7 Faces of Dr. Lao Jim Danforth Father Goose S. H. Barnett Peter Stone Frank Tarloff A Hard Day's Night Alun Owen One Potato, Two Potato Orville H. Hampton Raphael Hayes The Organizer Age Mario Monicelli Scarpelli That Man from Rio Daniel Boulanger Philippe De Broca Ariane Mnouchkine Jean-Paul Rappeneau Cat Ballou Lee Marvin The Spy Who Came in from the Cold Richard Burton Othello Laurence Olivier The Pawnbroker Rod Steiger Ship of Fools Oskar Werner A Thousand Clowns Martin Balsam The Flight of the Phoenix Ian Bannen Doctor Zhivago Tom Courtenay Ship of Fools Michael Dunn Othello Frank Finlay Darling Julie Christie The Sound of Music Julie Andrews The Collector Samantha Eggar A Patch of Blue Elizabeth Hartman Ship of Fools Simone Signoret A Patch of Blue Shelley Winters Inside Daisy Clover Ruth Gordon Othello Joyce Redman Othello Maggie Smith The Sound of Music Peggy Wood Ship of Fools Robert Clatworthy Joseph Kish King Rat Robert Emmet Smith Frank Tuttle A Patch of Blue George W. Davis Urie McCleary Henry Grace Charles S. Thompson The Slender Thread Hal Pereira Jack Poplin Robert Benton Joseph Kish The Spy Who Came in from the Cold Tambi Larsen Edward Marshall Hal Pereira Josie MacAvin Doctor Zhivago John Box Terry Marsh Dario Simoni The Agony and the Ecstasy John DeCuir Jack Martin Smith Dario Simoni The Greatest Story Ever Told William Creber Richard Day David Hall Fred MacLean Ray Moyer Norman Rockett Inside Daisy Clover Robert Clatworthy George James Hopkins The Sound of Music Boris Leven Ruby Levitt Walter M. Scott The Sound of Music Robert Wise Darling Joseph Janni Doctor Zhivago Carlo Ponti Ship of Fools Stanley Kramer A Thousand Clowns Fred Coe Ship of Fools Ernest Laszlo In Harm's Way Loyal Griggs King Rat Burnett Guffey Morituri Conrad Hall A Patch of Blue Robert Burks Doctor Zhivago Freddie Young The Agony and the Ecstasy Leon Shamroy The Great Race Russell Harlan The Greatest Story Ever Told Loyal Griggs William C. Mellor The Sound of Music Ted McCord Darling Julie Harris Morituri Moss Mabry A Rage To Live Howard Shoup Ship of Fools Jean Louis Bill Thomas The Slender Thread Edith Head Doctor Zhivago Phyllis Dalton The Agony and the Ecstasy Vittorio Nino Novarese The Greatest Story Ever Told Marjorie Best Vittorio Nino Novarese Inside Daisy Clover Edith Head Bill Thomas The Sound of Music Dorothy Jeakins The Sound of Music Robert Wise The Collector William Wyler Darling John Schlesinger Doctor Zhivago David Lean Woman in the Dunes Hiroshi Teshigahara The Eleanor Roosevelt Story Sidney Glazier The Battle of the Bulge...the Brave Rifles Laurence E. Mascott The Forth Road Bridge Peter Mills Let My People Go Marshall Flaum To Die in Madrid Frédéric Rossif To Be Alive! Francis Thompson Mural on Our Street Kirk Smallman Ouverture Mafilm Productions Point of View Vision Associates Productions Yeats Country Patrick Carey Joe Mendoza The Sound of Music William Reynolds Cat Ballou Charles Nelson Doctor Zhivago Norman Savage The Flight of the Phoenix Michael Luciano The Great Race Ralph E. Winters The Shop on Main Street Czechoslovakia Blood on the Land Greece Dear John Sweden Kwaidan Japan Marriage Italian Style Italy Doctor Zhivago Maurice Jarre The Agony and the Ecstasy Alex North The Greatest Story Ever Told Alfred Newman A Patch of Blue Jerry Goldsmith The Umbrellas of Cherbourg Jacques Demy Michel Legrand The Sound of Music Irwin Kostal Cat Ballou DeVol The Pleasure Seekers Alexander Courage Lionel Newman A Thousand Clowns Don Walker The Umbrellas of Cherbourg Michel Legrand The Shadow of Your Smile The Sandpiper Johnny Mandel Paul Francis Webster I Will Wait for You The Umbrellas of Cherbourg Jacques Demy Norman Gimbel Michel Legrand The Ballad of Cat Ballou Cat Ballou Mack David Jerry Livingston The Sweetheart Tree The Great Race Henry Mancini Johnny Mercer What's New Pussycat? What's New Pussycat? Burt Bacharach Hal David Doctor Zhivago Robert Bolt Cat Ballou Walter Newman Frank R. Pierson The Collector John Kohn Stanley Mann Ship of Fools Abby Mann A Thousand Clowns Herb Gardner The Dot and the Line Les Goldman Chuck Jones Clay Or the Origin of Species Eliot Noyes Jr. The Thieving Magpie (La Gazza Ladra) Emanuele Luzzati The Chicken (Le Poulet) Claude Berri Fortress of Peace Lothar Wolff Skaterdater Marshal Backlar Noel Black Snow Edgar Anstey Time Piece Jim Henson The Sound of Music Todd-AO Sound Department Fred Hynes 20th Century-Fox Studio Sound Department James P. Corcoran The Agony and the Ecstasy 20th Century-Fox Studio Sound Department James P. Corcoran Doctor Zhivago Metro-Goldwyn-Mayer British Studio Sound Department A. W. Watkins Metro-Goldwyn-Mayer Studio Sound Department Franklin E. Milton The Great Race Warner Bros. Studio Sound Department George R. Groves Shenandoah Universal City Studio Sound Department Waldon O. Watson The Great Race Tregoweth Brown Von Ryan's Express Walter A. Rossi Thunderball John Stears The Greatest Story Ever Told J. McMillan Johnson Darling Frederic Raphael Casanova '70 Age Suso Cecchi D'Amico Tonino Guerra Mario Monicelli Giorgio Salvioni Scarpelli Those Magnificent Men in Their Flying Machines Ken Annakin Jack Davies The Train Franklin Coen Frank Davis The Umbrellas of Cherbourg Jacques Demy A Man for All Seasons Paul Scofield The Russians are Coming the Russians are Coming Alan Arkin Who's Afraid of Virginia Woolf? Richard Burton Alfie Michael Caine The Sand Pebbles Steve McQueen The Fortune Cookie Walter Matthau The Sand Pebbles Mako Georgy Girl James Mason Who's Afraid of Virginia Woolf? George Segal A Man for All Seasons Robert Shaw Who's Afraid of Virginia Woolf? Elizabeth Taylor A Man and a Woman Anouk Aimee The Shop on Main Street Ida Kaminska Georgy Girl Lynn Redgrave Morgan! Vanessa Redgrave Who's Afraid of Virginia Woolf? Sandy Dennis A Man for All Seasons Wendy Hiller Hawaii Jocelyne Lagarde Alfie Vivien Merchant You're a Big Boy Now Geraldine Page Who's Afraid of Virginia Woolf? Richard Sylbert George James Hopkins The Fortune Cookie Robert Luthardt Edward G. Boyle The Gospel According to St. Matthew Luigi Scaccianoce Is Paris Burning? Willy Holt Marc Frederix Pierre Guffroy Mister Buddwing George W. Davis Paul Groesse Henry Grace Hugh Hunt Fantastic Voyage Dale Hennesy Jack Martin Smith Stuart A. Reiss Walter M. Scott Gambit Alexander Golitzen George C. Webb John Austin John McCarthy Juliet of the Spirits Piero Gherardi The Oscar Arthur Lonergan Hal Pereira Robert Benton James Payne The Sand Pebbles Boris Leven William Kiernan Walter M. Scott John Sturtevant A Man for All Seasons Fred Zinnemann Alfie Lewis Gilbert The Russians are Coming the Russians are Coming Norman Jewison The Sand Pebbles Robert Wise Who's Afraid of Virginia Woolf? Ernest Lehman Who's Afraid of Virginia Woolf? Haskell Wexler The Fortune Cookie Joseph LaShelle Georgy Girl Ken Higgins Is Paris Burning? Marcel Grignon Seconds James Wong Howe A Man for All Seasons Ted Moore Fantastic Voyage Ernest Laszlo Hawaii Russell Harlan The Professionals Conrad Hall The Sand Pebbles Joseph MacDonald Who's Afraid of Virginia Woolf? Irene Sharaff The Gospel According to St. Matthew Danilo Donati Mandragola Danilo Donati Mister Buddwing Helen Rose Morgan! Jocelyn Rickards A Man for All Seasons Joan Bridge Elizabeth Haffenden Gambit Jean Louis Hawaii Dorothy Jeakins Juliet of the Spirits Piero Gherardi The Oscar Edith Head A Man for All Seasons Fred Zinnemann Blow-Up Michelangelo Antonioni A Man and a Woman Claude Lelouch The Professionals Richard Brooks Who's Afraid of Virginia Woolf? Mike Nichols The War Game Peter Watkins The Face of Genius Alfred R. Kelman Helicopter Canada Tom Daly Peter Jones Le Volcan Interdit (The Forbidden Volcano) Haroun Tazieff The Really Big Family Alex Grasshoff A Year Toward Tomorrow Edmond A. Levy Adolescence Vladimir Forgency Marin Karmitz Cowboy Michael Ahnemann Gary Schlosser The Odds Against Lee R. Bobker Helen Kristt Radin Saint Matthew Passion Mafilm Studio Grand Prix Henry Berman Stewart Linder Frank Santillo Fredric Steinkamp Fantastic Voyage William B. Murphy The Russians are Coming the Russians are Coming Hal Ashby J. Terry Williams The Sand Pebbles William Reynolds Who's Afraid of Virginia Woolf? Sam O'Steen A Man and a Woman France The Battle of Algiers Italy Loves of a Blonde Czechoslovakia Pharaoh Poland Three Yugoslavia Born Free John Barry The Bible Toshiro Mayuzumi Hawaii Elmer Bernstein The Sand Pebbles Jerry Goldsmith Who's Afraid of Virginia Woolf? Alex North A Funny Thing Happened on the Way to the Forum Ken Thorne The Gospel According to St. Matthew Luis Enrique Bacalov Return of the Seven Elmer Bernstein The Singing Nun Harry Sukman Stop the World - I Want To Get Off Al Ham Born Free Born Free John Barry Don Black A Time for Love An American Dream Johnny Mandel Paul Francis Webster Alfie Alfie Burt Bacharach Hal David Georgy Girl Georgy Girl Jim Dale Tom Springfield My Wishing Doll Hawaii Elmer Bernstein Mack David A Man for All Seasons Robert Bolt Alfie Bill Naughton The Professionals Richard Brooks The Russians are Coming the Russians are Coming William Rose Who's Afraid of Virginia Woolf? Ernest Lehman Herb Alpert and the Tijuana Brass Double Feature Faith Hubley John Hubley The Drag Wolf Koenig Robert Verrall The Pink Blueprint David H. DePatie Friz Freleng Wild Wings Edgar Anstey Turkey the Bridge Derek Williams The Winning Strain Leslie Winik Grand Prix Metro-Goldwyn-Mayer Studio Sound Department Franklin E. Milton Gambit Universal City Studio Sound Department Waldon O. Watson Hawaii Samuel Goldwyn Studio Sound Department Gordon E. Sawyer The Sand Pebbles 20th Century-Fox Studio Sound Department James P. Corcoran Who's Afraid of Virginia Woolf? Warner Bros. Studio Sound Department George R. Groves Grand Prix Gordon Daniel Fantastic Voyage Walter Rossi Fantastic Voyage Art Cruickshank Hawaii Linwood G. Dunn A Man and a Woman Claude Lelouch Pierre Uytterhoeven Blow-Up Michelangelo Antonioni Edward Bond Tonino Guerra The Fortune Cookie I. A. L. Diamond Billy Wilder Khartoum Robert Ardrey The Naked Prey Clint Johnston Don Peters In the Heat of the Night Rod Steiger Bonnie and Clyde Warren Beatty The Graduate Dustin Hoffman Cool Hand Luke Paul Newman Guess Who's Coming to Dinner Spencer Tracy Cool Hand Luke George Kennedy The Dirty Dozen John Cassavetes Bonnie and Clyde Gene Hackman Guess Who's Coming to Dinner Cecil Kellaway Bonnie and Clyde Michael J. Pollard Guess Who's Coming to Dinner Katharine Hepburn The Graduate Anne Bancroft Bonnie and Clyde Faye Dunaway The Whisperers Dame Edith Evans Wait Until Dark Audrey Hepburn Bonnie and Clyde Estelle Parsons Thoroughly Modern Millie Carol Channing Barefoot in the Park Mildred Natwick Guess Who's Coming to Dinner Beah Richards The Graduate Katharine Ross Camelot Edward Carrere John Truscott John W. Brown Doctor Dolittle Mario Chiari Ed Graves Jack Martin Smith Stuart A. Reiss Walter M. Scott Guess Who's Coming to Dinner Robert Clatworthy Frank Tuttle The Taming of the Shrew John DeCuir Giuseppe Mariani Renzo Mongiardino Elven Webb Luigi Gervasi Dario Simoni Thoroughly Modern Millie Alexander Golitzen George C. Webb Howard Bristol In the Heat of the Night Walter Mirisch Bonnie and Clyde Warren Beatty Doctor Dolittle Arthur P. Jacobs The Graduate Lawrence Turman Guess Who's Coming to Dinner Stanley Kramer Bonnie and Clyde Burnett Guffey Camelot Richard H. Kline Doctor Dolittle Robert Surtees The Graduate Robert Surtees In Cold Blood Conrad Hall Camelot John Truscott Bonnie and Clyde Theadora Van Runkle The Happiest Millionaire Bill Thomas The Taming of the Shrew Danilo Donati Irene Sharaff Thoroughly Modern Millie Jean Louis The Graduate Mike Nichols Bonnie and Clyde Arthur Penn Guess Who's Coming to Dinner Stanley Kramer In Cold Blood Richard Brooks In the Heat of the Night Norman Jewison The Anderson Platoon Pierre Schoendoerffer Festival Murray Lerner Harvest Carroll Ballard A King's Story Jack Le Vien A Time for Burning William C. Jersey The Redwoods Trevor Greenwood Mark Harris Monument to the Dream Charles E. Guggenheim A Place To Stand Christopher Chapman See You at the Pillar Robert Fitchett While I Run This Race Carl V. Ragsdale In the Heat of the Night Hal Ashby Beach Red Frank P. Keller The Dirty Dozen Michael Luciano Doctor Dolittle Samuel E. Beetley Marjorie Fowler Guess Who's Coming to Dinner Robert C. Jones Closely Watched Trains Czechoslovakia El Amor Brujo Spain I Even Met Happy Gypsies Yugoslavia Live for Life France Portrait of Chieko Japan Thoroughly Modern Millie Elmer Bernstein Cool Hand Luke Lalo Schifrin Doctor Dolittle Leslie Bricusse Far from the Madding Crowd Richard Rodney Bennett In Cold Blood Quincy Jones Camelot Ken Darby Alfred Newman Doctor Dolittle Alexander Courage Lionel Newman Guess Who's Coming to Dinner DeVol Thoroughly Modern Millie Joseph Gershenson Andre Previn Valley of the Dolls John Williams Talk to the Animals Doctor Dolittle Leslie Bricusse The Bare Necessities The Jungle Book Terry Gilkyson The Eyes of Love Banning Quincy Jones Bob Russell The Look of Love Casino Royale Burt Bacharach Hal David Thoroughly Modern Millie Thoroughly Modern Millie Sammy Cahn James Van Heusen In the Heat of the Night Stirling Silliphant Cool Hand Luke Donn Pearce Frank R. Pierson The Graduate Buck Henry Calder Willingham In Cold Blood Richard Brooks Ulysses Fred Haines Joseph Strick The Box Fred Wolf Hypothese Beta Jean-Charles Meunier What on Earth! Wolf Koenig Robert Verrall A Place to Stand Christopher Chapman Paddle to the Sea Julian Biggs Sky Over Holland John Ferno Stop, Look and Listen Len Janson Chuck Menville In the Heat of the Night Samuel Goldwyn Studio Sound Department Camelot Seven Arts Studio Sound Department The Dirty Dozen Metro-Goldwyn-Mayer Studio Sound Department Doctor Dolittle 20th Century-Fox Studio Sound Department Thoroughly Modern Millie Universal City Studio Sound Department The Dirty Dozen John Poyner In the Heat of the Night James A. Richard Doctor Dolittle L. B. Abbott Tobruk Howard A. Anderson Jr. Albert Whitlock Guess Who's Coming to Dinner William Rose Bonnie and Clyde Robert Benton David Newman Divorce American Style Robert Kaufman Norman Lear La Guerre Est Finie Jorge Semprun Two for the Road Frederic Raphael Charly Cliff Robertson The Heart Is a Lonely Hunter Alan Arkin The Fixer Alan Bates Oliver! Ron Moody The Lion in Winter Peter O'Toole The Subject Was Roses Jack Albertson Faces Seymour Cassel Star! Daniel Massey Oliver! Jack Wild The Producers Gene Wilder The Lion in Winter Katharine Hepburn Funny Girl Barbra Streisand The Subject Was Roses Patricia Neal Isadora Vanessa Redgrave Rachel, Rachel Joanne Woodward Rosemary's Baby Ruth Gordon Faces Lynn Carlin The Heart Is a Lonely Hunter Sondra Locke Funny Girl Kay Medford Rachel, Rachel Estelle Parsons Oliver! John Box Terence Marsh Vernon Dixon Ken Muggleston 2001: A Space Odyssey Ernie Archer Harry Lange Tony Masters The Shoes of the Fisherman Edward Carfagno George W. Davis Star! Boris Leven Howard Bristol Walter M. Scott War and Peace Mikhail Bogdanov Gennady Myasnikov G. Koshelev V. Uvarov Oliver! John Woolf Funny Girl Ray Stark The Lion in Winter Martin Poll Rachel, Rachel Paul Newman Romeo and Juliet John Brabourne Anthony Havelock-Allan Romeo and Juliet Pasqualino De Santis Funny Girl Harry Stradling Ice Station Zebra Daniel L. Fapp Oliver! Oswald Morris Star! Ernest Laszlo Romeo and Juliet Danilo Donati The Lion in Winter Margaret Furse Oliver! Phyllis Dalton Planet of the Apes Morton Haack Star! Donald Brooks Oliver! Carol Reed 2001: A Space Odyssey Stanley Kubrick The Battle of Algiers Gillo Pontecorvo The Lion in Winter Anthony Harvey Romeo and Juliet Franco Zeffirelli Journey Into Self Bill McGaw A Few Notes on Our Food Problem James Blue The Legendary Champions William Cayton Other Voices David H. Sawyer Young Americans Robert Cohn Alex Grasshoff Why Man Creates Saul Bass The House That Ananda Built Fali Bilimoria The Revolving Door Lee R. Bobker A Space to Grow Thomas P. Kelly Jr. A Way Out of the Wilderness Dan E. Weisburd Bullitt Frank P. Keller Funny Girl William Sands Robert Swink Maury Winetrobe The Odd Couple Frank Bracht Oliver! Ralph Kemplen Wild in the Streets Fred Feitshans Eve Newman War and Peace Union of Soviet Socialist Republics The Boys of Paul Street Hungary The Firemen's Ball Czechoslovakia The Girl with the Pistol Italy Stolen Kisses France The Lion in Winter John Barry The Fox Lalo Schifrin Planet of the Apes Jerry Goldsmith The Shoes of the Fisherman Alex North The Thomas Crown Affair Michel Legrand Oliver! John Green Finian's Rainbow Ray Heindorf Funny Girl Walter Scharf Star! Lennie Hayton The Young Girls of Rochefort Jacques Demy Michel Legrand The Windmills of Your Mind The Thomas Crown Affair Alan Bergman Marilyn Bergman Michel Legrand Chitty Chitty Bang Bang Chitty Chitty Bang Bang Richard M. Sherman Robert B. Sherman For Love of Ivy For Love of Ivy Quincy Jones Bob Russell Funny Girl Funny Girl Bob Merrill Jule Styne Star! Star! Sammy Cahn Jimmy Van Heusen The Lion in Winter James Goldman The Odd Couple Neil Simon Oliver! Vernon Harris Rachel, Rachel Stewart Stern Rosemary's Baby Roman Polanski Winnie the Pooh and the Blustery Day Walt Disney The House That Jack Built Wolf Koenig Jim MacKay The Magic Pear Tree Jimmy Murakami Windy Day Faith Hubley John Hubley Robert Kennedy Remembered Charles Guggenheim The Dove George Coe Sidney Davis Anthony Lover Duo National Film Board of Canada Prelude John Astin Oliver! Shepperton Studio Sound Department Bullitt Warner Bros.-Seven Arts Studio Sound Department Finian's Rainbow Warner Bros.-Seven Arts Studio Sound Department Funny Girl Columbia Studio Sound Department Star! 20th Century-Fox Studio Sound Department 2001: A Space Odyssey Stanley Kubrick Ice Station Zebra J. McMillan Johnson Hal Millar The Producers Mel Brooks 2001: A Space Odyssey Arthur C. Clarke Stanley Kubrick The Battle of Algiers Gillo Pontecorvo Franco Solinas Faces John Cassavetes Hot Millions Peter Ustinov Ira Wallach True Grit John Wayne Anne of the Thousand Days Richard Burton Midnight Cowboy Dustin Hoffman Goodbye, Mr. Chips Peter O'Toole Midnight Cowboy Jon Voight They Shoot Horses, Don't They? Gig Young The Reivers Rupert Crosse Bob & Carol & Ted & Alice Elliott Gould Easy Rider Jack Nicholson Anne of the Thousand Days Anthony Quayle The Prime of Miss Jean Brodie Maggie Smith Anne of the Thousand Days Genevieve Bujold They Shoot Horses, Don't They? Jane Fonda The Sterile Cuckoo Liza Minnelli The Happy Ending Jean Simmons Cactus Flower Goldie Hawn Last Summer Catherine Burns Bob & Carol & Ted & Alice Dyan Cannon Midnight Cowboy Sylvia Miles They Shoot Horses, Don't They? Susannah York Hello, Dolly! Herman Blumenthal John DeCuir Jack Martin Smith Raphael Bretton George Hopkins Walter M. Scott Anne of the Thousand Days Maurice Carter Lionel Couch Patrick McLoughlin Gaily, Gaily Robert Boyle George B. Chan Carl Biddiscombe Edward Boyle Sweet Charity Alexander Golitzen George C. Webb Jack D. Moore They Shoot Horses, Don't They? Harry Horner Frank McKelvy Midnight Cowboy Jerome Hellman Anne of the Thousand Days Hal B. Wallis Butch Cassidy and the Sundance Kid John Foreman Hello, Dolly! Ernest Lehman Z Jacques Perrin Hamed Rachedi Butch Cassidy and the Sundance Kid Conrad Hall Anne of the Thousand Days Arthur Ibbetson Bob & Carol & Ted & Alice Charles B. Lang Hello, Dolly! Harry Stradling Marooned Daniel Fapp Anne of the Thousand Days Margaret Furse Gaily, Gaily Ray Aghayan Hello, Dolly! Irene Sharaff Sweet Charity Edith Head They Shoot Horses, Don't They? Donfeld Midnight Cowboy John Schlesinger Alice's Restaurant Arthur Penn Butch Cassidy and the Sundance Kid George Roy Hill They Shoot Horses, Don't They? Sydney Pollack Z Costa-Gavras Arthur Rubinstein - The Love of Life Bernard Chevry Before the Mountain Was Moved Robert K. Sharpe In the Year of the Pig Emile de Antonio The Olympics in Mexico Comite Organizador de los Juegos de la XIX Olimpiada The Wolf Men Irwin Rosten Czechoslovakia 1968 Robert M. Fresco Denis Sanders An Impression of John Steinbeck: Writer Donald Wrye Jenny Is a Good Thing Joan Horvath Leo Beuerman Russell A. Mosser Arthur H. Wolf The Magic Machines Joan Keller Stern Z Françoise Bonnot Hello, Dolly! William Reynolds Midnight Cowboy Hugh A. Robertson The Secret of Santa Vittoria Earle Herdan William Lyon They Shoot Horses, Don't They? Fredric Steinkamp Z Algeria Adalen `31 Sweden The Battle of Neretva Yugoslavia The Brothers Karamazov Union of Soviet Socialist Republics My Night with Maud France Butch Cassidy and the Sundance Kid Burt Bacharach Anne of the Thousand Days Georges Delerue The Reivers John Williams The Secret of Santa Vittoria Ernest Gold The Wild Bunch Jerry Fielding Hello, Dolly! Lennie Hayton Lionel Newman Goodbye, Mr. Chips Leslie Bricusse John Williams Paint Your Wagon Nelson Riddle Sweet Charity Cy Coleman They Shoot Horses, Don't They? John Green Albert Woodbury Raindrops Keep Fallin' on My Head Butch Cassidy and the Sundance Kid Burt Bacharach Hal David Come Saturday Morning The Sterile Cuckoo Fred Karlin Dory Previn Jean The Prime of Miss Jean Brodie Rod McKuen True Grit True Grit Elmer Bernstein Don Black What are You Doing the Rest of Your Life? The Happy Ending Alan Bergman Marilyn Bergman Michel Legrand Midnight Cowboy Waldo Salt Anne of the Thousand Days Bridget Boland John Hale Richard Sokolove Goodbye, Columbus Arnold Schulman They Shoot Horses, Don't They? James Poe Robert E. Thompson Z Costa-Gavras Jorge Semprun It's Tough to Be a Bird Ward Kimball Of Men and Demons Faith Hubley John Hubley Walking Ryan Larkin The Magic Machines Joan Keller Stern Blake Doug Jackson People Soup Marc Merson Hello, Dolly! Jack Solomon Murray Spivack Anne of the Thousand Days John Aldred Butch Cassidy and the Sundance Kid David Dockendorf William Edmundson Gaily, Gaily Robert Martin Clem Portman Marooned Les Fresholtz Arthur Piantadosi Marooned Robbie Robertson Krakatoa, East of Java Eugene Lourie Alex Weldon Butch Cassidy and the Sundance Kid William Goldman Bob & Carol & Ted & Alice Paul Mazursky Larry Tucker The Damned Nicola Badalucco Enrico Medioli Luchino Visconti Easy Rider Peter Fonda Dennis Hopper Terry Southern The Wild Bunch Walon Green Sam Peckinpah Roy N. Sickner Patton George C. Scott I Never Sang for My Father Melvyn Douglas The Great White Hope James Earl Jones Five Easy Pieces Jack Nicholson Love Story Ryan O'Neal Ryan's Daughter John Mills Lovers and Other Strangers Richard Castellano Little Big Man Chief Dan George I Never Sang for My Father Gene Hackman Love Story John Marley Women in Love Glenda Jackson The Great White Hope Jane Alexander Love Story Ali MacGraw Ryan's Daughter Sarah Miles Diary of a Mad Housewife Carrie Snodgress Airport Helen Hayes Five Easy Pieces Karen Black The Landlord Lee Grant M*A*S*H Sally Kellerman Airport Maureen Stapleton Patton Urie McCleary Gil Parrondo Antonio Mateos Pierre-Louis Thevenet Airport E. Preston Ames Alexander Golitzen Mickey S. Michaels Jack D. Moore The Molly Maguires Tambi Larsen Darrell Silvera Scrooge Bob Cartwright Terry Marsh Pamela Cornell Tora! Tora! Tora! Richard Day Taizoh Kawashima Yoshiro Muraki Jack Martin Smith Carl Biddiscombe Norman Rockett Walter M. Scott Patton Frank McCarthy Airport Ross Hunter Five Easy Pieces Bob Rafelson Richard Wechsler Love Story Howard G. Minsky M*A*S*H Ingo Preminger Ryan's Daughter Freddie Young Airport Ernest Laszlo Patton Fred Koenekamp Tora! Tora! Tora! Osami Furuya Sinsaku Himeda Masamichi Satoh Charles F. Wheeler Women in Love Billy Williams Cromwell Nino Novarese Airport Edith Head Darling Lili Jack Bear Donald Brooks The Hawaiians Bill Thomas Scrooge Margaret Furse Patton Franklin J. Schaffner Fellini Satyricon Federico Fellini Love Story Arthur Hiller M*A*S*H Robert Altman Women in Love Ken Russell Woodstock Bob Maurice Chariots of the Gods Dr. Harald Reinl Jack Johnson Jim Jacobs King: A Filmed Record...Montgomery to Memphis Ely Landau Say Goodbye David H. Vowell Interviews with My Lai Veterans Joseph Strick The Gifts Robert McBride A Long Way from Nowhere Bob Aller Oisin Patrick Carey Vivien Carey Time Is Running Out Horst Dallmayr Robert Menegoz Patton Hugh S. Fowler Airport Stuart Gilmore M*A*S*H Danford B. Greene Tora! Tora! Tora! Inoue Chikaya Pembroke J. Herring James E. Newcom Woodstock Thelma Schoonmaker Investigation of a Citizen Above Suspicion Italy First Love Switzerland Hoa-Binh France Paix Sur Les Champs Belgium Tristana Spain Love Story Francis Lai Airport Alfred Newman Cromwell Frank Cordell Patton Jerry Goldsmith Sunflower Henry Mancini Let It Be The Beatles The Baby Maker Fred Karlin Tylwyth Kymry A Boy Named Charlie Brown Vince Guaraldi Rod McKuen Bill Melendez Al Shean John Scott Trotter Darling Lili Henry Mancini Johnny Mercer Scrooge Leslie Bricusse Ian Fraser Herbert W. Spencer For All We Know Lovers and Other Strangers James Griffin Fred Karlin Robb Royer Pieces of Dreams Pieces of Dreams Alan Bergman Marilyn Bergman Michel Legrand Thank You Very Much Scrooge Leslie Bricusse Till Love Touches Your Life Madron Arthur Hamilton Riz Ortolani Whistling Away the Dark Darling Lili Henry Mancini Johnny Mercer M*A*S*H Ring Lardner Jr. Airport George Seaton I Never Sang for My Father Robert Anderson Lovers and Other Strangers Joseph Bologna David Zelag Goodman Renee Taylor Women in Love Larry Kramer Is It Always Right To Be Right? Nick Bosustow The Further Adventures of Uncle Sam: Part Two Dale Case Robert Mitchell The Shepherd Cameron Guess The Resurrection of Broncho Billy John Longenecker Shut Up...I'm Crying Robert Siegler Sticky My Fingers...Fleet My Feet John Hancock Patton Don Bassman Douglas Williams Airport David Moriarty Ronald Pierce Ryan's Daughter John Bramall Gordon K. McCallum Tora! Tora! Tora! Herman Lewis Murray Spivack Woodstock Larry Johnson Dan Wallin Tora! Tora! Tora! L. B. Abbott A. D. Flowers Patton Alex Weldon Patton Francis Ford Coppola Edmund H. North Five Easy Pieces Adrien Joyce Bob Rafelson Joe Norman Wexler Love Story Erich Segal My Night at Maud's Eric Rohmer The French Connection Gene Hackman Sunday Bloody Sunday Peter Finch Kotch Walter Matthau The Hospital George C. Scott Fiddler on the Roof Topol The Last Picture Show Ben Johnson The Last Picture Show Jeff Bridges Fiddler on the Roof Leonard Frey Sometimes a Great Notion Richard Jaeckel The French Connection Roy Scheider Klute Jane Fonda Mccabe & Mrs. Miller Julie Christie Sunday Bloody Sunday Glenda Jackson Mary, Queen of Scots Vanessa Redgrave Nicholas and Alexandra Janet Suzman The Last Picture Show Cloris Leachman Carnal Knowledge Ann-Margret The Last Picture Show Ellen Burstyn Who Is Harry Kellerman and Why Is He Saying Those Terrible Things about Me? Barbara Harris The Go-Between Margaret Leighton Nicholas and Alexandra Ernest Archer John Box Jack Maxsted Gil Parrondo Vernon Dixon The Andromeda Strain Boris Leven William Tuntke Ruby Levitt Bedknobs and Broomsticks Peter Ellenshaw John B. Mansbridge Hal Gausman Emile Kuri Fiddler on the Roof Robert Boyle Michael Stringer Peter Lamont Mary, Queen of Scots Robert Cartwright Terence Marsh Peter Howitt The French Connection Philip D'Antoni A Clockwork Orange Stanley Kubrick Fiddler on the Roof Norman Jewison The Last Picture Show Stephen J. Friedman Nicholas and Alexandra Sam Spiegel Fiddler on the Roof Oswald Morris The French Connection Owen Roizman The Last Picture Show Robert Surtees Nicholas and Alexandra Freddie Young Summer of '42 Robert Surtees Nicholas and Alexandra Yvonne Blake Antonia Castillo Bedknobs and Broomsticks Bill Thomas Death in Venice Piero Tosi Mary, Queen of Scots Margaret Furse What's the Matter with Helen? Morton Haack The French Connection William Friedkin A Clockwork Orange Stanley Kubrick Fiddler on the Roof Norman Jewison The Last Picture Show Peter Bogdanovich Sunday Bloody Sunday John Schlesinger The Hellstrom Chronicle Walon Green Alaska Wilderness Lake Alan Landsburg On Any Sunday Bruce Brown The Ra Expeditions Lennart Ehrenborg Thor Heyerdahl The Sorrow and the Pity Marcel Ophuls Sentinels of Silence Robert Amram Manuel Arango Adventures in Perception Hans van Gelder Art Is... Julian Krainin DeWitt L. Sage Jr. The Numbers Start with the River Donald Wrye Somebody Waiting Sherwood Omens Hal Riney Dick Snider The French Connection Jerry Greenberg The Andromeda Strain Stuart Gilmore John W. Holmes A Clockwork Orange Bill Butler Kotch Ralph E. Winters Summer of '42 Folmar Blangsted The Garden of the Finzi Continis Italy Dodes'ka-Den Japan The Emigrants Sweden The Policeman Israel Tchaikovsky Union of Soviet Socialist Republics Summer of '42 Michel Legrand Mary, Queen of Scots John Barry Nicholas and Alexandra Richard Rodney Bennett Shaft Isaac Hayes Straw Dogs Jerry Fielding Fiddler on the Roof John Williams Bedknobs and Broomsticks Irwin Kostal Richard M. Sherman Robert B. Sherman The Boy Friend Peter Greenwell Peter Maxwell Davies Tchaikovsky Dimitri Tiomkin Willy Wonka and the Chocolate Factory Leslie Bricusse Anthony Newley Walter Scharf Theme from Shaft Shaft Isaac Hayes All His Children Sometimes a Great Notion Alan Bergman Marilyn Bergman Henry Mancini Bless the Beasts & Children Bless the Beasts & Children Perry Botkin Jr. Barry DeVorzon Life Is What You Make It Kotch Marvin Hamlisch Johnny Mercer The Age of Not Believing Bedknobs and Broomsticks Richard M. Sherman Robert B. Sherman The French Connection Ernest Tidyman A Clockwork Orange Stanley Kubrick The Conformist Bernardo Bertolucci The Garden of the Finzi Continis Vittorio Bonicelli Ugo Pirro The Last Picture Show Peter Bogdanovich Larry McMurtry The Crunch Bird Ted Petok Evolution Michael Mills The Selfish Giant Peter Sander Murray Shostak Sentinels of Silence Robert Amram Manuel Arango Good Morning Denny Evans Ken Greenwald The Rehearsal Stephen F. Verona Fiddler on the Roof David Hildyard Gordon K. McCallum Diamonds are Forever Gordon K. McCallum John Mitchell Alfred J. Overton The French Connection Christopher Newman Theodore Soderberg Kotch Richard Portman Jack Solomon Mary, Queen of Scots John Aldred Bob Jones Bedknobs and Broomsticks Danny Lee Eustace Lycett Alan Maley When Dinosaurs Ruled the Earth Jim Danforth Roger Dicken The Hospital Paddy Chayefsky Investigation of a Citizen Above Suspicion Elio Petri Ugo Pirro Klute Andy Lewis Dave Lewis Summer of '42 Herman Raucher Sunday Bloody Sunday Penelope Gilliatt The Godfather Marlon Brando Sleuth Michael Caine Sleuth Laurence Olivier The Ruling Class Peter O'Toole Sounder Paul Winfield Cabaret Joel Grey The Heartbreak Kid Eddie Albert The Godfather James Caan The Godfather Robert Duvall The Godfather Al Pacino Cabaret Liza Minnelli Lady Sings the Blues Diana Ross Travels with My Aunt Maggie Smith Sounder Cicely Tyson The Emigrants Liv Ullmann Butterflies are Free Eileen Heckart The Heartbreak Kid Jeannie Berlin Pete 'N' Tillie Geraldine Page Fat City Susan Tyrrell The Poseidon Adventure Shelley Winters Cabaret Jurgen Kiebach Rolf Zehetbauer Herbert Strabel Lady Sings the Blues Carl Anderson Reg Allen The Poseidon Adventure William Creber Raphael Bretton Travels with My Aunt John Box Robert W. Laing Gil Parrondo Young Winston Don Ashton Geoffrey Drake John Graysmark William Hutchinson Peter James The Godfather Albert S. Ruddy Cabaret Cy Feuer Deliverance John Boorman The Emigrants Bengt Forslund Sounder Robert B. Radnitz Cabaret Geoffrey Unsworth 1776 Harry Stradling Jr. Butterflies are Free Charles B. Lang The Poseidon Adventure Harold E. Stine Travels with My Aunt Douglas Slocombe Travels with My Aunt Anthony Powell The Godfather Anna Hill Johnstone Lady Sings the Blues Ray Aghayan Norma Koch Bob Mackie The Poseidon Adventure Paul Zastupnevich Young Winston Anthony Mendleson Cabaret Bob Fosse Deliverance John Boorman The Emigrants Jan Troell The Godfather Francis Ford Coppola Sleuth Joseph L. Mankiewicz Marjoe Sarah Kernochan Howard Smith Ape and Super-Ape Bert Haanstra Malcolm X Arnold Perl Marvin Worth Manson Robert Hendrickson Laurence Merrick The Silent Revolution Eckehard Munck This Tiny World Charles Huguenot van der Linden Martina Huguenot van der Linden Hundertwasser's Rainy Day Peter Schamoni K-Z Giorgio Treves Selling Out Tadeusz Jaworski The Tide of Traffic Humphrey Swingler Cabaret David Bretherton Deliverance Tom Priestley The Godfather William Reynolds Peter Zinner The Hot Rock Fred W. Berger Frank P. Keller The Poseidon Adventure Harold F. Kress The Discreet Charm of the Bourgeoisie France The Dawns Here are Quiet Union of Soviet Socialist Republics I Love You Rosa Israel My Dearest Señorita Spain The New Land Sweden Limelight Charles Chaplin Raymond Rasch Larry Russell Napoleon and Samantha Buddy Baker The Poseidon Adventure John Williams Sleuth John Addison Images John Williams Cabaret Ralph Burns Lady Sings the Blues Gil Askey Man of La Mancha Laurence Rosenthal The Morning After The Poseidon Adventure Joel Hirschhorn Al Kasha Ben Ben Don Black Walter Scharf Come Follow, Follow Me The Little Ark Fred Karlin Marsha Karlin Marmalade, Molasses & Honey The Life and Times of Judge Roy Bean Alan Bergman Marilyn Bergman Maurice Jarre Strange are the Ways of Love The Stepmother Sammy Fain Paul Francis Webster The Godfather Francis Ford Coppola Mario Puzo Cabaret Jay Allen The Emigrants Bengt Forslund Jan Troell Pete 'N' Tillie Julius J. Epstein Sounder Lonne Elder III A Christmas Carol Richard Williams Kama Sutra Rides Again Bob Godfrey Tup Tup Nedeljko Dragic Norman Rockwell's World...an American Dream Richard Barclay Frog Story Ray Gideon Ron Satlof Solo David Adams Cabaret David Hildyard Robert Knudson Butterflies are Free Charles Knight Arthur Piantadosi The Candidate Gene Cantamessa Richard Portman The Godfather Bud Grenzbach Christopher Newman Richard Portman The Poseidon Adventure Herman Lewis Theodore Soderberg The Candidate Jeremy Larner The Discreet Charm of the Bourgeoisie Luis Buñuel Jean-Claude Carrière Lady Sings the Blues Chris Clark Suzanne de Passe Terence McCloy Murmur of the Heart Louis Malle Young Winston Carl Foreman Save the Tiger Jack Lemmon Last Tango in Paris Marlon Brando The Last Detail Jack Nicholson Serpico Al Pacino The Sting Robert Redford The Paper Chase John Houseman Bang the Drum Slowly Vincent Gardenia Save the Tiger Jack Gilford The Exorcist Jason Miller The Last Detail Randy Quaid A Touch of Class Glenda Jackson The Exorcist Ellen Burstyn Cinderella Liberty Marsha Mason The Way We Were Barbra Streisand Summer Wishes, Winter Dreams Joanne Woodward Paper Moon Tatum O'Neal The Exorcist Linda Blair American Graffiti Candy Clark Paper Moon Madeline Kahn Summer Wishes, Winter Dreams Sylvia Sidney The Sting Henry Bumstead James Payne Brother Sun Sister Moon Lorenzo Mongiardino Gianni Quaranta Carmelo Patrono The Exorcist Bill Malley Jerry Wunderlich Tom Sawyer Philip Jefferies Robert de Vestel The Way We Were Stephen Grimes William Kiernan The Sting Tony Bill Julia Phillips Michael Phillips American Graffiti Francis Ford Coppola Gary Kurtz Cries and Whispers Ingmar Bergman The Exorcist William Peter Blatty A Touch of Class Melvin Frank Cries and Whispers Sven Nykvist The Exorcist Owen Roizman Jonathan Livingston Seagull Jack Couffer The Sting Robert Surtees The Way We Were Harry Stradling Jr. The Sting Edith Head Cries and Whispers Marik Vos Ludwig Piero Tosi Tom Sawyer Donfeld The Way We Were Dorothy Jeakins Moss Mabry The Sting George Roy Hill American Graffiti George Lucas Cries and Whispers Ingmar Bergman The Exorcist William Friedkin Last Tango in Paris Bernardo Bertolucci The Great American Cowboy Kieth Merrill Always a New Beginning John D. Goodell Battle of Berlin Bengt von zur Muehlen Journey to the Outer Limits Alex Grasshoff Walls of Fire Gertrude Ross Marks Edmund F. Penney Princeton: A Search for Answers Julian Krainin DeWitt L. Sage Jr. Background Carmen D'Avino Children at Work (Paisti Ag Obair) Louis Marcus Christo's Valley Curtain Albert Maysles David Maysles Four Stones for Kanemitsu Terry Sanders June Wayne The Sting William Reynolds American Graffiti Verna Fields Marcia Lucas The Day of the Jackal Ralph Kemplen The Exorcist Norman Gay Jordan Leondopoulos Evan Lottman Bud Smith Jonathan Livingston Seagull James Galloway Frank P. Keller Day for Night France The House on Chelouche Street Israel L'invitation Switzerland The Pedestrian West Germany Turkish Delight The Netherlands The Way We Were Marvin Hamlisch Cinderella Liberty John Williams The Day of the Dolphin Georges Delerue Papillon Jerry Goldsmith A Touch of Class John Cameron The Sting Marvin Hamlisch Jesus Christ Superstar Andrew Lloyd Webber Andre Previn Herbert Spencer Tom Sawyer Richard M. Sherman Robert B. Sherman John Williams The Way We Were The Way We Were Alan Bergman Marilyn Bergman Marvin Hamlisch All That Love Went to Waste A Touch of Class George Barrie Sammy Cahn Live and Let Die Live and Let Die Linda McCartney Paul McCartney Love Robin Hood George Bruns Floyd Huddleston Nice to Be Around Cinderella Liberty John Williams Paul Williams The Exorcist William Peter Blatty The Last Detail Robert Towne The Paper Chase James Bridges Paper Moon Alvin Sargent Serpico Waldo Salt Norman Wexler Frank Film Frank Mouris The Legend of John Henry David Adams Nick Bosustow Pulcinella Giulio Gianini Emanuele Luzzati The Bolero William Fertik Allan Miller Clockmaker Richard Gayer Life Times Nine Pen Densham John Watson The Exorcist Robert Knudson Chris Newman The Day of the Dolphin Lawrence O. Jost Richard Portman The Paper Chase Lawrence O. Jost Donald O. Mitchell Paper Moon Les Fresholtz Richard Portman The Sting Robert Bertrand Ronald K. Pierce The Sting David S. Ward American Graffiti Willard Huyck Gloria Katz George Lucas Cries and Whispers Ingmar Bergman Save the Tiger Steve Shagan A Touch of Class Melvin Frank Jack Rose Harry and Tonto Art Carney Murder on the Orient Express Albert Finney Lenny Dustin Hoffman Chinatown Jack Nicholson The Godfather Part II Al Pacino The Godfather Part II Robert De Niro The Towering Inferno Fred Astaire Thunderbolt and Lightfoot Jeff Bridges The Godfather Part II Michael V. Gazzo The Godfather Part II Lee Strasberg Alice Doesn't Live Here Anymore Ellen Burstyn Claudine Diahann Carroll Chinatown Faye Dunaway Lenny Valerie Perrine A Woman Under the Influence Gena Rowlands Murder on the Orient Express Ingrid Bergman Day for Night Valentina Cortese Blazing Saddles Madeline Kahn Alice Doesn't Live Here Anymore Diane Ladd The Godfather Part II Talia Shire The Godfather Part II Angelo Graham Dean Tavoularis George R. Nelson Chinatown W. Stewart Campbell Richard Sylbert Ruby Levitt Earthquake E. Preston Ames Alexander Golitzen Frank McKelvy The Island at the Top of the World Peter Ellenshaw John B. Mansbridge Al Roelofs Walter Tyler Hal Gausman The Towering Inferno William Creber Ward Preston Raphael Bretton The Godfather Part II Francis Ford Coppola Gray Frederickson Fred Roos Chinatown Robert Evans The Conversation Francis Ford Coppola Fred Roos Lenny Marvin Worth The Towering Inferno Irwin Allen The Towering Inferno Joseph Biroc Fred Koenekamp Chinatown John A. Alonzo Earthquake Philip Lathrop Lenny Bruce Surtees Murder on the Orient Express Geoffrey Unsworth The Great Gatsby Theoni V. Aldredge Chinatown Anthea Sylbert Daisy Miller John Furness The Godfather Part II Theadora Van Runkle Murder on the Orient Express Tony Walton The Godfather Part II Francis Ford Coppola Chinatown Roman Polanski Day for Night Francois Truffaut Lenny Bob Fosse A Woman Under the Influence John Cassavetes Hearts and Minds Peter Davis Bert Schneider The 81st Blow David Bergman Jacquot Ehrlich Haim Gouri Antonia: A Portrait of the Woman Judy Collins Jill Godmilow The Challenge...a Tribute to Modern Art Herbert Kline The Wild and the Brave Eugene S. Jones Natalie R. Jones Don't Robin Lehman City Out of Wilderness Francis Thompson Exploratorium Jon Boorstin John Muir's High Sierra Lesley Foster Dewitt Jones Naked Yoga Ronald S. Kass Mervyn Lloyd The Towering Inferno Carl Kress Harold F. Kress Blazing Saddles Danford Greene John C. Howard Chinatown Sam O'Steen Earthquake Dorothy Spencer The Longest Yard Michael Luciano Amarcord Italy Cats' Play Hungary The Deluge Poland Lacombe, Lucien France The Truce Argentina The Godfather Part II Carmine Coppola Nino Rota Chinatown Jerry Goldsmith Murder on the Orient Express Richard Rodney Bennett Shanks Alex North The Towering Inferno John Williams The Great Gatsby Nelson Riddle The Little Prince Douglas Gamley Alan Jay Lerner Frederick Loewe Angela Morley Phantom of the Paradise George Aliceson Tipton Paul Williams We May Never Love Like This Again The Towering Inferno Joel Hirschhorn Al Kasha Benji's Theme (I Feel Love) Benji Betty Box Euel Box Blazing Saddles Blazing Saddles Mel Brooks John Morris Little Prince The Little Prince Alan Jay Lerner Frederick Loewe Wherever Love Takes Me Gold Elmer Bernstein Don Black The Godfather Part II Francis Ford Coppola Mario Puzo The Apprenticeship of Duddy Kravitz Lionel Chetwynd Mordecai Richler Lenny Julian Barry Murder on the Orient Express Paul Dehn Young Frankenstein Mel Brooks Gene Wilder Chinatown Robert Towne Alice Doesn't Live Here Anymore Robert Getchell The Conversation Francis Ford Coppola Day for Night Jean-Louis Richard Suzanne Schiffman Francois Truffaut Harry and Tonto Josh Greenfeld Paul Mazursky Closed Mondays Bob Gardiner Will Vinton The Family That Dwelt Apart Yvon Mallette Robert Verrall Hunger Peter Foldes René Jodoin Voyage to Next Faith Hubley John Hubley Winnie the Pooh and Tigger Too Wolfgang Reitherman One-Eyed Men are Kings Paul Claudon Edmond Sechan Climb Dewitt Jones The Concert Claude Chagrin Julian Chagrin Planet Ocean George V. Casey The Violin George Pastic Andrew Welsh Earthquake Melvin Metcalfe Sr. Ronald Pierce Chinatown Bud Grenzbach Larry Jost The Conversation Walter Murch Arthur Rochester The Towering Inferno Herman Lewis Theodore Soderberg Young Frankenstein Gene Cantamessa Richard Portman One Flew Over the Cuckoo's Nest Jack Nicholson The Sunshine Boys Walter Matthau Dog Day Afternoon Al Pacino The Man in the Glass Booth Maximilian Schell Give 'Em Hell, Harry! James Whitmore The Sunshine Boys George Burns One Flew Over the Cuckoo's Nest Brad Dourif The Day of the Locust Burgess Meredith Dog Day Afternoon Chris Sarandon Shampoo Jack Warden One Flew Over the Cuckoo's Nest Louise Fletcher The Story of Adele H. Isabelle Adjani Tommy Ann-Margret Hedda Glenda Jackson Hester Street Carol Kane Shampoo Lee Grant Nashville Ronee Blakley Farewell, My Lovely Sylvia Miles Nashville Lily Tomlin Jacqueline Susann's Once Is Not Enough Brenda Vaccaro Barry Lyndon Ken Adam Roy Walker Vernon Dixon The Hindenburg Edward Carfagno Frank McKelvy The Man Who Would Be King Tony Inglis Alexander Trauner Peter James Shampoo W. Stewart Campbell Richard Sylbert George Gaines The Sunshine Boys Albert Brenner Marvin March One Flew Over the Cuckoo's Nest Michael Douglas Saul Zaentz Barry Lyndon Stanley Kubrick Dog Day Afternoon Martin Bregman Martin Elfand Jaws David Brown Richard D. Zanuck Nashville Robert Altman Barry Lyndon John Alcott The Day of the Locust Conrad Hall Funny Lady James Wong Howe The Hindenburg Robert Surtees One Flew Over the Cuckoo's Nest Bill Butler Haskell Wexler Barry Lyndon Milena Canonero Ulla-Britt Soderlund The Four Musketeers Yvonne Blake Ron Talsky Funny Lady Ray Aghayan Bob Mackie The Magic Flute Karin Erskine Henny Noremark The Man Who Would Be King Edith Head One Flew Over the Cuckoo's Nest Milos Forman Amarcord Federico Fellini Barry Lyndon Stanley Kubrick Dog Day Afternoon Sidney Lumet Nashville Robert Altman The Man Who Skied Down Everest F. R. Crawley James Hager Dale Hartleben The California Reich Keith F. Critchlow Walter F. Parkes Fighting for Our Lives Glen Pearcy The Incredible Machine Irwin Rosten The Other Half of the Sky: A China Memoir Shirley MacLaine The End of the Game Robin Lehman Claire Wilbur Arthur and Lillie Jon Else Steven Kovacs Kristine Samuelson Millions of Years Ahead of Man Manfred Baier Probes in Space George V. Casey Whistling Smith Barrie Howells Michael Scott Jaws Verna Fields Dog Day Afternoon Dede Allen The Man Who Would Be King Russell Lloyd One Flew Over the Cuckoo's Nest Richard Chew Sheldon Kahn Lynzee Klingman Three Days of the Condor Don Guidice Fredric Steinkamp Dersu Uzala Union of Soviet Socialist Republics Land of Promise Poland Letters from Marusia Mexico Sandakan No. 8 Japan Scent of a Woman Italy Jaws John Williams Birds Do It, Bees Do It Gerald Fried Bite the Bullet Alex North One Flew Over the Cuckoo's Nest Jack Nitzsche The Wind and the Lion Jerry Goldsmith Barry Lyndon Leonard Rosenman Funny Lady Peter Matz Tommy Peter Townshend I'm Easy Nashville Keith Carradine How Lucky Can You Get Funny Lady Fred Ebb John Kander Now That We're in Love Whiffs George Barrie Sammy Cahn Richard's Window The Other Side of the Mountain Charles Fox Norman Gimbel Theme from Mahogany (Do You Know Where You're Going to) Mahogany Gerry Goffin Michael Masser One Flew Over the Cuckoo's Nest Bo Goldman Lawrence Hauben Barry Lyndon Stanley Kubrick The Man Who Would Be King Gladys Hill John Huston Scent of a Woman Ruggero Maccari Dino Risi The Sunshine Boys Neil Simon Dog Day Afternoon Frank Pierson Amarcord Federico Fellini Tonino Guerra And Now My Love Claude Lelouch Pierre Uytterhoeven Lies My Father Told Me Ted Allan Shampoo Warren Beatty Robert Towne Great Bob Godfrey Kick Me Robert Swarthe Monsieur Pointu René Jodoin André Leduc Bernard Longpré Sisyphus Marcell Jankovics Angel and Big Joe Bert Salzman Conquest of Light Louis Marcus Dawn Flight Brian Lansburgh Lawrence M. Lansburgh A Day in the Life of Bonnie Consolo Barry Spinello Doubletalk Alan Beattie Jaws John Carter {father} Roger Heman Robert L. Hoyt Earl Madery Bite the Bullet Les Fresholtz Al Overton Jr. Arthur Piantadosi Richard Tyler Funny Lady Don MacDougall Richard Portman Jack Solomon Curly Thirlwell The Hindenburg John A. Bolger Jr. John Mack Leonard Peterson Don K. Sharpless The Wind and the Lion Roy Charman William McCaughey Aaron Rochin Harry W. Tetrick Network Peter Finch Taxi Driver Robert De Niro Seven Beauties Giancarlo Giannini Network William Holden Rocky Sylvester Stallone All the President's Men Jason Robards Network Ned Beatty Rocky Burgess Meredith Marathon Man Laurence Olivier Rocky Burt Young Network Faye Dunaway Cousin, Cousine Marie-Christine Barrault Rocky Talia Shire Carrie Sissy Spacek Face to Face Liv Ullmann Network Beatrice Straight All the President's Men Jane Alexander Taxi Driver Jodie Foster Voyage of the Damned Lee Grant Carrie Piper Laurie All the President's Men George Jenkins George Gaines The Incredible Sarah Norman Reynolds Elliot Scott Peter Howitt The Last Tycoon Gene Callahan Jack Collis Jerry Wunderlich Logan's Run Dale Hennesy Robert de Vestel The Shootist Robert F. Boyle Arthur Jeph Parker Rocky Robert Chartoff Irwin Winkler All the President's Men Walter Coblenz Bound for Glory Robert F. Blumofe Harold Leventhal Network Howard Gottfried Taxi Driver Julia Phillips Michael Phillips Bound for Glory Haskell Wexler King Kong Richard H. Kline Logan's Run Ernest Laszlo Network Owen Roizman A Star Is Born Robert Surtees Fellini's Casanova Danilo Donati Bound for Glory William Theiss The Incredible Sarah Anthony Mendleson The Passover Plot Mary Wills The Seven-Per-Cent Solution Alan Barrett Rocky John G. Avildsen All the President's Men Alan J. Pakula Face to Face Ingmar Bergman Network Sidney Lumet Seven Beauties Lina Wertmüller Harlan County, U.S.a. Barbara Kopple Hollywood on Trial James Gutman David Helpern Jr. Off the Edge Michael Firth People of the Wind Anthony Howarth David Koff Volcano: An Inquiry Into the Life and Death of Malcolm Lowry Donald Brittain Robert Duncan Number Our Days Lynne Littman American Shoeshine Sparky Greene Blackwood Tony Ianzelo Andy Thompson The End of the Road John Armstrong Universe Lester Novros Rocky Scott Conrad Richard Halsey All the President's Men Robert L. Wolfe Bound for Glory Pembroke J. Herring Robert Jones Network Alan Heim Two-Minute Warning Walter Hannemann Eve Newman Black and White in Color Ivory Coast Cousin, Cousine France Jacob, the Liar German Democratic Republic Nights and Days Poland Seven Beauties Italy The Omen Jerry Goldsmith Obsession Bernard Herrmann The Outlaw Josey Wales Jerry Fielding Taxi Driver Bernard Herrmann Voyage of the Damned Lalo Schifrin Bound for Glory Leonard Rosenman Bugsy Malone Paul Williams A Star Is Born Roger Kellaway Evergreen (Love Theme from a Star Is Born) A Star Is Born Barbra Streisand Paul Williams A World That Never Was Half a House Sammy Fain Paul Francis Webster Ave Satani The Omen Jerry Goldsmith Come to Me The Pink Panther Strikes Again Don Black Henry Mancini Gonna Fly Now Rocky Carol Connors Bill Conti Ayn Robbins All the President's Men William Goldman Bound for Glory Robert Getchell Fellini's Casanova Federico Fellini Bernadino Zapponi The Seven-Per-Cent Solution Nicholas Meyer Voyage of the Damned David Butler Steve Shagan Network Paddy Chayefsky Cousin, Cousine Jean-Charles Tacchella Daniele Thompson The Front Walter Bernstein Rocky Sylvester Stallone Seven Beauties Lina Wertmüller Leisure Suzanne Baker Dedalo Manfredo Manfredi The Street Guy Glover Caroline Leaf In the Region of Ice Andre Guttfreund Peter Werner Kudzu Marjorie Anne Short The Morning Spider Claude Chagrin Julian Chagrin Nightlife Robin Lehman Claire Wilbur Number One Dyan Cannon Vince Cannon All the President's Men Dick Alexander Les Fresholtz Arthur Piantadosi Jim Webb King Kong William McCaughey Aaron Rochin Jack Solomon Harry Warren Tetrick Rocky Bud Alper Lyle Burbridge William McCaughey Harry Warren Tetrick Silver Streak Hal Etherington Donald Mitchell Richard Tyler Douglas Williams A Star Is Born Robert Glass Robert Knudson Tom Overton Dan Wallin The Goodbye Girl Richard Dreyfuss Annie Hall Woody Allen Equus Richard Burton A Special Day Marcello Mastroianni Saturday Night Fever John Travolta Julia Jason Robards The Turning Point Mikhail Baryshnikov Equus Peter Firth Star Wars Alec Guinness Julia Maximilian Schell Annie Hall Diane Keaton The Turning Point Anne Bancroft Julia Jane Fonda The Turning Point Shirley MacLaine The Goodbye Girl Marsha Mason Julia Vanessa Redgrave The Turning Point Leslie Browne The Goodbye Girl Quinn Cummings Close Encounters of the Third Kind Melinda Dillon Looking for Mr. Goodbar Tuesday Weld Star Wars John Barry Leslie Dilley Norman Reynolds Roger Christian Airport `77 George C. Webb Mickey S. Michaels Close Encounters of the Third Kind Joe Alves Dan Lomino Phil Abramson The Spy Who Loved Me Ken Adam Peter Lamont Hugh Scaife The Turning Point Albert Brenner Marvin March Annie Hall Charles H. Joffe The Goodbye Girl Ray Stark Julia Richard Roth Star Wars Gary Kurtz The Turning Point Arthur Laurents Herbert Ross Close Encounters of the Third Kind Vilmos Zsigmond Islands in the Stream Fred J. Koenekamp Julia Douglas Slocombe Looking for Mr. Goodbar William A. Fraker The Turning Point Robert Surtees Star Wars John Mollo Airport `77 Edith Head Burton Miller Julia Anthea Sylbert A Little Night Music Florence Klotz The Other Side of Midnight Irene Sharaff Annie Hall Woody Allen Close Encounters of the Third Kind Steven Spielberg Julia Fred Zinnemann Star Wars George Lucas The Turning Point Herbert Ross Who are the Debolts? and Where Did They Get Nineteen Kids? John Korty Warren L. Lockhart Dan McCann The Children of Theatre Street Robert Dornhelm Earle Mack High Grass Circus Bill Brind Tony Ianzelo Torben Schioler Homage to Chagall - the Colours of Love Harry Rasky Union Maids James Klein Miles Mogulescu Julia Reichert Gravity Is My Enemy John Joseph Jan Stussy Agueda Martinez: Our People, Our Country Moctesuma Esparza First Edition DeWitt L. Sage Jr. Helen Whitney Of Time, Tombs and Treasure James R. Messenger Paul N. Raimondi The Shetland Experience Douglas Gordon Star Wars Richard Chew Paul Hirsch Marcia Lucas Close Encounters of the Third Kind Michael Kahn Julia Walter Murch Smokey and the Bandit Walter Hannemann Angelo Ross The Turning Point William Reynolds Madame Rosa France Iphigenia Greece Operation Thunderbolt Israel A Special Day Italy That Obscure Object of Desire Spain Star Wars John Williams Close Encounters of the Third Kind John Williams Julia Georges Delerue Mohammad - Messenger of God Maurice Jarre The Spy Who Loved Me Marvin Hamlisch A Little Night Music Jonathan Tunick Pete's Dragon Joel Hirschhorn Al Kasha Irwin Kostal The Slipper and the Rose - the Story of Cinderella Angela Morley Richard M. Sherman Robert B. Sherman You Light Up My Life You Light Up My Life Joseph Brooks Candle on the Water Pete's Dragon Joel Hirschhorn Al Kasha Nobody Does It Better The Spy Who Loved Me Marvin Hamlisch Carole Bayer Sager Someone's Waiting for You The Rescuers Carol Connors Sammy Fain Ayn Robbins The Slipper and the Rose Waltz (He Danced with Me/She Danced with Me The Slipper and the Rose - The Story of Cinderella Richard M. Sherman Robert B. Sherman Julia Alvin Sargent Equus Peter Shaffer I Never Promised You a Rose Garden Lewis John Carlino Gavin Lambert Oh, God! Larry Gelbart That Obscure Object of Desire Luis Buñuel Jean-Claude Carrière Annie Hall Woody Allen Marshall Brickman The Goodbye Girl Neil Simon The Late Show Robert Benton Star Wars George Lucas The Turning Point Arthur Laurents The Sand Castle Co Hoedeman The Bead Game Ishu Patel The Doonesbury Special Faith Hubley John Hubley Garry Trudeau Jimmy the C Robert Grossman James Picker Craig Whitaker I'll Find a Way Beverly Shaffer Yuki Yoshida The Absent-Minded Waiter William E. McEuen Floating Free Jerry Butts Notes on the Popular Arts Saul Bass Spaceborne Philip Dauber Star Wars Derek Ball Don MacDougall Bob Minkler Ray West Close Encounters of the Third Kind Gene S. Cantamessa Robert J. Glass Robert Knudson Don MacDougall The Deep Dick Alexander Tom Beckert Walter Goss Robin Gregory Sorcerer Jean-Louis Ducarme Robert J. Glass Robert Knudson Richard Tyler The Turning Point Jerry Jost Theodore Soderberg Paul Wells Douglas O. Williams Star Wars Robert Blalack John Dykstra Richard Edlund Grant McCune John Stears Close Encounters of the Third Kind Roy Arbogast Gregory Jein Douglas Trumbull Matthew Yuricich Richard Yuricich Coming Home Jon Voight Heaven Can Wait Warren Beatty The Buddy Holly Story Gary Busey The Deer Hunter Robert De Niro The Boys from Brazil Laurence Olivier The Deer Hunter Christopher Walken Coming Home Bruce Dern Comes a Horseman Richard Farnsworth Midnight Express John Hurt Heaven Can Wait Jack Warden Coming Home Jane Fonda Autumn Sonata Ingrid Bergman Same Time, Next Year Ellen Burstyn An Unmarried Woman Jill Clayburgh Interiors Geraldine Page California Suite Maggie Smith Heaven Can Wait Dyan Cannon Coming Home Penelope Milford Interiors Maureen Stapleton The Deer Hunter Meryl Streep Heaven Can Wait Edwin O'Donovan Paul Sylbert George Gaines The Brink's Job Angelo Graham Dean Tavoularis Bruce Kay George R. Nelson California Suite Albert Brenner Marvin March Interiors Mel Bourne Daniel Robert The Wiz Philip Rosenberg Tony Walton Robert Drumheller Edward Stewart The Deer Hunter Michael Cimino Michael Deeley John Peverall Barry Spikings Coming Home Jerome Hellman Heaven Can Wait Warren Beatty Midnight Express Alan Marshall David Puttnam An Unmarried Woman Paul Mazursky Tony Ray Days of Heaven Nestor Almendros The Deer Hunter Vilmos Zsigmond Heaven Can Wait William A. Fraker Same Time, Next Year Robert Surtees The Wiz Oswald Morris Death on the Nile Anthony Powell Caravans Renie Conley Days of Heaven Patricia Norris The Swarm Paul Zastupnevich The Wiz Tony Walton The Deer Hunter Michael Cimino Coming Home Hal Ashby Heaven Can Wait Warren Beatty Buck Henry Interiors Woody Allen Midnight Express Alan Parker Scared Straight! Arnold Shapiro The Lovers' Wind Albert Lamorisse Mysterious Castles of Clay Alan Root Raoni Jean-Pierre Dutilleux Michel Gast Barry Williams With Babies and Banners: Story of the Women's Emergency Brigade Anne Bohlen Lyn Goldfarb Lorraine Gray The Flight of the Gossamer Condor Ben Shedd Jacqueline Phillips Shedd The Divided Trail: A Native American Odyssey Jerry Aronson An Encounter with Faces K.K. Kapil Goodnight Miss Ann August Cinquegrana Squires of San Quentin J. Gary Mitchell The Deer Hunter Peter Zinner The Boys from Brazil Robert E. Swink Coming Home Don Zimmerman Midnight Express Gerry Hambling Superman Stuart Baird Get Out Your Handkerchiefs France The Glass Cell German Federal Republic Hungarians Hungary Viva Italia! Italy White Bim Black Ear Union of Soviet Socialist Republics Midnight Express Giorgio Moroder The Boys from Brazil Jerry Goldsmith Days of Heaven Ennio Morricone Heaven Can Wait Dave Grusin Superman John Williams The Buddy Holly Story Joe Renzetti Pretty Baby Jerry Wexler The Wiz Quincy Jones Last Dance Thank God It's Friday Paul Jabara Hopelessly Devoted to You Grease John Farrar Ready to Take a Chance Again Foul Play Charles Fox Norman Gimbel The Last Time I Felt Like This Same Time, Next Year Alan Bergman Marilyn Bergman Marvin Hamlisch When You're Loved The Magic of Lassie Richard M. Sherman Robert B. Sherman Midnight Express Oliver Stone Bloodbrothers Walter Newman California Suite Neil Simon Heaven Can Wait Warren Beatty Elaine May Same Time, Next Year Bernard Slade Coming Home Nancy Dowd Robert C. Jones Waldo Salt Autumn Sonata Ingmar Bergman The Deer Hunter Michael Cimino Louis Garfinkle Quinn K. Redeker Deric Washburn Interiors Woody Allen An Unmarried Woman Paul Mazursky Special Delivery Eunice Macaulay John Weldon Oh My Darling Nico Crama Rip Van Winkle Will Vinton Teenage Father Taylor Hackford A Different Approach Jim Belcher Fern Field Mandy's Grandmother Andrew Sugerman Strange Fruit Seth Pinsker The Deer Hunter Darin Knight William McCaughey Richard Portman Aaron Rochin The Buddy Holly Story Willie Burton Joel Fein Tex Rudloff Curly Thirlwell Days of Heaven Robert W. Glass Jr. John T. Reitz Barry Thomas John K. Wilkinson Hooper Robert J. Glass Robert Knudson Don MacDougall Jack Solomon Superman Roy Charman Graham Hartstone Nicolas Le Messurier Gordon K. McCallum Kramer vs. Kramer Dustin Hoffman The China Syndrome Jack Lemmon ...And Justice for All Al Pacino All That Jazz Roy Scheider Being There Peter Sellers Being There Melvyn Douglas Apocalypse Now Robert Duvall The Rose Frederic Forrest Kramer vs. Kramer Justin Henry The Black Stallion Mickey Rooney Norma Rae Sally Field Starting Over Jill Clayburgh The China Syndrome Jane Fonda Chapter Two Marsha Mason The Rose Bette Midler Kramer vs. Kramer Meryl Streep Kramer vs. Kramer Jane Alexander Breaking Away Barbara Barrie Starting Over Candice Bergen Manhattan Mariel Hemingway All That Jazz Philip Rosenberg Tony Walton Gary Brink Edward Stewart Alien Roger Christian Les Dilley Michael Seymour Ian Whittaker Apocalypse Now Angelo Graham Dean Tavoularis George R. Nelson The China Syndrome George Jenkins Arthur Jeph Parker Star Trek - The Motion Picture Leon Harris Joe Jennings Harold Michelson John Vallone Linda DeScenna Kramer vs. Kramer Stanley R. Jaffe All That Jazz Robert Alan Aurthur Apocalypse Now Francis Coppola Gray Frederickson Fred Roos Tom Sternberg Breaking Away Peter Yates Norma Rae Tamara Asseyev Alex Rose Apocalypse Now Vittorio Storaro 1941 William A. Fraker All That Jazz Giuseppe Rotunno The Black Hole Frank Phillips Kramer vs. Kramer Nestor Almendros All That Jazz Albert Wolsky Agatha Shirley Russell Butch and Sundance: The Early Days William Ware Theiss The Europeans Judy Moorcroft La Cage Aux Folles Ambra Danon Piero Tosi Kramer vs. Kramer Robert Benton All That Jazz Bob Fosse Apocalypse Now Francis Coppola Breaking Away Peter Yates La Cage Aux Folles Edouard Molinaro Best Boy Ira Wohl Generation on the Wind David A. Vassar Going the Distance Jacques Bobet Paul Cowan The Killing Ground Tom Priestley Steve Singer The War at Home Barry Alexander Brown Glenn Silber Paul Robeson: Tribute to an Artist Saul J. Turell Dae Risto Teofilovski Koryo Celadon Donald A. Connolly James R. Messenger Nails Phillip Borsos Remember Me Dick Young All That Jazz Alan Heim Apocalypse Now Lisa Fruchtman Gerald B. Greenberg Richard Marks Walter Murch The Black Stallion Robert Dalva Kramer vs. Kramer Jerry Greenberg The Rose C. Timothy O'Meara Robert L. Wolfe The Tin Drum Federal Republic of Germany The Maids of Wilko Poland Mama Turns a Hundred Spain A Simple Story France To Forget Venice Italy A Little Romance Georges Delerue 10 Henry Mancini The Amityville Horror Lalo Schifrin The Champ Dave Grusin Star Trek THE MOTION PICTURE All That Jazz Ralph Burns Breaking Away Patrick Williams The Muppet Movie Kenny Ascher Paul Williams It Goes Like It Goes Norma Rae Norman Gimbel David Shire I'll Never Say `Goodbye' The Promise Alan Bergman Marilyn Bergman David Shire It's Easy to Say 10 Henry Mancini Robert Wells The Rainbow Connection The Muppet Movie Kenny Ascher Paul Williams Through the Eyes of Love Ice Castles Marvin Hamlisch Carole Bayer Sager Kramer vs. Kramer Robert Benton Apocalypse Now Francis Coppola John Milius La Cage Aux Folles Marcello Danon Edouard Molinaro Jean Poiret Francis Veber A Little Romance Allan Burns Norma Rae Harriet Frank Jr. Irving Ravetch Breaking Away Steve Tesich ...And Justice for All Valerie Curtin Barry Levinson All That Jazz Robert Alan Aurthur Bob Fosse The China Syndrome James Bridges T.S. Cook Mike Gray Manhattan Woody Allen Marshall Brickman Every Child Derek Lamb Dream Doll Bob Godfrey Zlatko Grgic It's So Nice to Have a Wolf Around the House Paul Fierlinger Board and Care Ron Ellis Sarah Pillsbury Bravery in the Field Roman Kroitor Stefan Wodoslawsky Oh Brother, My Brother Carol Lowell Ross Lowell The Solar Film Saul Bass Michael Britton Solly's Diner Larry Hankin Harry Mathias Jay Zukerman Apocalypse Now Richard Beggs Mark Berger Nat Boxer Walter Murch 1941 Gene S. Cantamessa Robert J. Glass Robert Knudson Don MacDougall The Electric Horseman Les Fresholtz Michael Minkler Al Overton Arthur Piantadosi Meteor Michael J. Kohut William McCaughey Aaron Rochin Jack Solomon The Rose Theodore Soderberg Jim Webb Paul Wells Douglas Williams Alien Nick Allder Denys Ayling H.R. Giger Brian Johnson Carlo Rambaldi 1941 A. D. Flowers William A. Fraker Gregory Jein The Black Hole Art Cruickshank Harrison Ellenshaw Peter Ellenshaw Joe Hale Danny Lee Eustace Lycett Moonraker John Evans Derek Meddings Paul Wilson Star Trek - The Motion Picture John Dykstra Grant McCune Dave Stewart Robert Swarthe Douglas Trumbull Richard Yuricich Raging Bull Robert De Niro The Great Santini Robert Duvall The Elephant Man John Hurt Tribute Jack Lemmon The Stunt Man Peter O'Toole Ordinary People Timothy Hutton Ordinary People Judd Hirsch The Great Santini Michael O'Keefe Raging Bull Joe Pesci Melvin and Howard Jason Robards Coal Miner's Daughter Sissy Spacek Resurrection Ellen Burstyn Private Benjamin Goldie Hawn Ordinary People Mary Tyler Moore Gloria Gena Rowlands Melvin and Howard Mary Steenburgen Private Benjamin Eileen Brennan Resurrection Eva Le Gallienne Raging Bull Cathy Moriarty Inside Moves Diana Scarwid Tess Pierre Guffroy Jack Stephens Coal Miner's Daughter John W. Corso John M. Dwyer The Elephant Man Bob Cartwright Stuart Craig Hugh Scaife The Empire Strikes Back Leslie Dilley Harry Lange Norman Reynolds Alan Tomkins Michael Ford Kagemusha (The Shadow Warrior) Yoshiro Muraki Ordinary People Ronald L. Schwary Coal Miner's Daughter Bernard Schwartz The Elephant Man Jonathan Sanger Raging Bull Robert Chartoff Irwin Winkler Tess Claude Berri Timothy Burrill Tess Ghislain Cloquet Geoffrey Unsworth The Blue Lagoon Nestor Almendros Coal Miner's Daughter Ralf D. Bode The Formula James Crabe Raging Bull Michael Chapman Tess Anthony Powell The Elephant Man Patricia Norris My Brilliant Career Anna Senior Somewhere in Time Jean-Pierre Dorleac When Time Ran Out Paul Zastupnevich Ordinary People Robert Redford The Elephant Man David Lynch Raging Bull Martin Scorsese The Stunt Man Richard Rush Tess Roman Polanski From Mao to Mozart: Isaac Stern in China Murray Lerner Agee Ross Spears The Day After Trinity Jon Else Front Line David Bradbury The Yellow Star - The Persecution of the Jews in Europe 1933-45 Arthur Cohn Bengt von zur Muehlen Karl Hess: Toward Liberty Roland Hallé Peter W. Ladue Don't Mess with Bill Pen Densham John Watson The Eruption of Mount St. Helens George Casey It's the Same World Dick Young Luther Metke at 94 Richard Hawkins Jorge Preloran Raging Bull Thelma Schoonmaker Coal Miner's Daughter Arthur Schmidt The Competition David Blewitt The Elephant Man Anne V. Coates Fame Gerry Hambling Moscow Does Not Believe in Tears Union of Soviet Socialist Republics Confidence Hungary Kagemusha (The Shadow Warrior) Japan The Last Metro France The Nest Spain Fame Michael Gore Altered States John Corigliano The Elephant Man John Morris The Empire Strikes Back John Williams Tess Philippe Sarde Fame Fame Michael Gore Dean Pitchford Nine to Five Nine to Five Dolly Parton On the Road Again Honeysuckle Rose Willie Nelson Out Here on My Own Fame Lesley Gore Michael Gore People Alone The Competition Wilbur Jennings Lalo Schifrin Ordinary People Alvin Sargent Breaker Morant Bruce Beresford Jonathan Hardy David Stevens Coal Miner's Daughter Tom Rickman The Elephant Man Eric Bergren Christopher DeVore David Lynch The Stunt Man Lawrence B. Marcus Richard Rush Melvin and Howard Bo Goldman Brubaker W. D. Richter Arthur Ross Fame Christopher Gore Mon Oncle D'amerique Jean Gruault Private Benjamin Nancy Meyers Harvey Miller Charles Shyer The Fly Ferenc Rofusz All Nothing Frédéric Back History of the World in Three Minutes Flat Michael Mills The Dollar Bottom Lloyd Phillips Fall Line Bob Carmichael Greg Lowe A Jury of Her Peers Sally Heckel The Empire Strikes Back Gregg Landaker Steve Maslow Peter Sutton Bill Varney Altered States Willie D. Burton Les Fresholtz Michael Minkler Arthur Piantadosi Coal Miner's Daughter Jim Alexander Roger Heman Richard Portman Fame Jay M. Harding Michael J. Kohut Chris Newman Aaron Rochin Raging Bull David J. Kimball Les Lazarowitz Donald O. Mitchell Bill Nicholson On Golden Pond Henry Fonda Reds Warren Beatty Atlantic City Burt Lancaster Arthur Dudley Moore Absence of Malice Paul Newman Arthur John Gielgud Only When I Laugh James Coco Chariots of Fire Ian Holm Reds Jack Nicholson Ragtime Howard E. Rollins Jr. On Golden Pond Katharine Hepburn Reds Diane Keaton Only When I Laugh Marsha Mason Atlantic City Susan Sarandon The French Lieutenant's Woman Meryl Streep Reds Maureen Stapleton Absence of Malice Melinda Dillon On Golden Pond Jane Fonda Only When I Laugh Joan Hackett Ragtime Elizabeth McGovern Raiders of the Lost Ark Leslie Dilley Norman Reynolds Michael Ford The French Lieutenant's Woman Assheton Gorton Ann Mollo Heaven's Gate Tambi Larsen Jim Berkey Ragtime John Graysmark Anthony Reading Patrizia Von Brandenstein George de Titta Jr. George de Titta Sr. Peter Howitt Reds Richard Sylbert Michael Seirton Chariots of Fire David Puttnam Atlantic City Denis Heroux John Kemeny On Golden Pond Bruce Gilbert Raiders of the Lost Ark Frank Marshall Reds Warren Beatty Reds Vittorio Storaro Excalibur Alex Thomson On Golden Pond Billy Williams Ragtime Miroslav Ondricek Raiders of the Lost Ark Douglas Slocombe Chariots of Fire Milena Canonero The French Lieutenant's Woman Tom Rand Pennies from Heaven Bob Mackie Ragtime Anna Hill Johnstone Reds Shirley Russell Reds Warren Beatty Atlantic City Louis Malle Chariots of Fire Hugh Hudson On Golden Pond Mark Rydell Raiders of the Lost Ark Steven Spielberg Genocide Rabbi Marvin Hier Arnold Schwartzman Against Wind and Tide: A Cuban Odyssey Suzanne Bauman Jim Burroughs Paul Neshamkin Brooklyn Bridge Ken Burns Eight Minutes to Midnight: A Portrait of Dr. Helen Caldicott Mary Benjamin Boyd Estus Susanne Simpson El Salvador: Another Vietnam Glenn Silber Tete Vasconcellos Close Harmony Nigel Noble Americas in Transition Obie Benz Journey for Survival Dick Young See What I Say Linda Chapman Pam LeBlanc Freddi Stevens Urge To Build Roland Hallé John Hoover Raiders of the Lost Ark Michael Kahn Chariots of Fire Terry Rawlings The French Lieutenant's Woman John Bloom On Golden Pond Robert L. Wolfe Reds Dede Allen Craig McKay Mephisto Hungary The Boat Is Full Switzerland Man of Iron Poland Muddy River Japan Three Brothers Italy An American Werewolf in London Rick Baker Heartbeeps Stan Winston Chariots of Fire Vangelis Dragonslayer Alex North On Golden Pond Dave Grusin Ragtime Randy Newman Raiders of the Lost Ark John Williams Arthur's Theme (Best That You Can Do) Arthur Peter Allen Burt Bacharach Christopher Cross Carole Bayer Sager Endless Love Endless Love Lionel Richie For Your Eyes Only For Your Eyes Only Bill Conti Mick Leeson One More Hour Ragtime Randy Newman The First Time It Happens The Great Muppet Caper Joe Raposo On Golden Pond Ernest Thompson The French Lieutenant's Woman Harold Pinter Pennies from Heaven Dennis Potter Prince of the City Jay Presson Allen Sidney Lumet Ragtime Michael Weller Chariots of Fire Colin Welland Absence of Malice Kurt Luedtke Arthur Steve Gordon Atlantic City John Guare Reds Warren Beatty Trevor Griffiths Crac Frédéric Back The Creation Will Vinton The Tender Tale of Cinderella Penguin Janet Perlman Violet Paul Kemp Shelley Levinson Couples and Robbers Christine Oestreicher First Winter John N. Smith Raiders of the Lost Ark Roy Charman Gregg Landaker Steve Maslow Bill Varney On Golden Pond Richard Portman David Ronne Outland Robert W. Glass Jr. Robin Gregory Robert M. Thirlwell John K. Wilkinson Pennies from Heaven Jay M. Harding Michael J. Kohut Al Overton Richard Tyler Reds Tom Fleischman Simon Kaye Dick Vorisek Raiders of the Lost Ark Richard Edlund Joe Johnston Bruce Nicholson Kit West Dragonslayer Brian Johnson Dennis Muren Ken Ralston Phil Tippett Gandhi Ben Kingsley Tootsie Dustin Hoffman Missing Jack Lemmon The Verdict Paul Newman My Favorite Year Peter O'Toole An Officer and a Gentleman Louis Gossett Jr. The Best Little Whorehouse in Texas Charles Durning The World According to Garp John Lithgow The Verdict James Mason Victor/Victoria Robert Preston Sophie's Choice Meryl Streep Victor/Victoria Julie Andrews Frances Jessica Lange Missing Sissy Spacek An Officer and a Gentleman Debra Winger Tootsie Jessica Lange The World According to Garp Glenn Close Tootsie Teri Garr Frances Kim Stanley Victor/Victoria Lesley Ann Warren Gandhi Stuart Craig Bob Laing Michael Seirton Annie Dale Hennesy Marvin March Blade Runner Lawrence G. Paull David L. Snyder Linda DeScenna La Traviata Franco Zeffirelli Gianni Quaranta Victor/Victoria Tim Hutchinson Rodger Maus William Craig Smith Harry Cordwell Gandhi Richard Attenborough E.T. the Extra-Terrestrial Kathleen Kennedy Steven Spielberg Missing Edward Lewis Mildred Lewis Tootsie Sydney Pollack Dick Richards The Verdict David Brown Richard D. Zanuck Gandhi Ronnie Taylor Billy Williams Das Boot Jost Vacano E.T. the Extra-Terrestrial Allen Daviau Sophie's Choice Nestor Almendros Tootsie Owen Roizman Gandhi Bhanu Athaiya John Mollo La Traviata Piero Tosi Sophie's Choice Albert Wolsky Tron Elois Jenssen Rosanna Norton Victor/Victoria Patricia Norris Gandhi Richard Attenborough Das Boot Wolfgang Petersen E.T. the Extra-Terrestrial Steven Spielberg Tootsie Sydney Pollack The Verdict Sidney Lumet Just Another Missing Kid John Zaritsky After the Axe Sturla Gunnarsson Steve Lucas Ben's Mill Michel Chalufour John Karol In Our Water Meg Switzgable A Portrait of Giselle Joseph Wishy If You Love This Planet Edward Le Lorrain Terri Nash Gods of Metal Robert Richter The Klan: A Legacy of Hate in America Charles Guggenheim Werner Schumann To Live Or Let Die Freida Lee Mock Traveling Hopefully John G. Avildsen Gandhi John Bloom Das Boot Hannes Nikel E.T. the Extra-Terrestrial Carol Littleton An Officer and a Gentleman Peter Zinner Tootsie Fredric Steinkamp William Steinkamp Volver a Empezar ("to Begin Again") Spain Alsino and the Condor Nicaragua Coup De Torchon ("Clean Slate") France The Flight of the Eagle Sweden Private Life Union of Soviet Socialist Republics Quest for Fire Michèle Burke Sarah Monzani Gandhi Tom Smith E.T. the Extra-Terrestrial John Williams Gandhi George Fenton Ravi Shankar An Officer and a Gentleman Jack Nitzsche Poltergeist Jerry Goldsmith Sophie's Choice Marvin Hamlisch Victor/Victoria Leslie Bricusse Henry Mancini Annie Ralph Burns One from the Heart Tom Waits Up Where We Belong An Officer and a Gentleman Will Jennings Jack Nitzsche Buffy Sainte-Marie Eye of the Tiger Rocky Iii Jim Peterik Frankie Sullivan III How Do You Keep the Music Playing? Best Friends Alan Bergman Marilyn Bergman Michel Legrand If We Were in Love Yes, Giorgio Alan Bergman Marilyn Bergman John Williams It Might Be You Tootsie Alan Bergman Marilyn Bergman Dave Grusin Missing Costa-Gavras Donald Stewart Das Boot Wolfgang Petersen Sophie's Choice Alan J. Pakula The Verdict David Mamet Victor/Victoria Blake Edwards Gandhi John Briley Diner Barry Levinson E.T. the Extra-Terrestrial Melissa Mathison An Officer and a Gentleman Douglas Day Stewart Tootsie Larry Gelbart Don McGuire Murray Schisgal Tango Zbigniew Rybczynski The Great Cognito Will Vinton The Snowman John Coates A Shocking Accident Christine Oestreicher Ballet Robotique Bob Rogers The Silence Joseph Benson Michael Toshiyuki Uno Split Cherry Tree Jan Saunders Sredni Vashtar Andrew Birkin E.T. the Extra-Terrestrial Gene Cantamessa Don Digirolamo Robert Glass Robert Knudson Das Boot Milan Bor Mike Le-Mare Trevor Pyke Gandhi Jonathan Bates Gerry Humphreys Simon Kaye Robin O'Donoghue Tootsie Dick Alexander Les Fresholtz Les Lazarowitz Arthur Piantadosi Tron Jim La Rue Bob Minkler Lee Minkler Michael Minkler E.T. the Extra-Terrestrial Ben Burtt Charles L. Campbell Das Boot Mike Le-Mare Poltergeist Richard L. Anderson Stephen Hunter Flick E.T. the Extra-Terrestrial Dennis Muren Carlo Rambaldi Kenneth F. Smith Blade Runner David Dryer Douglas Trumbull Richard Yuricich Poltergeist Richard Edlund Bruce Nicholson Michael Wood Tender Mercies Robert Duvall Educating Rita Michael Caine Reuben, Reuben Tom Conti The Dresser Tom Courtenay The Dresser Albert Finney Terms of Endearment Jack Nicholson To Be Or Not To Be Charles Durning Terms of Endearment John Lithgow The Right Stuff Sam Shepard Cross Creek Rip Torn Terms of Endearment Shirley MacLaine Testament Jane Alexander Silkwood Meryl Streep Educating Rita Julie Walters Terms of Endearment Debra Winger The Year of Living Dangerously Linda Hunt Silkwood Cher The Big Chill Glenn Close Yentl Amy Irving Cross Creek Alfre Woodard Fanny & Alexander Anna Asp Return of the Jedi Fred Hole Norman Reynolds James Schoppe Michael Ford The Right Stuff W. Stewart Campbell Geoffrey Kirkland Richard J. Lawrence Peter Romero George R. Nelson Pat Pending Terms of Endearment Harold Michelson Polly Platt Anthony Mondello Tom Pedigo Yentl Leslie Tomkins Roy Walker Tessa Davies Terms of Endearment James L. Brooks The Big Chill Michael Shamberg The Dresser Peter Yates The Right Stuff Robert Chartoff Irwin Winkler Tender Mercies Philip S. Hobel Fanny & Alexander Sven Nykvist Flashdance Don Peterman The Right Stuff Caleb Deschanel Wargames William A. Fraker Zelig Gordon Willis Fanny & Alexander Marik Vos Cross Creek Joe I. Tompkins Heart Like a Wheel William Ware Theiss The Return of Martin Guerre Anne-Marie Marchand Zelig Santo Loquasto Terms of Endearment James L. Brooks The Dresser Peter Yates Fanny & Alexander Ingmar Bergman Silkwood Mike Nichols Tender Mercies Bruce Beresford He Makes Me Feel Like Dancin' Emile Ardolino Children of Darkness Ara Chekmayan Richard Kotuk First Contact Robin Anderson Bob Connolly The Profession of Arms Michael Bryans Tina Viljoen Seeing Red James Klein Julia Reichert Flamenco at 5:15 Cynthia Scott Adam Symansky In the Nuclear Shadow: What Can the Children Tell Us? Eric Thiermann Vivienne Verdon-Roe Sewing Woman Arthur Dong Spaces: The Architecture of Paul Rudolph Robert Eisenhardt You are Free (Ihr Zent Frei) Dea Brokman Ilene Landis The Right Stuff Glenn Farr Lisa Fruchtman Tom Rolf Stephen A. Rotter Douglas Stewart Blue Thunder Edward Abroms Frank Morriss Flashdance Walt Mulconery Bud Smith Silkwood Sam O'Steen Terms of Endearment Richard Marks Fanny & Alexander Sweden Carmen Spain Entre Nous France Job's Revolt Hungary Le Bal Algeria The Right Stuff Bill Conti Cross Creek Leonard Rosenman Return of the Jedi John Williams Terms of Endearment Michael Gore Under Fire Jerry Goldsmith Yentl Alan Bergman Marilyn Bergman Michel Legrand The Sting II Lalo Schifrin Trading Places Elmer Bernstein Flashdance...What a Feeling Flashdance Irene Cara Keith Forsey Giorgio Moroder Maniac Flashdance Dennis Matkosky Michael Sembello Over You Tender Mercies Bobby Hart Austin Roberts Papa, Can You Hear Me? Yentl Alan Bergman Marilyn Bergman Michel Legrand The Way He Makes Me Feel Yentl Alan Bergman Marilyn Bergman Michel Legrand Terms of Endearment James L. Brooks Betrayal Harold Pinter The Dresser Ronald Harwood Educating Rita Willy Russell Reuben, Reuben Julius J. Epstein Tender Mercies Horton Foote The Big Chill Barbara Benedek Lawrence Kasdan Fanny & Alexander Ingmar Bergman Silkwood Alice Arlen Nora Ephron Wargames Lawrence Lasker Walter F. Parkes Sundae in New York Jimmy Picker Mickey's Christmas Carol Burny Mattinson Sound of Sunshine - Sound of Rain Eda Godel Hallinan Boys and Girls Janice L. Platt Goodie-Two-Shoes Ian Emes Overnight Sensation Jon N. Bloom The Right Stuff Mark Berger David MacMillan Tom Scott Randy Thom Never Cry Wolf Todd Boekelheide David Parker Alan R. Splet Randy Thom Return of the Jedi Ben Burtt Tony Dawe Gary Summers Randy Thom Terms of Endearment Jim Alexander Rick Kline Donald O. Mitchell Kevin O'Connell Wargames Willie D. Burton Carlos de Larios Michael J. Kohut Aaron Rochin The Right Stuff Jay Boekelheide Return of the Jedi Ben Burtt Amadeus F. Murray Abraham Starman Jeff Bridges Under the Volcano Albert Finney Amadeus Tom Hulce The Killing Fields Sam Waterston The Killing Fields Haing S. Ngor A Soldier's Story Adolph Caesar Places in the Heart John Malkovich The Karate Kid Noriyuki "Pat" Morita Greystoke: The Legend of Tarzan, Lord of the Apes Ralph Richardson Places in the Heart Sally Field A Passage to India Judy Davis Country Jessica Lange The Bostonians Vanessa Redgrave The River Sissy Spacek A Passage to India Peggy Ashcroft The Natural Glenn Close Places in the Heart Lindsay Crouse Swing Shift Christine Lahti The Pope of Greenwich Village Geraldine Page Amadeus Patrizia Von Brandenstein Karel Cerny 2010 Albert Brenner Rick Simpson The Cotton Club Richard Sylbert Les Bloom George Gaines The Natural Mel Bourne Angelo Graham Speed Hopkins James J. Murakami Bruce Weintraub A Passage to India John Box Leslie Tomkins Hugh Scaife Amadeus Saul Zaentz The Killing Fields David Puttnam A Passage to India John Brabourne Richard Goodwin Places in the Heart Arlene Donovan A Soldier's Story Norman Jewison Patrick Palmer Ronald L. Schwary The Killing Fields Chris Menges Amadeus Miroslav Ondricek The Natural Caleb Deschanel A Passage to India Ernest Day The River Vilmos Zsigmond Amadeus Theodor Pistek 2010 Patricia Norris The Bostonians Jenny Beavan John Bright A Passage to India Judy Moorcroft Places in the Heart Ann Roth Amadeus Milos Forman Broadway Danny Rose Woody Allen The Killing Fields Roland Joffé A Passage to India David Lean Places in the Heart Robert Benton The Times of Harvey Milk Robert Epstein Richard Schmiechen High Schools Charles Guggenheim Nancy Sloss In the Name of the People Frank Christopher Alex W. Drehsler Marlene Zev Braun Karel Dirka Streetwise Cheryl McCall The Stone Carvers Marjorie Hunt Paul Wagner The Children of Soong Ching Ling Gary Bush Paul T.K. Lin Code Gray: Ethical Dilemmas in Nursing Ben Achtenberg Joan Sawyer The Garden of Eden Lawrence R. Hott Roger M. Sherman Recollections of Pavlovsk Irina Kalinina The Killing Fields Jim Clark Amadeus Michael Chandler Nena Danevic The Cotton Club Robert Q. Lovett Barry Malkin A Passage to India David Lean Romancing the Stone Donn Cambern Frank Morriss Dangerous Moves Switzerland Beyond the Walls Israel Camila Argentina Double Feature Spain Wartime Romance Union of Soviet Socialist Republics Amadeus Paul LeBlanc Dick Smith 2010 Michael Westmore Greystoke: The Legend of Tarzan, Lord of the Apes Rick Baker Paul Engelen A Passage to India Maurice Jarre Indiana Jones and the Temple of Doom John Williams The Natural Randy Newman The River John Williams Under the Volcano Alex North Purple Rain Prince The Muppets Take Manhattan Jeff Moss Songwriter Kris Kristofferson I Just Called to Say I Love You The Woman in Red Stevie Wonder Against All Odds (Take a Look at Me Now) Against All Odds Phil Collins Footloose Footloose Kenny Loggins Dean Pitchford Ghostbusters Ghostbusters Ray Parker Jr. Let's Hear It for the Boy Footloose Dean Pitchford Tom Snow Amadeus Peter Shaffer Greystoke: The Legend of Tarzan, Lord of the Apes Michael Austin P.H. Vazak The Killing Fields Bruce Robinson A Passage to India David Lean A Soldier's Story Charles Fuller Places in the Heart Robert Benton Beverly Hills Cop Danilo Bach Daniel Petrie Jr. Broadway Danny Rose Woody Allen El Norte Gregory Nava Anna Thomas Splash Bruce Jay Friedman Lowell Ganz Brian Grazer Babaloo Mandel Charade Jon Minnis Doctor De Soto Morton Schindel Michael Sporn Paradise Ishu Patel Up Mike Hoover The Painted Door Michael MacMillan Janice L. Platt Tales of Meeting and Parting Lesli Linka Glatter Sharon Oreck Amadeus Mark Berger Todd Boekelheide Chris Newman Tom Scott 2010 Gene S. Cantamessa Carlos De Larios Michael J. Kohut Aaron Rochin Dune Steve Maslow Kevin O'Connell Nelson Stoll Bill Varney A Passage to India Michael A. Carter Graham V. Hartstone Nicolas Le Messurier John Mitchell The River Nick Alphin Richard Portman David Ronne Robert Thirlwell Indiana Jones and the Temple of Doom George Gibbs Michael McAlister Dennis Muren Lorne Peterson 2010 Richard Edlund George Jenson Neil Krepela Mark Stetson Ghostbusters John Bruno Richard Edlund Chuck Gaspar Mark Vargo Kiss of the Spider Woman William Hurt Witness Harrison Ford Murphy's Romance James Garner Prizzi's Honor Jack Nicholson Runaway Train Jon Voight Cocoon Don Ameche Out of Africa Klaus Maria Brandauer Prizzi's Honor William Hickey Jagged Edge Robert Loggia Runaway Train Eric Roberts The Trip to Bountiful Geraldine Page Agnes of God Anne Bancroft The Color Purple Whoopi Goldberg Sweet Dreams Jessica Lange Out of Africa Meryl Streep Prizzi's Honor Anjelica Huston The Color Purple Margaret Avery Twice in a Lifetime Amy Madigan Agnes of God Meg Tilly The Color Purple Oprah Winfrey Out of Africa Stephen Grimes Josie MacAvin Brazil Norman Garwood Maggie Gray The Color Purple J. Michael Riva Robert W. Welch Linda DeScenna Ran Shinobu Muraki Yoshiro Muraki Witness Stan Jolley John Anderson Out of Africa Sydney Pollack The Color Purple Quincy Jones Kathleen Kennedy Frank Marshall Steven Spielberg Kiss of the Spider Woman David Weisman Prizzi's Honor John Foreman Witness Edward S. Feldman Out of Africa David Watkin The Color Purple Allen Daviau Murphy's Romance William A. Fraker Ran Asakazu Nakai Takao Saito Masaharu Ueda Witness John Seale Ran Emi Wada The Color Purple Aggie Guerard Rodgers The Journey of Natty Gann Albert Wolsky Out of Africa Milena Canonero Prizzi's Honor Donfeld Out of Africa Sydney Pollack Kiss of the Spider Woman Hector Babenco Prizzi's Honor John Huston Ran Akira Kurosawa Witness Peter Weir Broken Rainbow Maria Florio Victoria Mudd Las Madres - the Mothers of Plaza De Mayo Susana Muñoz Lourdes Portillo Soldiers in Hiding Japhet Asher The Statue of Liberty Ken Burns Buddy Squires Unfinished Business Steven Okazaki Witness to War: Dr. Charlie Clements David Goodman The Courage To Care Robert Gardner Keats and His Nightingale: A Blind Date Michael Crowley James Wolpaw Making Overtures - the Story of a Community Orchestra Barbara Willis Sweete The Wizard of the Strings Alan Edelstein Witness Thom Noble A Chorus Line John Bloom Out of Africa Pembroke Herring Sheldon Kahn Fredric Steinkamp William Steinkamp Prizzi's Honor Kaja Fehr Rudi Fehr Runaway Train Henry Richardson The Official Story Argentina Angry Harvest Federal Republic of Germany Colonel Redl Hungary Three Men and a Cradle France When Father Was Away on Business Yugoslavia Mask Zoltan Elek Michael Westmore The Color Purple Ken Chase Remo Williams: The Adventure Begins Carl Fullerton Out of Africa John Barry Agnes of God Georges Delerue The Color Purple Chris Boardman Jorge Calandrelli Andrae Crouch Jack Hayes Jerry Hey Quincy Jones Randy Kerber Jeremy Lubbock Joel Rosenbaum Caiphus Semenya Fred Steiner Rod Temperton Silverado Bruce Broughton Witness Maurice Jarre Say You, Say Me White Nights Lionel Richie Miss Celie's Blues (Sister) The Color Purple Quincy Jones Lionel Richie Rod Temperton Separate Lives (Love Theme from 'White Nights') White Nights Stephen Bishop Surprise, Surprise A Chorus Line Marvin Hamlisch Edward Kleban The Power of Love Back to the Future Johnny Colla Chris Hayes Huey Lewis Out of Africa Kurt Luedtke The Color Purple Menno Meyjes Kiss of the Spider Woman Leonard Schrader Prizzi's Honor Richard Condon Janet Roach The Trip to Bountiful Horton Foote Witness William Kelley Earl W. Wallace Pamela Wallace Back to the Future Bob Gale Robert Zemeckis Brazil Terry Gilliam Charles McKeown Tom Stoppard The Official Story Aida Bortnik Luis Puenzo The Purple Rose of Cairo Woody Allen Anna & Bella Cilia Van Dijk The Big Snit Richard Condie Michael Scott Second Class Mail Alison Snowden Molly's Pilgrim Jeff Brown Chris Pelzer Graffiti Dianna Costello Rainbow War Bob Rogers Out of Africa Gary Alexander Peter Handford Chris Jenkins Larry Stensvold Back to the Future William B. Kaplan B. Tennyson Sebastian II Robert Thirlwell Bill Varney A Chorus Line Gerry Humphreys Michael Minkler Donald O. Mitchell Chris Newman Ladyhawke Dick Alexander Bud Alper Les Fresholtz Vern Poore Silverado Rick Kline Donald O. Mitchell Kevin O'Connell David Ronne Back to the Future Charles L. Campbell Robert Rutledge Ladyhawke Bob Henderson Alan Murray Rambo: First Blood Part II Frederick J. Brown Cocoon David Berry Scott Farrar Ralph McQuarrie Ken Ralston Return to Oz Michael Lloyd Zoran Perisic Will Vinton Ian Wingrove Young Sherlock Holmes David Allen John Ellis Dennis Muren Kit West The Color of Money Paul Newman 'Round Midnight Dexter Gordon Mona Lisa Bob Hoskins Children of a Lesser God William Hurt Salvador James Woods Hannah and Her Sisters Michael Caine Platoon Tom Berenger Platoon Willem Dafoe A Room with a View Denholm Elliott Hoosiers Dennis Hopper Children of a Lesser God Marlee Matlin The Morning After Jane Fonda Crimes of the Heart Sissy Spacek Peggy Sue Got Married Kathleen Turner Aliens Sigourney Weaver Hannah and Her Sisters Dianne Wiest Crimes of the Heart Tess Harper Children of a Lesser God Piper Laurie The Color of Money Mary Elizabeth Mastrantonio A Room with a View Maggie Smith A Room with a View Brian Ackland-Snow Gianni Quaranta Elio Altamura Brian Savegar Aliens Peter Lamont Crispian Sallis The Color of Money Boris Leven Karen A. O'Hara Hannah and Her Sisters Stuart Wurtzel Carol Joffe The Mission Stuart Craig Jack Stephens Platoon Arnold Kopelson Children of a Lesser God Patrick Palmer Burt Sugarman Hannah and Her Sisters Robert Greenhut The Mission Fernando Ghia David Puttnam A Room with a View Ismail Merchant The Mission Chris Menges Peggy Sue Got Married Jordan Cronenweth Platoon Robert Richardson A Room with a View Tony Pierce-Roberts Star Trek IV: The Voyage Home Don Peterman A Room with a View Jenny Beavan John Bright The Mission Enrico Sabbatini Otello Anna Anni Maurizio Millenotti Peggy Sue Got Married Theadora Van Runkle Pirates Anthony Powell Platoon Oliver Stone Blue Velvet David Lynch Hannah and Her Sisters Woody Allen The Mission Roland Joffé A Room with a View James Ivory Artie Shaw: Time Is All You've Got Brigitte Berman Down and Out in America Joseph Feury Milton Justice Chile: ¿Hasta Cuando? David Bradbury Isaac in America: A Journey with Isaac Bashevis Singer Amram Nowak Kirk Simon Witness to Apartheid Sharon I. Sopher Women - for America, for the World Vivienne Verdon-Roe Debonair Dancers Alison Nigh-Strelich The Masters of Disaster Sonya Friedman Red Grooms: Sunflower in a Hothouse Madeline Bell Thomas L. Neff Sam Aaron D. Weisblatt Platoon Claire Simpson Aliens Ray Lovejoy Hannah and Her Sisters Susan E. Morse The Mission Jim Clark Top Gun Chris Lebenzon Billy Weber The Assault The Netherlands '38' Austria Betty Blue France The Decline of the American Empire Canada My Sweet Little Village Czechoslovakia The Fly Stephan Dupuis Chris Walas The Clan of the Cave Bear Michèle Burke Michael G. Westmore Legend Rob Bottin Peter Robb-King 'Round Midnight Herbie Hancock Aliens James Horner Hoosiers Jerry Goldsmith The Mission Ennio Morricone Star Trek IV: The Voyage Home Leonard Rosenman Take My Breath Away Top Gun Giorgio Moroder Tom Whitlock Glory of Love The Karate Kid Part II Peter Cetera David Foster Diane Nini Life in a Looking Glass That's Life Leslie Bricusse Henry Mancini Mean Green Mother from Outer Space Little Shop of Horrors Howard Ashman Alan Menken Somewhere Out There An American Tail James Horner Barry Mann Cynthia Weil A Room with a View Ruth Prawer Jhabvala Children of a Lesser God Hesper Anderson Mark Medoff The Color of Money Richard Price Crimes of the Heart Beth Henley Stand By Me Bruce A. Evans Raynold Gideon Hannah and Her Sisters Woody Allen Crocodile"Dundee" John Cornell Paul Hogan Ken Shadie My Beautiful Laundrette Hanif Kureishi Platoon Oliver Stone Salvador Richard Boyle Oliver Stone A Greek Tragedy Willem Thijssen Linda Van Tulden The Frog, the Dog and the Devil Bob Stenhouse Luxo Jr. John Lasseter William Reeves Precious Images Chuck Workman Exit Pino Quartullo Stefano Reali Love Struck Fredda Weiss Platoon Charles "Bud" Grenzbach Simon Kaye Richard Rogers John K. Wilkinson Aliens Michael A. Carter Roy Charman Graham V. Hartstone Nicolas Le Messurier Heartbreak Ridge Dick Alexander Les Fresholtz William Nelson Vern Poore Star Trek IV: The Voyage Home Gene S. Cantamessa Dave Hudson Mel Metcalfe Terry Porter Top Gun William B. Kaplan Rick Kline Donald O. Mitchell Kevin O'Connell Aliens Don Sharpe Star Trek Iv: The Voyage Home Mark Mangini Top Gun Cecelia Hall George Watters II Aliens Suzanne Benson John Richardson Robert Skotak Stan Winston Little Shop of Horrors Lyle Conway Bran Ferren Martin Gutteridge Poltergeist II: The Other Side John Bruno Richard Edlund William Neil Garry Waller Wall Street Michael Douglas Broadcast News William Hurt Dark Eyes Marcello Mastroianni Ironweed Jack Nicholson Good Morning, Vietnam Robin Williams The Untouchables Sean Connery Broadcast News Albert Brooks Street Smart Morgan Freeman Moonstruck Vincent Gardenia Cry Freedom Denzel Washington Moonstruck Cher Fatal Attraction Glenn Close Broadcast News Holly Hunter Anna Sally Kirkland Ironweed Meryl Streep Moonstruck Olympia Dukakis Gaby Norma Aleandro Fatal Attraction Anne Archer Throw Momma from the Train Anne Ramsey The Whales of August Ann Sothern The Last Emperor Ferdinando Scarfiotti Bruno Cesari Osvaldo Desideri Empire of the Sun Norman Reynolds Harry Cordwell Hope and Glory Anthony Pratt Joan Woollard Radio Days Santo Loquasto Les Bloom George DeTitta Jr. Carol Joffe The Untouchables William A. Elliott Patrizia Von Brandenstein Hal Gausman The Last Emperor Jeremy Thomas Broadcast News James L. Brooks Fatal Attraction Stanley R. Jaffe Sherry Lansing Hope and Glory John Boorman Moonstruck Norman Jewison Patrick Palmer The Last Emperor Vittorio Storaro Broadcast News Michael Ballhaus Empire of the Sun Allen Daviau Hope and Glory Philippe Rousselot Matewan Haskell Wexler The Last Emperor James Acheson The Dead Dorothy Jeakins Empire of the Sun Bob Ringwood Maurice Jenny Beavan John Bright The Untouchables Marilyn Vance-Straker The Last Emperor Bernardo Bertolucci Fatal Attraction Adrian Lyne Hope and Glory John Boorman Moonstruck Norman Jewison My Life As a Dog Lasse Hallström The Ten-Year Lunch: The Wit and Legend of the Algonquin Round Table Aviva Slesin Eyes on the Prize: America's Civil Rights Years/Bridge to Freedom 1965 Callie Crossley James A. DeVinney Hellfire: A Journey from Hiroshima John W. Dower John Junkerman Radio Bikini Robert Stone A Stitch for Time Cyril Christo Barbara Herbich Young at Heart Pamela Conn Sue Marx Frances Steloff: Memoirs of a Bookseller Deborah Dickson In the Wee Wee Hours... Izak Ben-Meir Dr. Frank Daniel Language Says It All Megan Williams Silver Into Gold Lynn Mueller The Last Emperor Gabriella Cristiani Broadcast News Richard Marks Empire of the Sun Michael Kahn Fatal Attraction Peter E. Berger Michael Kahn Robocop Frank J. Urioste Babette's Feast Denmark Au Revoir Les Enfants (Goodbye, Children) France Course Completed Spain The Family Italy Pathfinder Norway Harry and the Hendersons Rick Baker Happy New Year Bob Laden The Last Emperor David Byrne Cong Su Ryuichi Sakamoto Cry Freedom George Fenton Jonas Gwangwa Empire of the Sun John Williams The Untouchables Ennio Morricone The Witches of Eastwick John Williams I(Ve'had the) Time of My Life Dirty Dancing John DeNicola Donald Markowitz Franke Previte Cry Freedom Cry Freedom George Fenton Jonas Gwangwa Nothing's Gonna Stop Us Now Mannequin Albert Hammond Diane Warren Shakedown Beverly Hills Cop II Harold Faltermeyer Keith Forsey Bob Seger Storybook Love The Princess Bride Willy DeVille The Last Emperor Bernardo Bertolucci Mark Peploe The Dead Tony Huston Fatal Attraction James Dearden Full Metal Jacket Gustav Hasford Michael Herr Stanley Kubrick My Life As a Dog Per Berglund Brasse Brännström Lasse Hallström Reidar Jönsson Moonstruck John Patrick Shanley Au Revoir Les Enfants (Goodbye, Children) Louis Malle Broadcast News James L. Brooks Hope and Glory John Boorman Radio Days Woody Allen The Man Who Planted Trees Frédéric Back George and Rosemary Eunice Macaulay Your Face Bill Plympton Ray's Male Heterosexual Dance Hall Jana Sue Memel Jonathan Sanger Making Waves Ann Wingate Shoeshine Robert A. Katz The Last Emperor Bill Rowe Ivan Sharrock Empire of the Sun John Boyd Tony Dawe Don Digirolamo Robert Knudson Lethal Weapon Dick Alexander Les Fresholtz Bill Nelson Vern Poore Robocop Carlos de Larios Michael J. Kohut Aaron Rochin Robert Wald The Witches of Eastwick Wayne Artman Tom Beckert Tom Dahl Art Rochester Innerspace William George Harley Jessup Dennis Muren Kenneth Smith Predator Richard Greenberg Robert M. Greenberg Joel Hynek Stan Winston Rain Man Dustin Hoffman Mississippi Burning Gene Hackman Big Tom Hanks Stand and Deliver Edward James Olmos Pelle the Conqueror Max Von Sydow A Fish Called Wanda Kevin Kline Little Dorrit Alec Guinness Tucker the Man and His Dream Martin Landau Running on Empty River Phoenix Married to the Mob Dean Stockwell The Accused Jodie Foster Dangerous Liaisons Glenn Close Working Girl Melanie Griffith A Cry in the Dark Meryl Streep Gorillas in the Mist Sigourney Weaver The Accidental Tourist Geena Davis Working Girl Joan Cusack Mississippi Burning Frances McDormand Dangerous Liaisons Michelle Pfeiffer Working Girl Sigourney Weaver Dangerous Liaisons Stuart Craig Gerard James Beaches Albert Brenner Garrett Lewis Rain Man Ida Random Linda DeScenna Tucker the Man and His Dream Dean Tavoularis Armin Ganz Who Framed Roger Rabbit Elliot Scott Peter Howitt Rain Man Mark Johnson The Accidental Tourist Michael Grillo Lawrence Kasdan Charles Okun Dangerous Liaisons Norma Heyman Hank Moonjean Mississippi Burning Robert F. Colesberry Frederick Zollo Working Girl Douglas Wick Mississippi Burning Peter Biziou Rain Man John Seale Tequila Sunrise Conrad L. Hall The Unbearable Lightness of Being Sven Nykvist Who Framed Roger Rabbit Dean Cundey Dangerous Liaisons James Acheson Coming to America Deborah Nadoolman A Handful of Dust Jane Robinson Sunset Patricia Norris Tucker the Man and His Dream Milena Canonero Rain Man Barry Levinson A Fish Called Wanda Charles Crichton The Last Temptation of Christ Martin Scorsese Mississippi Burning Alan Parker Working Girl Mike Nichols Hotel Terminus: The Life and Times of Klaus Barbie Marcel Ophuls The Cry of Reason - Beyers Naude: An Afrikaner Speaks Out Robert Bilheimer Ronald Mix Let's Get Lost Nan Bush Bruce Weber Promises to Keep Ginny Durrin Who Killed Vincent Chin? Christine Choy Renee Tajima You Don't Have to Die Malcolm Clarke William Guttentag The Children's Storefront Karen Goodman Family Gathering Ann Tegnell Lise Yasui Gang Cops Thomas B. Fleming Daniel J. Marks Portrait of Imogen Nancy Hale Meg Partridge Who Framed Roger Rabbit Arthur Schmidt Die Hard John F. Link Frank J. Urioste Gorillas in the Mist Stuart Baird Mississippi Burning Gerry Hambling Rain Man Stu Linder Pelle the Conqueror Denmark Hanussen Hungary The Music Teacher Belgium Salaam Bombay! India Women on the Verge of a Nervous Breakdown Spain Beetlejuice Steve La Porte Ve Neill Robert Short Coming to America Rick Baker Scrooged Tom Burman Bari Dreiband-Burman The Milagro Beanfield War Dave Grusin The Accidental Tourist John Williams Dangerous Liaisons George Fenton Gorillas in the Mist Maurice Jarre Rain Man Hans Zimmer Let the River Run Working Girl Carly Simon Calling You Bagdad Cafe Bob Telson Two Hearts Buster Phil Collins Lamont Dozier Dangerous Liaisons Christopher Hampton The Accidental Tourist Frank Galati Lawrence Kasdan Gorillas in the Mist Tab Murphy Anna Hamilton Phelan Little Dorrit Christine Edzard The Unbearable Lightness of Being Jean-Claude Carrière Philip Kaufman Rain Man Ronald Bass Barry Morrow Big Gary Ross Anne Spielberg Bull Durham Ron Shelton A Fish Called Wanda John Cleese Charles Crichton Running on Empty Naomi Foner Tin Toy John Lasseter William Reeves The Cat Came Back Cordell Barker Technological Threat Brian Jennings Bill Kroyer The Appointments of Dennis Jennings Dean Parisot Steven Wright Cadillac Dreams Abbee Goldstein Matia Karrell Gullah Tales George deGolian Gary Moss Bird Dick Alexander Willie D. Burton Les Fresholtz Vern Poore Die Hard Don Bassman Kevin F. Cleary Al Overton Richard Overton Gorillas in the Mist Peter Handford Andy Nelson Brian Saunders Mississippi Burning Rick Kline Robert Litt Danny Michael Elliot Tyson Who Framed Roger Rabbit John Boyd Tony Dawe Don Digirolamo Robert Knudson Who Framed Roger Rabbit Charles L. Campbell Louis L. Edemann Die Hard Stephen H. Flick Richard Shorr Willow Ben Burtt Richard Hymns Who Framed Roger Rabbit George Gibbs Edward Jones Ken Ralston Richard Williams Die Hard Brent Boates Al DiSarro Richard Edlund Thaine Morris Willow Chris Evans Michael McAlister Dennis Muren Phil Tippett My Left Foot Daniel Day-Lewis Henry V Kenneth Branagh Born on the Fourth of July Tom Cruise Driving Miss Daisy Morgan Freeman Dead Poets Society Robin Williams Glory Denzel Washington Do the Right Thing Danny Aiello Driving Miss Daisy Dan Aykroyd A Dry White Season Marlon Brando Crimes and Misdemeanors Martin Landau Driving Miss Daisy Jessica Tandy Camille Claudel Isabelle Adjani Shirley Valentine Pauline Collins Music Box Jessica Lange The Fabulous Baker Boys Michelle Pfeiffer My Left Foot Brenda Fricker Enemies, a Love Story Anjelica Huston Enemies, a Love Story Lena Olin Steel Magnolias Julia Roberts Parenthood Dianne Wiest Batman Anton Furst Peter Young The Abyss Leslie Dilley Anne Kuljian The Adventures of Baron Munchausen Dante Ferretti Francesca Lo Schiavo Driving Miss Daisy Bruno Rubeo Crispian Sallis Glory Norman Garwood Garrett Lewis Driving Miss Daisy Lili Fini Zanuck Richard D. Zanuck Born on the Fourth of July A. Kitman Ho Oliver Stone Dead Poets Society Steven Haft Tony Thomas Paul Junger Witt Field of Dreams Charles Gordon Lawrence Gordon My Left Foot Noel Pearson Glory Freddie Francis The Abyss Mikael Salomon Blaze Haskell Wexler Born on the Fourth of July Robert Richardson The Fabulous Baker Boys Michael Ballhaus Henry V Phyllis Dalton The Adventures of Baron Munchausen Gabriella Pescucci Driving Miss Daisy Elizabeth McBride Harlem Nights Joe I. Tompkins Valmont Theodor Pistek Born on the Fourth of July Oliver Stone Crimes and Misdemeanors Woody Allen Dead Poets Society Peter Weir Henry V Kenneth Branagh My Left Foot Jim Sheridan Common Threads: Stories from the Quilt Bill Couturié Robert Epstein Adam Clayton Powell Richard Killberg Yvonne Smith Crack Usa: County Under Siege Vince DiPersio William Guttentag For All Mankind Betsy Broyles Breier Al Reinert Super Chief: The Life and Legacy of Earl Warren Bill Jersey Judith Leonard The Johnstown Flood Charles Guggenheim Fine Food, Fine Pastries, Open 6 to 9 David Petersen Yad Vashem: Preserving the Past to Ensure the Future Ray Errol Fox Born on the Fourth of July David Brenner Joe Hutshing The Bear Noëlle Boisson Driving Miss Daisy Mark Warner The Fabulous Baker Boys William Steinkamp Glory Steven Rosenblum Cinema Paradiso Italy Camille Claudel France Jesus of Montreal Canada Waltzing Regitze Denmark What Happened to Santiago Puerto Rico Driving Miss Daisy Lynn Barber Kevin Haney Manlio Rocchetti The Adventures of Baron Munchausen Fabrizio Sforza Maggie Weston Dad Ken Diaz Greg Nelson Dick Smith The Little Mermaid Alan Menken Born on the Fourth of July John Williams The Fabulous Baker Boys David Grusin Field of Dreams James Horner Indiana Jones and the Last Crusade John Williams Under the Sea The Little Mermaid Howard Ashman Alan Menken After All Chances Are Dean Pitchford Tom Snow I Love to See You Smile Parenthood Randy Newman Kiss the Girl The Little Mermaid Howard Ashman Alan Menken The Girl Who Used to Be Me Shirley Valentine Alan Bergman Marilyn Bergman Marvin Hamlisch Driving Miss Daisy Alfred Uhry Born on the Fourth of July Ron Kovic Oliver Stone Enemies, a Love Story Paul Mazursky Roger L. Simon Field of Dreams Phil Alden Robinson My Left Foot Shane Connaughton Jim Sheridan Dead Poets Society Tom Schulman Crimes and Misdemeanors Woody Allen Do the Right Thing Spike Lee When Harry Met Sally... Nora Ephron Sex, Lies, and Videotape Steven Soderbergh Balance Christoph Lauenstein Wolfgang Lauenstein The Cow Alexander Petrov The Hill Farm Mark Baker Work Experience James Hendrie Amazon Diary Robert Nixon The Childeater Jonathan Tammuz Glory Donald O. Mitchell Gregg C. Rudloff Elliot Tyson Russell Williams II The Abyss Don Bassman Kevin F. Cleary Lee Orloff Richard Overton Black Rain Donald O. Mitchell Kevin O'Connell Greg P. Russell Keith A. Wester Born on the Fourth of July Tod A. Maitland Michael Minkler Wylie Stateman Gregory H. Watkins Indiana Jones and the Last Crusade Ben Burtt Tony Dawe Shawn Murphy Gary Summers Indiana Jones and the Last Crusade Ben Burtt Richard Hymns Black Rain Milton C. Burrow William L. Manger Lethal Weapon 2 Robert Henderson Alan Robert Murray The Abyss John Bruno Dennis Muren Dennis Skotak Hoyt Yeatman The Adventures of Baron Munchausen Richard Conway Kent Houston Back to the Future Part II John Bell Steve Gawley Michael Lantieri Ken Ralston Reversal of Fortune Jeremy Irons Dances with Wolves Kevin Costner Awakenings Robert De Niro Cyrano De Bergerac Gerard Depardieu The Field Richard Harris Good Fellas Joe Pesci Longtime Companion Bruce Davison The Godfather, Part III Andy Garcia Dances with Wolves Graham Greene Dick Tracy Al Pacino Misery Kathy Bates The Grifters Anjelica Huston Pretty Woman Julia Roberts Postcards from the Edge Meryl Streep Mr. & Mrs. Bridge Joanne Woodward Ghost Whoopi Goldberg The Grifters Annette Bening Good Fellas Lorraine Bracco Wild at Heart Diane Ladd Dances with Wolves Mary McDonnell Dick Tracy Richard Sylbert Rick Simpson Cyrano De Bergerac Ezio Frigerio Jacques Rouxel Dances with Wolves Jeffrey Beecroft Lisa Dean Lisa Dean The Godfather, Part III Dean Tavoularis Gary Fettis Hamlet Dante Ferretti Francesca Lo Schiavo Dances with Wolves Kevin Costner Jim Wilson Awakenings Lawrence Lasker Walter F. Parkes Ghost Lisa Weinstein The Godfather, Part III Francis Ford Coppola Good Fellas Irwin Winkler Dances with Wolves Dean Semler Avalon Allen Daviau Dick Tracy Vittorio Storaro The Godfather, Part III Gordon Willis Henry & June Philippe Rousselot Cyrano De Bergerac Franca Squarciapino Avalon Gloria Gresham Dances with Wolves Elsa Zamparelli Dick Tracy Milena Canonero Hamlet Maurizio Millenotti Dances with Wolves Kevin Costner The Godfather, Part III Francis Ford Coppola Good Fellas Martin Scorsese The Grifters Stephen Frears Reversal of Fortune Barbet Schroeder American Dream Arthur Cohn Barbara Kopple Berkeley in the Sixties Mark Kitchell Building Bombs Mark Mori Susan Robinson Forever Activists: Stories from the Veterans of the Abraham Lincoln Brigade Judith Montell Waldo Salt: A Screenwriter's Journey Eugene Corr Robert Hillmann Days of Waiting Steven Okazaki Burning Down Tomorrow Kit Thomas Chimps: So Like Us Karen Goodman Kirk Simon Journey Into Life: The World of the Unborn Derek Bromhall Rose Kennedy: A Life to Remember Freida Lee Mock Terry Sanders Dances with Wolves Neil Travis Ghost Walter Murch The Godfather, Part III Lisa Fruchtman Barry Malkin Walter Murch Good Fellas Thelma Schoonmaker The Hunt for Red October Dennis Virkler John Wright Journey of Hope Switzerland Cyrano De Bergerac France Ju Dou People's Republic of China The Nasty Girl Germany Open Doors Italy Dick Tracy John Caglione Jr. Doug Drexler Cyrano De Bergerac Michèle Burke Jean-Pierre Eychenne Edward Scissorhands Ve Neill Stan Winston Dances with Wolves John Barry Avalon Randy Newman Ghost Maurice Jarre Havana David Grusin Home Alone John Williams Sooner Or Later (I Always Get My Man) Dick Tracy Stephen Sondheim Blaze of Glory Young Guns II Jon Bon Jovi I'm Checkin' Out Postcards from the Edge Shel Silverstein Promise Me You'll Remember The Godfather, Part III John Bettis Carmine Coppola Somewhere in My Memory Home Alone Leslie Bricusse John Williams Dances with Wolves Michael Blake Awakenings Steven Zaillian Good Fellas Nicholas Pileggi Martin Scorsese The Grifters Donald E. Westlake Reversal of Fortune Nicholas Kazan Ghost Bruce Joel Rubin Alice Woody Allen Avalon Barry Levinson Green Card Peter Weir Metropolitan Whit Stillman Creature Comforts Nick Park A Grand Day Out Nick Park Grasshoppers (Cavallette) Bruno Bozzetto The Lunch Date Adam Davidson 12:01 PM Jonathan Heap Hillary Ripps Bronx Cheers Raymond De Felitta Matthew Gross Dear Rosie Peter Cattaneo Barnaby Thompson Senzeni Na? (What Have We Done?) Bernard Joffa Anthony E. Nicholas Dances with Wolves Bill W. Benton Jeffrey Perkins Greg Watkins Russell Williams II Days of Thunder Rick Kline Donald O. Mitchell Kevin O'Connell Charles Wilborn Dick Tracy David E. Campbell Thomas Causey D. M. Hemphill Chris Jenkins The Hunt for Red October Don Bassman Kevin F. Cleary Richard Bryce Goodman Richard Overton Total Recall Carlos de Larios Michael J. Kohut Aaron Rochin Nelson Stoll The Hunt for Red October Cecelia Hall George Watters II Flatliners Charles L. Campbell Richard Franklin Total Recall Stephen H. Flick The Silence of the Lambs Anthony Hopkins Bugsy Warren Beatty Cape Fear Robert De Niro The Prince of Tides Nick Nolte The Fisher King Robin Williams City Slickers Jack Palance JFK Tommy Lee Jones Bugsy Harvey Keitel Bugsy Ben Kingsley Barton Fink Michael Lerner The Silence of the Lambs Jodie Foster Thelma & Louise Geena Davis Rambling Rose Laura Dern For the Boys Bette Midler Thelma & Louise Susan Sarandon The Fisher King Mercedes Ruehl Rambling Rose Diane Ladd Cape Fear Juliette Lewis The Prince of Tides Kate Nelligan Fried Green Tomatoes Jessica Tandy Bugsy Dennis Gassner Nancy Haigh Barton Fink Dennis Gassner Nancy Haigh The Fisher King Mel Bourne Cindy Carr Hook Norman Garwood Garrett Lewis The Prince of Tides Paul Sylbert Caryl Heller The Silence of the Lambs Ron Bozman Edward Saxon Kenneth Utt Beauty and the Beast Don Hahn Bugsy Warren Beatty Mark Johnson Barry Levinson JFK A. Kitman Ho Oliver Stone The Prince of Tides Andrew Karsch Barbra Streisand JFK Robert Richardson Bugsy Allen Daviau The Prince of Tides Stephen Goldblatt Terminator 2: Judgment Day Adam Greenberg Thelma & Louise Adrian Biddle Bugsy Albert Wolsky The Addams Family Ruth Myers Barton Fink Richard Hornung Hook Anthony Powell Madame Bovary Corinne Jorry The Silence of the Lambs Jonathan Demme Boyz N the Hood John Singleton Bugsy Barry Levinson JFK Oliver Stone Thelma & Louise Ridley Scott In the Shadow of the Stars Allie Light Irving Saraf Death on the Job Vince DiPersio William Guttentag Doing Time: Life Inside the Big House Alan Raymond Susan Raymond The Restless Conscience Hava Kohav Beller Wild By Law Diane Garey Lawrence Hott Deadly Deception: General Electric, Nuclear Weapons and Our Environment Debra Chasnoff Birdnesters of Thailand (Aka "Shadow Hunters") Alain Majani Eric Valli A Little Vicious Immy Humes The Mark of the Maker David McGowan Memorial: Letters from American Soldiers Bill Couturié Bernard Edelman JFK Joe Hutshing Pietro Scalia The Commitments Gerry Hambling The Silence of the Lambs Craig McKay Terminator 2: Judgment Day Conrad Buff Mark Goldblatt Richard A. Harris Thelma & Louise Thom Noble Mediterraneo Italy Children of Nature Iceland The Elementary School Czechoslovakia The Ox Sweden Raise the Red Lantern Hong Kong Terminator 2: Judgment Day Jeff Dawn Stan Winston Hook Greg Cannom Christina Smith Monty Westmore Star Trek VI: The Undiscovered Country Edward French Michael Mills Richard Snell Beauty and the Beast Alan Menken Bugsy Ennio Morricone The Fisher King George Fenton JFK John Williams The Prince of Tides James Newton Howard Beauty and the Beast Beauty and the Beast Howard Ashman Alan Menken (Everything I Do) I Do It for You Robin Hood: Prince of Thieves Bryan Adams Michael Kamen Robert John Lange Be Our Guest Beauty and the Beast Howard Ashman Alan Menken Belle Beauty and the Beast Howard Ashman Alan Menken When You're Alone Hook Leslie Bricusse John Williams The Silence of the Lambs Ted Tally Europa Europa Agnieszka Holland Fried Green Tomatoes Fannie Flagg Carol Sobieski JFK Zachary Sklar Oliver Stone The Prince of Tides Pat Conroy Becky Johnston Thelma & Louise Callie Khouri Boyz N the Hood John Singleton Bugsy James Toback The Fisher King Richard LaGravenese Grand Canyon Lawrence Kasdan Meg Kasdan Manipulation Daniel Greaves Blackfly Christopher Hinton Strings Wendy Tilby Session Man Rob Fried Seth Winston Birch Street Gym Thomas R. Conroy Stephen Kessler Last Breeze of Summer David M. Massey Terminator 2: Judgment Day Tom Johnson Lee Orloff Gary Rydstrom Gary Summers Backdraft Gary Rydstrom Gary Summers Randy Thom Glenn Williams Beauty and the Beast David J. Hudson Doc Kane Mel Metcalfe Terry Porter JFK Gregg Landaker Tod A. Maitland Michael Minkler The Silence of the Lambs Tom Fleischman Christopher Newman Terminator 2: Judgment Day Gloria S. Borders Gary Rydstrom Backdraft Richard Hymns Gary Rydstrom Star Trek VI: The Undiscovered Country F. Hudson Miller George Watters II Terminator 2: Judgment Day Dennis Muren Robert Skotak Gene Warren Jr. Stan Winston Backdraft Scott Farrar Allen Hall Clay Pinney Mikael Salomon Hook Eric Brevig Harley Jessup Michael Lantieri Mark Sullivan Scent of a Woman Al Pacino Chaplin Robert Downey Jr. Unforgiven Clint Eastwood The Crying Game Stephen Rea Malcolm X Denzel Washington Unforgiven Gene Hackman The Crying Game Jaye Davidson A Few Good Men Jack Nicholson Glengarry Glen Ross Al Pacino Mr. Saturday Night David Paymer Howards End Emma Thompson Indochine Catherine Deneuve Passion Fish Mary McDonnell Love Field Michelle Pfeiffer Lorenzo's Oil Susan Sarandon My Cousin Vinny Marisa Tomei Husbands and Wives Judy Davis Enchanted April Joan Plowright Howards End Vanessa Redgrave Damage Miranda Richardson Unforgiven Clint Eastwood The Crying Game Stephen Woolley A Few Good Men David Brown Rob Reiner Andrew Scheinman Howards End Ismail Merchant Scent of a Woman Martin Brest Unforgiven Clint Eastwood The Crying Game Neil Jordan Howards End James Ivory The Player Robert Altman Scent of a Woman Martin Brest Philadelphia Tom Hanks In the Name of the Father Daniel Day-Lewis What's Love Got to Do with It Laurence Fishburne The Remains of the Day Anthony Hopkins Schindler's List Liam Neeson The Fugitive Tommy Lee Jones What's Eating Gilbert Grape Leonardo DiCaprio Schindler's List Ralph Fiennes In the Line of Fire John Malkovich In the Name of the Father Pete Postlethwaite The Piano Holly Hunter What's Love Got to Do with It Angela Bassett Six Degrees of Separation Stockard Channing The Remains of the Day Emma Thompson Shadowlands Debra Winger The Piano Anna Paquin The Firm Holly Hunter Fearless Rosie Perez The Age of Innocence Winona Ryder In the Name of the Father Emma Thompson Schindler's List Allan Starski Ewa Braun Addams Family Values Ken Adam Marvin March The Age of Innocence Dante Ferretti Robert J. Franco Orlando Jan Roelfs Ben Van Os The Remains of the Day Luciana Arrighi Ian Whittaker Schindler's List Branko Lustig Gerald R. Molen Steven Spielberg The Fugitive Arnold Kopelson In the Name of the Father Jim Sheridan The Piano Jan Chapman The Remains of the Day John Calley Ismail Merchant Mike Nichols Schindler's List Janusz Kaminski Farewell My Concubine Gu Changwei The Fugitive Michael Chapman The Piano Stuart Dryburgh Searching for Bobby Fischer Conrad L. Hall The Age of Innocence Gabriella Pescucci Orlando Sandy Powell The Piano Janet Patterson The Remains of the Day Jenny Beavan John Bright Schindler's List Anna Biedrzycka-Sheppard Schindler's List Steven Spielberg In the Name of the Father Jim Sheridan The Piano Jane Campion The Remains of the Day James Ivory Short Cuts Robert Altman I Am a Promise: The Children of Stanton Elementary School Alan Raymond Susan Raymond The Broadcast Tapes of Dr. Peter Arthur Ginsberg David Paperny Children of Fate Susan Todd Andrew Young For Better Or for Worse David Collier Betsy Thompson The War Room Chris Hegedus D. A. Pennebaker Defending Our Lives Margaret Lazarus Renner Wunderlich Blood Ties: The Life and Work of Sally Mann Steven Cantor Peter Spirer Chicks in White Satin Elaine Holliman Jason Schneider Schindler's List Michael Kahn The Fugitive Don Brochu David Finfer Dean Goodhill Dov Hoenig Richard Nord Dennis Virkler In the Line of Fire Anne V. Coates In the Name of the Father Gerry Hambling The Piano Veronika Jenet Belle Epoque Spain Farewell My Concubine Hong Kong Hedd Wyn United Kingdom The Scent of Green Papaya Vietnam The Wedding Banquet Taiwan Mrs. Doubtfire Greg Cannom Ve Neill Yolanda Toussieng Philadelphia Alan D'Angerio Carl Fullerton Schindler's List Judy Alexander Cory Matthew Mungle Christina Smith Schindler's List John Williams The Age of Innocence Elmer Bernstein The Firm Dave Grusin The Fugitive James Newton Howard The Remains of the Day Richard Robbins Streets of Philadelphia Philadelphia Bruce Springsteen A Wink and a Smile Sleepless in Seattle Ramsey McLean Marc Shaiman Again Poetic Justice James Harris III Janet Jackson Terry Lewis Philadelphia Philadelphia Neil Young The Day I Fall in Love Beethoven's 2nd James Ingram Clif Magness Carole Bayer Sager Schindler's List Steven Zaillian The Age of Innocence Jay Cocks Martin Scorsese In the Name of the Father Terry George Jim Sheridan The Remains of the Day Ruth Prawer Jhabvala Shadowlands William Nicholson The Piano Jane Campion Dave Gary Ross In the Line of Fire Jeff Maguire Philadelphia Ron Nyswaner Sleepless in Seattle Jeff Arch Nora Ephron David S. Ward The Wrong Trousers Nick Park Blindscape Stephen Palmer The Mighty River Frédéric Back Hubert Tison Small Talk Kevin Baldwin Bob Godfrey The Village Mark Baker Black Rider (Schwarzfahrer) Pepe Danquart Down on the Waterfront Jonathan Penner Stacy Title The Dutch Master Jonathan Brett Susan Seidelman Partners Jana Sue Memel Peter Weller The Screw (La Vis) Didier Flamand Jurassic Park Ron Judkins Shawn Murphy Gary Rydstrom Gary Summers Cliffhanger Bob Beemer Tim Cooney Michael Minkler The Fugitive Michael Herbick Donald O. Mitchell Frank A. Montaño Scott D. Smith Geronimo: An American Legend Bill W. Benton Chris Carpenter D. M. Hemphill Lee Orloff Schindler's List Ron Judkins Scott Millan Andy Nelson Steve Pederson Jurassic Park Richard Hymns Gary Rydstrom Cliffhanger Gregg Baxter Wylie Stateman The Fugitive John Leveque Bruce Stambler Jurassic Park Michael Lantieri Dennis Muren Phil Tippett Stan Winston Cliffhanger John Bruno Pamela Easley Neil Krepela John Richardson The Nightmare before Christmas Gordon Baker Pete Kozachik Eric Leighton Ariel Velasco Shaw Forrest Gump Tom Hanks The Shawshank Redemption Morgan Freeman The Madness of King George Nigel Hawthorne Nobody's Fool Paul Newman Pulp Fiction John Travolta Ed Wood Martin Landau Pulp Fiction Samuel L. Jackson Bullets Over Broadway Chazz Palminteri Quiz Show Paul Scofield Forrest Gump Gary Sinise Blue Sky Jessica Lange Nell Jodie Foster Tom & Viv Miranda Richardson Little Women Winona Ryder The Client Susan Sarandon Bullets Over Broadway Dianne Wiest Tom & Viv Rosemary Harris The Madness of King George Helen Mirren Pulp Fiction Uma Thurman Bullets Over Broadway Jennifer Tilly The Madness of King George Ken Adam Carolyn Scott Bullets Over Broadway Santo Loquasto Susan Bode Forrest Gump Rick Carter Nancy Haigh Interview with the Vampire Dante Ferretti Francesca Lo Schiavo Legends of the Fall Lilly Kilvert Dorree Cooper Forrest Gump Wendy Finerman Steve Starkey Steve Tisch Four Weddings and a Funeral Duncan Kenworthy Pulp Fiction Lawrence Bender Quiz Show Michael Jacobs Julian Krainin Michael Nozik Robert Redford The Shawshank Redemption Niki Marvin Legends of the Fall John Toll Forrest Gump Don Burgess Red Piotr Sobocinski The Shawshank Redemption Roger Deakins Wyatt Earp Owen Roizman The Adventures of Priscilla, Queen of the Desert Tim Chappel Lizzy Gardiner Bullets Over Broadway Jeffrey Kurland Little Women Colleen Atwood Maverick April Ferry Queen Margot Moidele Bickel Forrest Gump Robert Zemeckis Bullets Over Broadway Woody Allen Pulp Fiction Quentin Tarantino Quiz Show Robert Redford Red Krzysztof Kieslowski Maya Lin: A Strong Clear Vision Freida Lee Mock Terry Sanders Complaints of a Dutiful Daughter Deborah Hoffmann D-Day Remembered Charles Guggenheim Freedom on My Mind Connie Field Marilyn Mulford A Great Day in Harlem Jean Bach A Time for Justice Charles Guggenheim 89mm Od Europy (89mm from Europe) Marcel Lozinski Blues Highway Vince DiPersio Bill Guttentag School of the Americas Assassins Robert Richter Straight from the Heart Dee Mosbacher Frances Reid Forrest Gump Arthur Schmidt Hoop Dreams Bill Haugse Steve James Frederick Marx Pulp Fiction Sally Menke The Shawshank Redemption Richard Francis-Bruce Speed John Wright Burnt By the Sun Russia Before the Rain The Former Yugoslav Republic of Macedonia Eat Drink Man Woman Taiwan Farinelli: Il Castrato Belgium Strawberry and Chocolate Cuba Ed Wood Rick Baker Ve Neill Yolanda Toussieng Forrest Gump Judith A. Cory Hallie D'Amore Daniel C. Striepeke Mary Shelley's Frankenstein Paul Engelen Carol Hemming Daniel Parker The Lion King Hans Zimmer Forrest Gump Alan Silvestri Interview with the Vampire Elliot Goldenthal Little Women Thomas Newman The Shawshank Redemption Thomas Newman Can You Feel the Love Tonight The Lion King Elton John Tim Rice Circle of Life The Lion King Elton John Tim Rice Hakuna Matata The Lion King Elton John Tim Rice Look What Love Has Done Junior James Newton Howard James Ingram Carole Bayer Sager Patty Smyth Make Up Your Mind The Paper Randy Newman Forrest Gump Eric Roth The Madness of King George Alan Bennett Nobody's Fool Robert Benton Quiz Show Paul Attanasio The Shawshank Redemption Frank Darabont Pulp Fiction Roger Avary Quentin Tarantino Bullets Over Broadway Woody Allen Douglas McGrath Four Weddings and a Funeral Richard Curtis Heavenly Creatures Peter Jackson Frances Walsh Red Krzysztof Kieslowski Krzysztof Piesiewicz Bob's Birthday David Fine Alison Snowden The Big Story David Stoten Tim Watts The Janitor Vanessa Schwartz The Monk and the Fish Michael Dudok de Wit Triangle Erica Russell Franz Kafka's It's a Wonderful Life Peter Capaldi Ruth Kenley-Letts Trevor Peggy Rajski Randy Stone Kangaroo Court Christine Astin Sean Astin On Hope Michele McGuire JoBeth Williams Syrup Paul Unwin Nick Vivian Speed Bob Beemer Gregg Landaker David R. B. MacMillan Steve Maslow Clear and Present Danger Michael Herbick Donald O. Mitchell Frank A. Montaño Arthur Rochester Forrest Gump Tom Johnson William B. Kaplan Dennis Sands Randy Thom Legends of the Fall David Campbell Christopher David Douglas Ganton Paul Massey The Shawshank Redemption Willie Burton Michael Herbick Robert J. Litt Elliot Tyson Speed Stephen Hunter Flick Clear and Present Danger John Leveque Bruce Stambler Forrest Gump Gloria S. Borders Randy Thom Forrest Gump Allen Hall George Murphy Ken Ralston Stephen Rosenbaum The Mask Tom Bertino Jon Farhat Scott Squires Steve Williams True Lies John Bruno Thomas L. Fisher Patrick McClung Jacques Stroweis Leaving Las Vegas Nicolas Cage Mr. Holland's Opus Richard Dreyfuss Nixon Anthony Hopkins Dead Man Walking Sean Penn The Postman (Il Postino) Massimo Troisi The Usual Suspects Kevin Spacey Babe James Cromwell Apollo 13 Ed Harris 12 Monkeys Brad Pitt Rob Roy Tim Roth Dead Man Walking Susan Sarandon Leaving Las Vegas Elisabeth Shue Casino Sharon Stone The Bridges of Madison County Meryl Streep Sense and Sensibility Emma Thompson Mighty Aphrodite Mira Sorvino Nixon Joan Allen Apollo 13 Kathleen Quinlan Georgia Mare Winningham Sense and Sensibility Kate Winslet Restoration Eugenio Zanetti Apollo 13 Michael Corenblith Merideth Boswell Babe Roger Ford Kerrie Brown A Little Princess Bo Welch Cheryl Carasik Richard Iii Tony Burrough Braveheart Bruce Davey Mel Gibson Alan Ladd Jr. Apollo 13 Brian Grazer Babe Bill Miller George Miller Doug Mitchell The Postman (Il Postino) Mario Cecchi Gori Vittorio Cecchi Gori Gaetano Daniele Sense and Sensibility Lindsay Doran Braveheart John Toll Batman Forever Stephen Goldblatt A Little Princess Emmanuel Lubezki Sense and Sensibility Michael Coulter Shanghai Triad Lu Yue Restoration James Acheson 12 Monkeys Julie Weiss Braveheart Charles Knode Richard Iii Shuna Harwood Sense and Sensibility Jenny Beavan John Bright Braveheart Mel Gibson Babe Chris Noonan Dead Man Walking Tim Robbins Leaving Las Vegas Mike Figgis The Postman (Il Postino) Michael Radford Anne Frank Remembered Jon Blair The Battle Over Citizen Kane Michael Epstein Thomas Lennon Fiddlefest - Roberta Tzavaras and Her East Harlem Violin Program Allan Miller Walter Scheuer Hank Aaron: Chasing the Dream Fredric Golding Mike Tollin Troublesome Creek: A Midwestern Steven Ascher Jeanne Jordan One Survivor Remembers Kary Antholis Jim Dine: A Self-Portrait on the Walls Nancy Dine Richard Stilwell The Living Sea Alec Lorimore Greg MacGillivray Never Give Up: The 20th Century Odyssey of Herbert Zipper Freida Lee Mock Terry Sanders The Shadow of Hate Charles Guggenheim Apollo 13 Dan Hanley Mike Hill Babe Marcus D'Arcy Jay Friedkin Braveheart Steven Rosenblum Crimson Tide Chris Lebenzon Seven Richard Francis-Bruce Antonia's Line The Netherlands All Things Fair Sweden Dust of Life Algeria O Quatrilho Brazil The Star Maker Italy Braveheart Lois Burwell Peter Frampton Paul Pattison My Family, Mi Familia Ken Diaz Mark Sanchez Roommates Colleen Callaghan Greg Cannom Bob Laden The Postman (Il Postino) Luis Enrique Bacalov Apollo 13 James Horner Braveheart James Horner Nixon John Williams Sense and Sensibility Patrick Doyle Pocahontas Alan Menken Stephen Schwartz The American President Marc Shaiman Sabrina John Williams Toy Story Randy Newman Unstrung Heroes Thomas Newman Colors of the Wind Pocahontas Alan Menken Stephen Schwartz Dead Man Walkin' Dead Man Walking Bruce Springsteen Have You Ever Really Loved a Woman Don Juan Demarco Bryan Adams Michael Kamen Robert John Lange Moonlight Sabrina Alan Bergman Marilyn Bergman John Williams You've Got a Friend in Me Toy Story Randy Newman Sense and Sensibility Emma Thompson Apollo 13 William Broyles Jr. Al Reinert Babe George Miller Chris Noonan Leaving Las Vegas Mike Figgis The Postman (Il Postino) Anna Pavignano Michael Radford Furio Scarpelli Giacomo Scarpelli Massimo Troisi The Usual Suspects Christopher McQuarrie Braveheart Randall Wallace Mighty Aphrodite Woody Allen Nixon Stephen J. Rivele Oliver Stone Christopher Wilkinson Toy Story Joel Cohen Peter Docter John Lasseter Joe Ranft Alec Sokolow Andrew Stanton Joss Whedon A Close Shave Nick Park The Chicken from Outer Space John R. Dilworth Gagarin Alexij Kharitidi Runaway Brain Chris Bailey The End Robin Bargar Chris Landreth Lieberman in Love Christine Lahti Jana Sue Memel Brooms Luke Cresswell Steve McNicholas Duke of Groove Thom Colwell Griffin Dunne Little Surprises Tikki Goldberg Jeff Goldblum Tuesday Morning Ride Dianne Houston Joy Ryan Apollo 13 Rick Dior David MacMillan Scott Millan Steve Pederson Batman Forever Michael Herbick Petur Hliddal Donald O. Mitchell Frank A. Montaño Braveheart Anna Behlmer Scott Millan Andy Nelson Brian Simmons Crimson Tide William B. Kaplan Rick Kline Kevin O'Connell Gregory H. Watkins Waterworld Gregg Landaker Steve Maslow Keith A. Wester Braveheart Lon Bender Per Hallberg Batman Forever John Leveque Bruce Stambler Crimson Tide George Watters II Babe Scott E. Anderson John Cox Charles Gibson Neal Scanlan Apollo 13 Leslie Ekker Michael Kanfer Robert Legato Matt Sweeney Shine Geoffrey Rush Jerry Maguire Tom Cruise The English Patient Ralph Fiennes The People vs. Larry Flynt Woody Harrelson Sling Blade Billy Bob Thornton Jerry Maguire Cuba Gooding Jr. Fargo William H. Macy Shine Armin Mueller-Stahl Primal Fear Edward Norton Ghosts of Mississippi James Woods Fargo Frances McDormand Secrets & Lies Brenda Blethyn Marvin's Room Diane Keaton The English Patient Kristin Scott Thomas Breaking the Waves Emily Watson The English Patient Juliette Binoche The Crucible Joan Allen The Mirror Has Two Faces Lauren Bacall The Portrait of a Lady Barbara Hershey Secrets & Lies Marianne Jean-Baptiste The English Patient Stuart Craig Stephenie McMillan The Birdcage Bo Welch Cheryl Carasik Evita Brian Morris Philippe Turlure Hamlet Tim Harvey William Shakespeare's Romeo & Juliet Catherine Martin Brigitte Broch The English Patient Saul Zaentz Fargo Ethan Coen Jerry Maguire James L. Brooks Cameron Crowe Laurence Mark Richard Sakai Secrets & Lies Simon Channing-Williams Shine Jane Scott The English Patient John Seale Evita Darius Khondji Fargo Roger Deakins Fly Away Home Caleb Deschanel Michael Collins Chris Menges The English Patient Ann Roth Angels and Insects Paul Brown Emma Ruth Myers Hamlet Alex Byrne The Portrait of a Lady Janet Patterson The English Patient Anthony Minghella Fargo Joel Coen The People vs. Larry Flynt Milos Forman Secrets & Lies Mike Leigh Shine Scott Hicks When We Were Kings Leon Gast David Sonenberg The Line King: The Al Hirschfeld Story Susan W. Dryfoos Mandela Angus Gibson Jo Menell Suzanne Farrell: Elusive Muse Anne Belle Deborah Dickson Tell the Truth and Run: George Seldes and the American Press Rick Goldsmith Breathing Lessons: The Life and Work of Mark O'Brien Jessica Yu Cosmic Voyage Jeffrey Marvin Bayley Silleck An Essay on Matisse Perry Wolff Special Effects Ben Burtt Susanne Simpson The Wild Bunch: An Album in Montage Nick Redman Paul Seydor The English Patient Walter Murch Evita Gerry Hambling Fargo Roderick Jaynes Jerry Maguire Joe Hutshing Shine Pip Karmel Kolya Czech Republic A Chef in Love Georgia The Other Side of Sunday Norway Prisoner of the Mountains Russia Ridicule France The Nutty Professor David LeRoy Anderson Rick Baker Ghosts of Mississippi Deborah La Mia Denaver Matthew W. Mungle Star Trek: First Contact Jake Garber Michael Westmore Scott Wheeler The English Patient Gabriel Yared Hamlet Patrick Doyle Michael Collins Elliot Goldenthal Shine David Hirschfelder Sleepers John Williams Emma Rachel Portman The First Wives Club Marc Shaiman The Hunchback of Notre Dame Alan Menken Stephen Schwartz James and the Giant Peach Randy Newman The Preacher's Wife Hans Zimmer You Must Love Me Evita Andrew Lloyd Webber Tim Rice Because You Loved Me Up Close and Personal Diane Warren For the First Time One Fine Day Jud J. Friedman James Newton Howard Allan Dennis Rich I Finally Found Someone The Mirror Has Two Faces Bryan Adams Marvin Hamlisch Robert "Mutt" Lange Barbra Streisand That Thing You Do! That Thing You Do! Adam Schlesinger Sling Blade Billy Bob Thornton The Crucible Arthur Miller The English Patient Anthony Minghella Hamlet Kenneth Branagh Trainspotting John Hodge Fargo Ethan Coen Joel Coen Jerry Maguire Cameron Crowe Lone Star John Sayles Secrets & Lies Mike Leigh Shine Scott Hicks Jan Sardi Quest Tyron Montgomery Thomas Stellmach Canhead Timothy Hittle Chris Peterson La Salla Richard Condie Wat's Pig Peter Lord Dear Diary David Frankel Barry Jossen De Tripas, Corazon Antonio Urrutia Ernst & Lyset Anders Thomas Jensen Kim Magnusson Esposados Juan Carlos Fresnadillo Wordless Bernadette Carranza Antonello De Leo The English Patient Mark Berger Walter Murch Chris Newman David Parker Evita Anna Behlmer Andy Nelson Ken Weston Independence Day Bob Beemer Bill W. Benton Chris Carpenter Jeff Wexler The Rock Kevin O'Connell Greg P. Russell Keith A. Wester Twister Gregg Landaker Steve Maslow Kevin O'Connell Geoffrey Patterson The Ghost and the Darkness Bruce Stambler Daylight Richard L. Anderson David A. Whittaker Eraser Bub Asman Alan Robert Murray Independence Day Volker Engel Clay Pinney Douglas Smith Joseph Viskocil Dragonheart Scott Squires James Straus Phil Tippett Kit West Twister Stefen Fangmeier John Frazier Henry La Bounta Habib Zargarpour As Good As It Gets Jack Nicholson Good Will Hunting Matt Damon The Apostle Robert Duvall Ulee's Gold Peter Fonda Wag the Dog Dustin Hoffman Good Will Hunting Robin Williams Jackie Brown Robert Forster Amistad Anthony Hopkins As Good As It Gets Greg Kinnear Boogie Nights Burt Reynolds As Good As It Gets Helen Hunt The Wings of the Dove Helena Bonham Carter Afterglow Julie Christie Mrs. Brown Judi Dench Titanic Kate Winslet L.A. Confidential Kim Basinger In & Out Joan Cusack Good Will Hunting Minnie Driver Boogie Nights Julianne Moore Titanic Gloria Stuart Titanic Peter Lamont Michael Ford Gattaca Jan Roelfs Nancy Nye Kundun Dante Ferretti Francesca Lo Schiavo L.A. Confidential Jeannine Oppewall Jay R. Hart Men in Black Bo Welch Cheryl Carasik Titanic James Cameron Jon Landau As Good As It Gets James L. Brooks Bridget Johnson Kristi Zea The Full Monty Uberto Pasolini Good Will Hunting Lawrence Bender L.A. Confidential Curtis Hanson Arnon Milchan Michael Nathanson Titanic Russell Carpenter Amistad Janusz Kaminski Kundun Roger Deakins L.A. Confidential Dante Spinotti The Wings of the Dove Eduardo Serra Titanic Deborah L. Scott Amistad Ruth E. Carter Kundun Dante Ferretti Oscar and Lucinda Janet Patterson The Wings of the Dove Sandy Powell Titanic James Cameron The Full Monty Peter Cattaneo Good Will Hunting Gus Van Sant L.A. Confidential Curtis Hanson The Sweet Hereafter Atom Egoyan The Long Way Home Rabbi Marvin Hier Richard Trank 4 Little Girls Spike Lee Sam Pollard Ayn Rand: A Sense of Life Michael Paxton Colors Straight Up Michele Ohayon Julia Schachter Waco: The Rules of Engagement William Gazecki Dan Gifford A Story of Healing Donna Dewey Carol Pasternak Alaska: Spirit of the Wild George Casey Paul Novros Amazon Kieth Merrill Jonathan Stern Daughter of the Bride Terri Randall Still Kicking: The Fabulous Palm Springs Follies Andrea Blaugrund Mel Damski Titanic Conrad Buff James Cameron Richard A. Harris Air Force One Richard Francis-Bruce As Good As It Gets Richard Marks Good Will Hunting Pietro Scalia L.A. Confidential Peter Honess Character The Netherlands Beyond Silence Germany Four Days in September Brazil Secrets of the Heart Spain The Thief Russia Men in Black David LeRoy Anderson Rick Baker Mrs. Brown Beverley Binda Veronica Brebner Lisa Westcott Titanic Greg Cannom Tina Earnshaw Simon Thompson Titanic James Horner Amistad John Williams Good Will Hunting Danny Elfman Kundun Philip Glass L.A. Confidential Jerry Goldsmith The Full Monty Anne Dudley Anastasia Lynn Ahrens Stephen Flaherty David Newman As Good As It Gets Hans Zimmer Men in Black Danny Elfman My Best Friend's Wedding James Newton Howard My Heart Will Go on Titanic James Horner Will Jennings Go the Distance Hercules Alan Menken David Zippel How Do I Live Con Air Diane Warren Journey to the Past Anastasia Lynn Ahrens Stephen Flaherty Miss Misery Good Will Hunting Elliott Smith L.A. Confidential Curtis Hanson Brian Helgeland Donnie Brasco Paul Attanasio The Sweet Hereafter Atom Egoyan Wag the Dog Hilary Henkin David Mamet The Wings of the Dove Hossein Amini Good Will Hunting Ben Affleck Matt Damon As Good As It Gets Mark Andrus James L. Brooks Boogie Nights Paul Thomas Anderson Deconstructing Harry Woody Allen The Full Monty Simon Beaufoy Geri's Game Jan Pinkava Famous Fred Joanna Quinn La Vieille Dame Et Les Pigeons (The Old Lady and the Pigeons) Sylvain Chomet The Mermaid Alexander Petrov Redux Riding Hood Steve Moore Dan O'Shannon Visas and Virtue Chris Donahue Chris Tashima Dance Lexie Dance Tim Loane Pearse Moore It's Good To Talk Roger Goldby Barney Reisz Sweethearts? Birger Larsen Thomas Lydholm Wolfgang Anders Thomas Jensen Kim Magnusson Titanic Tom Johnson Gary Rydstrom Gary Summers Mark Ulano Air Force One D. M. Hemphill Rick Kline Paul Massey Keith A. Wester Con Air Kevin O'Connell Arthur Rochester Greg P. Russell Contact Tom Johnson William B. Kaplan Dennis Sands Randy Thom L.A. Confidential Anna Behlmer Kirk Francis Andy Nelson Titanic Tom Bellfort Christopher Boyes Face/Off Per Hallberg Mark P. Stoeckinger The Fifth Element Mark Mangini Titanic Thomas L. Fisher Michael Kanfer Mark Lasoff Robert Legato The Lost World: Jurassic Park Randal M. Dutra Michael Lantieri Dennis Muren Stan Winston Starship Troopers Scott E. Anderson Alec Gillis John Richardson Phil Tippett Life Is Beautiful Roberto Benigni Saving Private Ryan Tom Hanks Gods and Monsters Ian McKellen Affliction Nick Nolte American History X Edward Norton Affliction James Coburn A Civil Action Robert Duvall The Truman Show Ed Harris Shakespeare in Love Geoffrey Rush A Simple Plan Billy Bob Thornton Shakespeare in Love Gwyneth Paltrow Elizabeth Cate Blanchett Central Station Fernanda Montenegro One True Thing Meryl Streep Hilary and Jackie Emily Watson Shakespeare in Love Judi Dench Primary Colors Kathy Bates Little Voice Brenda Blethyn Hilary and Jackie Rachel Griffiths Gods and Monsters Lynn Redgrave Shakespeare in Love Martin Childs Jill Quertier Elizabeth John Myhre Peter Howitt Pleasantville Jeannine Oppewall Jay Hart Saving Private Ryan Tom Sanders Lisa Dean Kavanaugh What Dreams May Come Eugenio Zanetti Cindy Carr Shakespeare in Love David Parfitt Donna Gigliotti Harvey Weinstein Edward Zwick Marc Norman Elizabeth Alison Owen Eric Fellner Tim Bevan Life Is Beautiful Elda Ferri Gianluigi Braschi Saving Private Ryan Steven Spielberg Ian Bryce Mark Gordon Gary Levinsohn The Thin Red Line Robert Michael Geisler John Roberdeau Grant Hill Saving Private Ryan Janusz Kaminski A Civil Action Conrad L. Hall Elizabeth Remi Adefarasin Shakespeare in Love Richard Greatrex The Thin Red Line John Toll Shakespeare in Love Sandy Powell Beloved Colleen Atwood Elizabeth Alexandra Byrne Pleasantville Judianna Makovsky Velvet Goldmine Sandy Powell Saving Private Ryan Steven Spielberg Life Is Beautiful Roberto Benigni Shakespeare in Love John Madden The Thin Red Line Terrence Malick The Truman Show Peter Weir The Last Days James Moll Ken Lipper Dancemaker Matthew Diamond Jerry Kupfer The Farm: Angola, U.S.a. Jonathan Stack Liz Garbus Lenny Bruce: Swear To Tell the Truth Robert B. Weide Regret to Inform Barbara Sonneborn Janet Cole The Personals: Improvisations on Romance in the Golden Years Keiko Ibi A Place in the Land Charles Guggenheim Sunrise Over Tiananmen Square Shui-Bo Wang Donald McWilliams Saving Private Ryan Michael Kahn Life Is Beautiful Simona Paggi Out of Sight Anne V. Coates Shakespeare in Love David Gamble The Thin Red Line Bill Webber Leslie Jones Life Is Beautiful Italy Central Station Brazil Children of Heaven Iran The Grandfather Spain Tango Argentina Elizabeth Jenny Shircore Saving Private Ryan Lois Burwell Conor O'Sullivan Daniel C. Striepeke Shakespeare in Love Lisa Westcott Veronica Brebner Life Is Beautiful Nicola Piovani Elizabeth David Hirschfelder Pleasantville Randy Newman Saving Private Ryan John Williams The Thin Red Line Hans Zimmer Shakespeare in Love Stephen Warbeck A Bug's Life Randy Newman Mulan Jerry Goldsmith Matthew Wilder David Zippel Patch Adams Marc Shaiman The Prince of Egypt Hans Zimmer Stephen Schwartz When You Believe The Prince of Egypt Stephen Schwartz I Don't Want to Miss a Thing Armageddon Diane Warren The Prayer Quest for Camelot Carole Bayer Sager David Foster Tony Renis Alberto Testa A Soft Place to Fall The Horse Whisperer Allison Moorer Gwil Owen That'll Do Babe: Pig in the City Randy Newman Gods and Monsters Bill Condon Out of Sight Scott Frank Primary Colors Elaine May A Simple Plan Scott B. Smith The Thin Red Line Terrence Malick Shakespeare in Love Marc Norman Tom Stoppard Bulworth Warren Beatty Jeremy Pikser Life Is Beautiful Roberto Benigni Vincenzo Cerami Saving Private Ryan Robert Rodat The Truman Show Andrew Niccol Bunny Chris Wedge The Canterbury Tales Christopher Grace Jonathan Myerson Jolly Roger Mark Baker More Mark Osborne Steve Kalafer When Life Departs Karsten Kiilerich Stefan Fjeldmark Election Night (Valgaften) Kim Magnusson Anders Thomas Jensen Culture Will Speck Josh Gordon Holiday Romance Alexander Joy La Carte Postale (The Postcard) Vivian Goffette Victor Simon Sandquist Joel Bergvall Saving Private Ryan Gary Rydstrom Gary Summers Andy Nelson Ronald Judkins Armageddon Kevin O'Connell Greg P. Russell Keith A. Wester The Mask of Zorro Kevin O'Connell Greg P. Russell Pud Cusack Shakespeare in Love Robin O'Donoghue Dominic Lester Peter Glossop The Thin Red Line Andy Nelson Anna Behlmer Paul Brincat Saving Private Ryan Gary Rydstrom Richard Hymns Armageddon George Watters II The Mask of Zorro David McMoyler What Dreams May Come Joel Hynek Nicholas Brooks Stuart Robertson Kevin Mack Armageddon Richard R. Hoover Pat McClung John Frazier Mighty Joe Young Rick Baker Hoyt Yeatman Alan Hall Jim Mitchell American Beauty Kevin Spacey The Insider Russell Crowe The Straight Story Richard Farnsworth Sweet and Lowdown Sean Penn The Hurricane Denzel Washington The Cider House Rules Michael Caine Magnolia Tom Cruise The Green Mile Michael Clarke Duncan The Talented Mr. Ripley Jude Law The Sixth Sense Haley Joel Osment Boys Don't Cry Hilary Swank American Beauty Annette Bening Tumbleweeds Janet McTeer The End of the Affair Julianne Moore Music of the Heart Meryl Streep Girl, Interrupted Angelina Jolie The Sixth Sense Toni Collette Being John Malkovich Catherine Keener Sweet and Lowdown Samantha Morton Boys Don't Cry Chloe Sevigny Sleepy Hollow Rick Heinrichs Peter Young Anna and the King Luciana Arrighi Ian Whittaker The Cider House Rules David Gropman Beth Rubino The Talented Mr. Ripley Roy Walker Bruno Cesari Topsy-Turvy Eve Stewart John Bush American Beauty Bruce Cohen Dan Jinks The Cider House Rules Richard N. Gladstein The Green Mile David Valdes Frank Darabont The Insider Michael Mann Pieter Jan Brugge The Sixth Sense Frank Marshall Kathleen Kennedy Barry Mendel American Beauty Conrad L. Hall The End of the Affair Roger Pratt The Insider Dante Spinotti Sleepy Hollow Emmanuel Lubezki Snow Falling on Cedars Robert Richardson Topsy-Turvy Lindy Hemming Anna and the King Jenny Beavan Sleepy Hollow Colleen Atwood The Talented Mr. Ripley Ann Roth Gary Jones Titus Milena Canonero American Beauty Sam Mendes Being John Malkovich Spike Jonze The Cider House Rules Lasse Hallström The Insider Michael Mann The Sixth Sense M. Night Shyamalan One Day in September Arthur Cohn Kevin Macdonald Buena Vista Social Club Wim Wenders Ulrich Felsberg Genghis Blues Roko Belic Adrian Belic On the Ropes Nanette Burstein Brett Morgen Speaking in Strings Paola di Florio Lilibet Foster King Gimp Susan Hannah Hadary William A. Whiteford Eyewitness Bert Van Bork The Wildest Show in the South: The Angola Prison Rodeo Simeon Soffer Jonathan Stack The Matrix Zach Staenberg American Beauty Tariq Anwar The Cider House Rules Lisa Zeno Churgin The Insider William Goldenberg Paul Rubell David Rosenbloom The Sixth Sense Andrew Mondshein All about My Mother Spain Caravan Nepal East-West France Solomon and Gaenor United Kingdom Under the Sun Sweden Topsy-Turvy Christine Blundell Trefor Proud Austin Powers: The Spy Who Shagged Me Michèle Burke Mike Smithson Bicentennial Man Greg Cannom Life Rick Baker The Red Violin John Corigliano American Beauty Thomas Newman Angela's Ashes John Williams The Cider House Rules Rachel Portman The Talented Mr. Ripley Gabriel Yared You'll Be in My Heart Tarzan Phil Collins Blame Canada South Park: Bigger, Longer & Uncut Trey Parker Marc Shaiman Music from the Heart Music of the Heart Diane Warren Save Me Magnolia Aimee Mann When She Loved Me Toy Story 2 Randy Newman The Cider House Rules John Irving Election Alexander Payne Jim Taylor The Green Mile Frank Darabont The Insider Eric Roth Michael Mann The Talented Mr. Ripley Anthony Minghella American Beauty Alan Ball Being John Malkovich Charlie Kaufman Magnolia Paul Thomas Anderson The Sixth Sense M. Night Shyamalan Topsy-Turvy Mike Leigh The Old Man and the Sea Alexandre Petrov Humdrum Peter Peake My Grandmother Ironed the King's Shirts Torill Kove 3 Misses Paul Driessen When the Day Breaks Wendy Tilby Amanda Forbis My Mother Dreams the Satan's Disciples in New York Barbara Schock Tammy Tiehel Bror, Min Bror (Teis and Nico) Henrik Ruben Genz Michael W. Horsten Killing Joe Mehdi Norowzian Steve Wax Kleingold (Small Change) Marc-Andreas Bochert Gabriele Lins Major and Minor Miracles Marcus Olsson The Matrix John Reitz Gregg Rudloff David Campbell David Lee The Green Mile Robert J. Litt Elliot Tyson Michael Herbick Willie D. Burton The Insider Andy Nelson Doug Hemphill Lee Orloff The Mummy Leslie Shatz Chris Carpenter Rick Kline Chris Munro Star Wars: Episode I - The Phantom Menace Gary Rydstrom Tom Johnson Shawn Murphy John Midgley The Matrix Dane A. Davis Fight Club Ren Klyce Richard Hymns Star Wars: Episode I - The Phantom Menace Ben Burtt Tom Bellfort The Matrix John Gaeta Janek Sirrs Steve Courtley Jon Thum Star Wars: Episode I - The Phantom Menace John Knoll Dennis Muren Scott Squires Rob Coleman Stuart Little John Dykstra Jerome Chen Henry F. Anderson III Eric Allard Gladiator Russell Crowe Before Night Falls Javier Bardem Cast Away Tom Hanks Pollock Ed Harris Quills Geoffrey Rush Traffic Benicio Del Toro The Contender Jeff Bridges Shadow of the Vampire Willem Dafoe Erin Brockovich Albert Finney Gladiator Joaquin Phoenix Erin Brockovich Julia Roberts The Contender Joan Allen Chocolat Juliette Binoche Requiem for a Dream Ellen Burstyn You Can Count on Me Laura Linney Pollock Marcia Gay Harden Chocolat Judi Dench Almost Famous Kate Hudson Almost Famous Frances McDormand Billy Elliot Julie Walters Crouching Tiger, Hidden Dragon Tim Yip Gladiator Arthur Max Crispian Sallis How the Grinch Stole Christmas Michael Corenblith Merideth Boswell Quills Martin Childs Jill Quertier Vatel Jean Rabasse Francois Benoit-Fresco Gladiator David Franzoni Branko Lustig Douglas Wick Chocolat David Brown Kit Golden Leslie Holleran Crouching Tiger, Hidden Dragon Hsu Li Kong Bill Kong Ang Lee Erin Brockovich Danny DeVito Michael Shamberg Stacey Sher Traffic Laura Bickford Marshall Herskovitz Edward Zwick Crouching Tiger, Hidden Dragon Peter Pau Gladiator John Mathieson Maleña Lajos Koltai O Brother, Where Art Thou? Roger Deakins The Patriot Caleb Deschanel Gladiator Janty Yates 102 Dalmatians Anthony Powell Crouching Tiger, Hidden Dragon Tim Yip How the Grinch Stole Christmas Rita Ryack Quills Jacqueline West Traffic Steven Soderbergh Billy Elliot Stephen Daldry Crouching Tiger, Hidden Dragon Ang Lee Erin Brockovich Steven Soderbergh Gladiator Ridley Scott Into the Arms of Strangers: Stories of the Kindertransport Mark Jonathan Harris Deborah Oppenheimer Legacy Tod Lending Long Night's Journey Into Day Frances Reid Deborah Hofmann Scottsboro: An American Tragedy Barak Goodman Daniel Anker Sound and Fury Josh Aronson Roger Weisberg Big Mama Tracy Seretean Curtain Call Charles Braverman Steve Kalafer Dolphins Greg MacGillivray Alec Lorimore The Man on Lincoln's Nose Daniel Raim On Tiptoe: Gentle Steps to Freedom Eric Simonson Leelai Demoz Traffic Stephen Mirrione Almost Famous Joe Hutshing Saar Klein Crouching Tiger, Hidden Dragon Tim Squyres Gladiator Pietro Scalia Wonder Boys Dede Allen Crouching Tiger, Hidden Dragon Taiwan Amores Perros Mexico Divided We Fall Czech Republic Everybody Famous Belgium The Taste of Others France How the Grinch Stole Christmas Rick Baker Gail Ryan The Cell Michèle Burke Edouard F. Henriques Shadow of the Vampire Ann Buchanan Amber Sibley Crouching Tiger, Hidden Dragon Tan Dun Chocolat Rachel Portman Gladiator Hans Zimmer Malèa Ennio Morricone The Patriot John Williams Things Have Changed Wonder Boys Bob Dylan A Fool in Love Meet the Parents Randy Newman I've Seen It All Dancer in the Dark Bjork Lars von Trier Sjon Sigurdsson A Love before Time Crouching Tiger, Hidden Dragon Jorge Calandrelli Tan Dun James Schamus My Funny Friend and Me The Emperor's New Groove Sting David Hartley Sting Traffic Stephen Gaghan Chocolat Robert Nelson Jacobs Crouching Tiger, Hidden Dragon Wang Hui Ling James Schamus Tsai Kuo Jung O Brother, Where Art Thou? Ethan Coen Joel Coen Wonder Boys Steve Kloves Almost Famous Cameron Crowe Billy Elliot Lee Hall Erin Brockovich Susannah Grant Gladiator David Franzoni John Logan William Nicholson You Can Count on Me Kenneth Lonergan Father and Daughter Michael Dudok de Wit The Periwig-Maker Steffen Schaffler Annette Schaffler Rejected Don Hertzfeldt Quiero Ser (I Want to Be...) Florian Gallenberger By Courier Peter Riegert Ericka Frederick One Day Crossing Joan Stein Christina Lazaridi Seraglio Gail Lerner Colin Campbell A Soccer Story (Uma Historia De Futebol) Paulo Machline Gladiator Scott Millan Bob Beemer Ken Weston Cast Away Randy Thom Tom Johnson Dennis S. Sands William B. Kaplan The Patriot Kevin O'Connell Greg P. Russell Lee Orloff The Perfect Storm John T. Reitz Gregg Rudloff David E. Campbell Keith A. Wester U-571 Steve Maslow Gregg Landaker Rick Kline Ivan Sharrock U-571 Jon Johnson Space Cowboys Alan Robert Murray Bub Asman Gladiator John Nelson Neil Courbould Tim Burke Rob Harvey Hollow Man Scott E. Anderson Craig Hayes Scott Stokdyk Stan Parks The Perfect Storm Stefen Fangmeier Habib Zargarpour John Frazier Walt Conti Training Day Denzel Washington A Beautiful Mind Russell Crowe I Am Sam Sean Penn Ali Will Smith In the Bedroom Tom Wilkinson Iris Jim Broadbent Training Day Ethan Hawke Sexy Beast Ben Kingsley The Lord of the Rings: The Fellowship of the Ring Ian McKellen Ali Jon Voight Monster's Ball Halle Berry Iris Judi Dench Moulin Rouge Nicole Kidman In the Bedroom Sissy Spacek Bridget Jones' Diary Renee Zellweger A Beautiful Mind Jennifer Connelly Gosford Park Helen Mirren Gosford Park Maggie Smith In the Bedroom Marisa Tomei Iris Kate Winslet Shrek Aron Warner Jimmy Neutron: Boy Genius Steve Oedekerk John A. Davis Monsters, Inc. Pete Docter John Lasseter Moulin Rouge Catherine Martin Brigitte Broch Amélie Aline Bonetto Marie-Laure Valla Gosford Park Stephen Altman Anna Pinnock Harry Potter and the Sorcerer's Stone Stuart Craig Stephenie McMillan The Lord of the Rings: The Fellowship of the Ring Grant Major Dan Hennah A Beautiful Mind Brian Grazer Ron Howard Gosford Park Robert Altman Bob Balaban David Levy In the Bedroom Graham Leader Ross Katz Todd Field The Lord of the Rings: The Fellowship of the Ring Peter Jackson Fran Walsh Barrie M. Osborne Moulin Rouge Martin Brown Baz Luhrmann Fred Baron The Lord of the Rings: The Fellowship of the Ring Andrew Lesnie Amélie Bruno Delbonnel Black Hawk Down Slawomir Idziak The Man Who Wasn't There Roger Deakins Moulin Rouge Donald M. McAlpine Moulin Rouge Catherine Martin Angus Strathie The Affair of the Necklace Milena Canonero Gosford Park Jenny Beavan Harry Potter and the Sorcerer's Stone Judianna Makovsky The Lord of the Rings: The Fellowship of the Ring Ngila Dickson Richard Taylor A Beautiful Mind Ron Howard Black Hawk Down Ridley Scott Gosford Park Robert Altman The Lord of the Rings: The Fellowship of the Ring Peter Jackson Mulholland Drive David Lynch Murder on a Sunday Morning Jean-Xavier de Lestrade Denis Poncet Children Underground Edet Belzberg Lalee's Kin: The Legacy of Cotton Susan Froemke Deborah Dickson Promises Justine Shapiro B.Z. Goldberg War Photographer Christian Frei Thoth Sarah Kernochan Lynn Appelle Artists and Orphans: A True Drama Lianne Klapper McNally Sing! Freida Lee Mock Jessica Sanders Black Hawk Down Pietro Scalia A Beautiful Mind Mike Hill Dan Hanley The Lord of the Rings: The Fellowship of the Ring John Gilbert Memento Dody Dorn Moulin Rouge Jill Bilcock No Man's Land Bosnia & Herzegovina Son of the Bride Argentina Amélie France Elling Norway Lagaan India The Lord of the Rings: The Fellowship of the Ring Peter Owen Richard Taylor A Beautiful Mind Greg Cannom Colleen Callaghan Moulin Rouge Maurizio Silvi Aldo Signoretti The Lord of the Rings: The Fellowship of the Ring Howard Shore A.I. Artificial Intelligence John Williams A Beautiful Mind James Horner Harry Potter and the Sorcerer's Stone John Williams Monsters, Inc. Randy Newman If I Didn't Have You Monsters, Inc. Randy Newman May It Be The Lord of the Rings: The Fellowship of the Ring Enya Nicky Ryan Roma Ryan There You'll Be Pearl Harbor Diane Warren Until Kate & Leopold Sting Vanilla Sky Vanilla Sky Paul McCartney A Beautiful Mind Akiva Goldsman Ghost World Daniel Clowes Terry Zwigoff In the Bedroom Rob Festinger Todd Field The Lord of the Rings: The Fellowship of the Ring Fran Walsh Philippa Boyens Peter Jackson Shrek Ted Elliott Terry Rossio Joe Stillman Roger S.H. Schulman Gosford Park Julian Fellowes Amélie Guillaume Laurant Jean-Pierre Jeunet Memento Christopher Nolan Jonathan Nolan Monster's Ball Milo Addica Will Rokos The Royal Tenenbaums Wes Anderson Owen Wilson For the Birds Ralph Eggleston Fifty Percent Grey Ruairi Robinson Seamus Byrne Giv Up Yer Aul Sins Cathal Gaffney Darragh O'Connell Strange Invaders Cordell Barker Stubble Trouble Joseph E. Merideth The Accountant Ray McKinnon Lisa Blount Copy Shop Virgil Widrich Gregor's Greatest Invention Johannes Kiefer A Man Thing (Meska Sprawa) Slawomir Fabicki Bogumil Godfrejow Speed for Thespians Kalman Apple Shameela Bakhsh Black Hawk Down Michael Minkler Myron Nettinga Chris Munro Amélie Vincent Arnardi Guillaume Leriche Jean Umansky The Lord of the Rings: The Fellowship of the Ring Christopher Boyes Michael Semanick Gethin Creagh Hammond Peek Moulin Rouge Andy Nelson Anna Behlmer Roger Savage Guntis Sics Pearl Harbor Kevin O'Connell Greg P. Russell Peter J. Devlin Pearl Harbor George Watters II Christopher Boyes Monsters, Inc. Gary Rydstrom Michael Silvers The Lord of the Rings: The Fellowship of the Ring Jim Rygiel Randall William Cook Richard Taylor Mark Stetson A.I. Artificial Intelligence Dennis Muren Scott Farrar Stan Winston Michael Lantieri Pearl Harbor Eric Brevig John Frazier Ed Hirsh Ben Snow The Pianist Adrien Brody Adaptation Nicolas Cage The Quiet American Michael Caine Gangs of New York Daniel Day-Lewis About Schmidt Jack Nicholson Adaptation Chris Cooper The Hours Ed Harris Road to Perdition Paul Newman Chicago John C. Reilly Catch Me If You Can Christopher Walken The Hours Nicole Kidman Frida Salma Hayek Unfaithful Diane Lane Far from Heaven Julianne Moore Chicago Renee Zellweger Chicago Catherine Zeta-Jones About Schmidt Kathy Bates The Hours Julianne Moore Chicago Queen Latifah Adaptation Meryl Streep Chicago John Myhre Gord Sim Frida Felipe Fernandez del Paso Hannia Robledo Gangs of New York Dante Ferretti Francesca Lo Schiavo The Lord of the Rings: The Two Towers Grant Major Dan Hennah Alan Lee Road to Perdition Dennis Gassner Nancy Haigh Chicago Martin Richards Gangs of New York Alberto Grimaldi Harvey Weinstein The Hours Scott Rudin Robert Fox The Lord of the Rings: The Two Towers Barrie M. Osborne Fran Walsh Peter Jackson The Pianist Roman Polanski Robert Benmussa Alain Sarde Road to Perdition Conrad L. Hall Chicago Dion Beebe Far from Heaven Edward Lachman Gangs of New York Michael Ballhaus The Pianist Pawel Edelman Chicago Colleen Atwood Frida Julie Weiss Gangs of New York Sandy Powell The Hours Ann Roth The Pianist Anna Sheppard The Pianist Roman Polanski Chicago Rob Marshall Gangs of New York Martin Scorsese The Hours Stephen Daldry Talk to Her Pedro Almodovar Bowling for Columbine Michael Moore Michael Donovan Daughter from Danang Gail Dolgin Vincente Franco Prisoner of Paradise Malcolm Clarke Stuart Sender Spellbound Jeffrey Blitz Sean Welch Winged Migration Jacques Perrin Twin Towers Bill Guttentag Robert David Port The Collector of Bedford Street Alice Elliott Mighty Times: The Legacy of Rosa Parks Robert Hudson Bobby Houston Why Can't We Be a Family Again? Roger Weisberg Murray Nossel Chicago Martin Walsh Gangs of New York Thelma Schoonmaker The Hours Peter Boyle The Lord of the Rings: The Two Towers Michael Horton The Pianist Hervé de Luze Nowhere in Africa Germany El Crimen Del Padre Amaro Mexico Hero China The Man Without a Past Finland Zus & Zo The Netherlands Frida John Jackson Beatrice De Alba The Time Machine John M. Elliott Jr Barbara Lorenz Frida Elliot Goldenthal Catch Me If You Can John Williams Far from Heaven Elmer Bernstein The Hours Philip Glass Road to Perdition Thomas Newman Lose Yourself 8 Mile Eminem Jeff Bass Luis Resto Burn It Blue Frida Elliot Goldenthal Julie Taymor Father and Daughter The Wild Thornberrys Movie Paul Simon The Hands That Built America Gangs of New York Bono The Edge Adam Clayton Larry Mullen I Move on Chicago John Kander Fred Ebb The Pianist Ronald Harwood About a Boy Peter Hedges Chris Weitz Paul Weitz Adaptation Charlie Kaufman Donald Kaufman Chicago Bill Condon The Hours David Hare Talk to Her Pedro Almodóvar Far from Heaven Todd Haynes Gangs of New York Jay Cocks Steven Zaillian Kenneth Lonergan My Big Fat Greek Wedding Nia Vardalos Y Tu Mama También Carlos Cuarón Alfonso Cuarón The Chubbchubbs! Eric Armstrong The Cathedral Tomek Baginski Das Rad Chris Stenner Heidi Wittlinger Mike's New Car Pete Docter Roger Gould Mt. Head Koji Yamamura This Charming Man (Der Er En Yndig Mand) Martin Strange-Hansen Mie Andreason Fait D'Hiver Dirk Beliën Anja Daelmans I'll Wait for the Next One... (J'attendrai Le Suivant...) Philippe Orreindy Thomas Gaudin Inja (Dog) Steven Pasvolsky Joe Weatherstone Johnny Flynton Lexi Alexander Alexander Buono Chicago Michael Minkler Dominick Tavella David Lee Gangs of New York Tom Fleischman Eugene Gearty Ivan Sharrock The Lord of the Rings: The Two Towers Christopher Boyes Michael Semanick Michael Hedges Hammond Peek Road to Perdition Scott Millan Bob Beemer John Patrick Pritchett Spider-Man Kevin O'Connell Greg P. Russell Ed Novick The Lord of the Rings: The Two Towers Ethan Van der Ryn Michael Hopkins Minority Report. Richard Hymns Gary Rydstrom Road to Perdition Scott A. Hecker The Lord of the Rings: The Two Towers Jim Rygiel Joe Letteri Randall William Cook Alex Funke Spider-Man John Dykstra Scott Stokdyk Anthony LaMolinara John Frazier Star Wars: Episode II - Attack of the Clones Rob Coleman Pablo Helman John Knoll Ben Snow Mystic River Sean Penn Pirates of the Caribbean: The Curse of the Black Pearl Johnny Depp House of Sand and Fog Ben Kinsgley Cold Mountain Jude Law Lost in Translation Bill Murray Mystic River Tim Robbins The Cooler Alec Baldwin 21 Grams Benicio Del Toro In America Djimon Hounsou The Last Samurai Ken Watanabe Monster Charlize Theron Whale Rider Keisha Castle-Hughes Something's Gotta Give Diane Keaton In America Samantha Morton 21 Grams Naomi Watts Cold Mountain Renee Zellweger House of Sand and Fog Shoreh Aghdashloo Pieces of April Patricia Clarkson Mystic River Marcia Gay Harden Thirteen Holly Hunter Finding Nemo Andrew Stanton Brother Bear Aaron Blaise Robert Walker The Triplets of Belleville Sylvain Chomet The Lord of the Rings: The Return of the King Grant Major Dan Hennah Alan Lee Girl with a Pearl Earring Ben Van Os Cecile Heideman The Last Samurai Lilly Kilvert Gretchen Rau Master and Commander: The Far Side of the World William Sandell Robert Gould Seabiscuit Jeannine Oppewall Leslie Pope The Lord of the Rings: The Return of the King Barrie M. Osborne Peter Jackson Fran Walsh Lost in Translation Ross Katz Sofia Coppola Master and Commander: The Far Side of the World Samuel Goldwyn Jr. Peter Weir Duncan Henderson Mystic River Robert Lorenz Judie G. Hoyt Clint Eastwood Seabiscuit Kathleen Kennedy Frank Marshall Gary Ross Master and Commander: The Far Side of the World Russell Boyd City of God Cesar Charlone Cold Mountain John Seale Girl with a Pearl Earring Eduardo Serra Seabiscuit John Schwartzman The Lord of the Rings: The Return of the King Ngila Dickson Richard Taylor Girl with a Pearl Earring Dien van Straalen The Last Samurai Ngila Dickson Master and Commander: The Far Side of the World Wendy Stiles Seabiscuit Judianna Makovsky The Lord of the Rings: The Return of the King Peter Jackson City of God Fernando Meirelles Lost in Translation Sofia Coppola Master and Commander: The Far Side of the World Peter Weir Mystic River Clint Eastwood The Fog of War Errol Morris Michael Williams Balseros Carlos Bosch Josep Maria Domenech Capturing the Friedmans Andrew Jarecki Marc Smerling My Architect Nathaniel Kahn Susan R. Behr The Weather Underground Sam Green Bill Sigeel Chernobyl Heart Maryann DeLeo Asylum Sandy McLeod Gini Reticker Ferry Tales Katja Esson The Lord of the Rings: The Return of the King Jamie Selkirk City of God Daniel Rezende Cold Mountain Walter Murch Master and Commander: The Far Side of the World Lee Smith Seabiscuit William Goldenberg The Barbarian Invasions Canada Evil Sweden The Twilight Samurai Japan Twin Sisters The Netherlands Zelary Czech Republic The Lord of the Rings: The Return of the King Richard Taylor Peter King Master and Commander: The Far Side of the World Edouard Henriques III Yolanda Toussieng Pirates of the Caribbean: The Curse of the Black Pearl Ve Neill Martin Samuel The Lord of the Rings: The Return of the King Howard Shore Big Fish Danny Elfman Cold Mountain Gabriel Yared Finding Nemo Thomas Newman House of Sand and Fog James Horner Into the West The Lord of the Rings: The Return of the King Fran Walsh Howard Shore Annie Lennox Belleville Rendez-vous The Triplets of Belleville Benoit Charest Sylvain Chomet A Kiss at the End of the Rainbow A Mighty Wind Michael McKean Annette O'Toole Scarlet Tide Cold Mountain T Bone Burnett Elvis Costello You Will Be My Ain True Love Cold Mountain Sting The Lord of the Rings: The Return of the King Fran Walsh Philippa Boyens Peter Jackson American Splendor Robert Pulcini Shari Springer Berman City of God Braulio Mantovani Mystic River Brian Helgeland Seabiscuit Gary Ross Lost in Translation Sofia Coppola The Barbarian Invasions Denys Arcand Dirty Pretty Things SteveN Knight Finding Nemo Andrew Stanton Bob Peterson David Reynolds In America Jim Sheridan Naomi Sheridan Kirsten Sheridan Harvie Krumpet Adam Elliot Boundin' Bud Luckey Destino Dominique Monfery Roy Edward Disney Gone Nutty Carlos Saldanha John C. Donkin Nibbles Chris Hinton Two Soldiers Aaron Schneider Andrew J. Sacks Die Rote Jacke (The Red Jacket) Florian Baxmeyer Most (The Bridge) Bobby Garabedian William Zabka Squash Lionel Bailliu (A) Torzija [(A) Torsion] Stefan Arsenijevic The Lord of the Rings: The Return of the King Christopher Boyes Michael Semanick Michael Hedges Hammond Peek The Last Samurai Andy Nelson Anna Behlmer Jeff Wexler Master and Commander: The Far Side of the World Paul Massey D.M. Hemphill Arthur Rochester Pirates of the Caribbean: The Curse of the Black Pearl Christopher Boyes David Parker David Campbell Lee Orloff Seabiscuit Andy Nelson Anna Bahlmer Tod A. Maitland Master and Commander: The Far Side of the World Richard King Finding Nemo Gary Rydstrom Michael Silvers Pirates of the Caribbean: The Curse of the Black Pearl Christopher Boyes George Watters II The Lord of the Rings: The Return of the King Jim Rygiel Joe Letteri Randall William Cook Alex Funke Master and Commander: The Far Side of the World Dan Sudick Stefan Fangmeier Nathan McGuinness Robert Stromberg Pirates of the Caribbean: The Curse of the Black Pearl John Knoll Hal Hickel Charles Gibson Terry Frazee Ray Jamie Foxx Hotel Rwanda Don Cheadle Finding Neverland Johnny Depp The Aviator Leonardo DiCaprio Million Dollar Baby Clint Eastwood Million Dollar Baby Morgan Freeman The Aviator Alan Alda Sideways Thomas Haden Church Collateral Jamie Foxx Closer Clive Owen Million Dollar Baby Hilary Swank Being Julia Annette Bening Maria Full of Grace Catalina Sandino Moreno Vera Drake Imelda Staunton Eternal Sunshine of the Spotless Mind Kate Winslet The Aviator Cate Blanchett Kinsey Laura Linney Sideways Virginia Madsen Hotel Rwanda Sophie Okonedo Closer Natalie Portman The Incredibles Brad Bird Shark Tale Bill Damaschke Shrek 2 Andrew Adamson The Aviator Dante Ferretti Francesca Lo Schiavo Finding Neverland Gemma Jackson Trisha Edwards Lemony Snicket's a Series of Unfortunate Events Rick Heinrichs Cheryl Carasik The Phantom of the Opera Anthony Pratt Celia Bobak A Very Long Engagement Aline Bonetto Million Dollar Baby Clint Eastwood Albert S. Ruddy Tom Rosenberg The Aviator Michael Mann Graham King Finding Neverland Richard N. Gladstein Nellie Bellflower Ray Taylor Hackford Stuart Benjamin Howard Baldwin Sideways Michael London The Aviator Robert Richardson House of Flying Daggers Zhao Xiaoding The Passion of the Christ Caleb Deschanel The Phantom of the Opera John Mathieson A Very Long Engagement Bruno Delbonnel The Aviator Sandy Powell Finding Neverland Alexandra Byrne Lemony Snicket's a Series of Unfortunate Events Colleen Atwood Ray Sharen Davis Troy Bob Ringwood Million Dollar Baby Clint Eastwood The Aviator Martin Scorsese Ray Taylor Hackford Sideways Alexander Payne Vera Drake Mike Leigh Born Into Brothels Ross Kauffman Zana Briski The Story of the Weeping Camel Luigi Falorni Byambasuren Davaa Super Size Me Morgan Spurlock Tupac: Resurrection Lauren Lazin Karolyn Ali Twist of Faith Kirby Dick Eddie Schmidt Mighty Times: The Children's March Robert Hudson Bobby Houston Autism Is a World Gerardine Wurzburg The Children of Leningradsky Hannah Polak Andrzej Celinski Hardwood Hubert Davis Erin Faith Young Sister Rose's Passion Oren Jacoby Steve Kalafer The Aviator Thelma Schoonmaker Collateral Jim Miller Paul Rubell Finding Neverland Matt Chesse Million Dollar Baby Joel Cox Ray Paul Hirsch The Sea Inside Spain As It Is in Heaven Sweden The Chorus France Downfall Germany Yesterday South Africa Lemony Snicket's a Series of Unfortunate Events Valli O'Reilly Bill Corso The Passion of the Christ Keith Vanderlaan Christien Tinsley The Sea Inside Jo Allen Manuel Garcia Finding Neverland Jan A.P. Kaczmarek Harry Potter and the Prisoner of Azkaban John Williams Lemony Snicket's a Series of Unfortunate Events Thomas Newman The Passion of the Christ John Debney The Village James Newton Howard Al Otro Lado del Rio The Motorcycle Diaries Jorge Drexler Accidentally in Love Shrek 2 Adam Duritz Charles Gillingham Jim Bogios David Immergluck Matthew Malley David Bryson Daniel Vickrey Believe The Polar Express Glen Ballard Alan Silvestri Learn to Be Lonely The Phantom of the Opera Andrew Lloyd Webber Charles Hart Look to Your Path (Vois Sur Ton Chemin) The Chorus Bruno Coulai Christophe Barratier Sideways Alexander Payne Jim Taylor Before Sunset Richard Linklater Julie Delpy Ethan Hawke Kim Krizan Finding Neverland David Magee Million Dollar Baby Paul Haggis The Motorcycle Diaries José Rivera Eternal Sunshine of the Spotless Mind Charlie Kaufman Michel Gondry Pierre Bismuth The Aviator John Logan Hotel Rwanda Keir Pearson Terry George The Incredibles Brad Bird Vera Drake Mike Leigh Ryan Chris Landreth Birthday Boy Sejong Park Andrew Gregory Gopher Broke Jeff Fowler Tim Miller Guard Dog Bill Plympton Lorenzo Mike Gabriel Baker Bloodworth Wasp Andrea Arnold Everything in This Country Must Gary McKendry Little Terrorist Ashvin Kumar 7:35 in the Morning Nacho Vigalondo Two Cars, One Night Taika Waititi Ainsley Gardiner Ray Scott Millan Greg Orloff Bob Beemer Steve Cantamessa The Aviator Tom Fleischman Petur Hiddal The Incredibles Randy Thom Gary A. Rizzo Doc Kane The Polar Express Randy Thom Tom Johnson Dennis Sands William B. Kaplan Spider-Man 2 Kevin O'Connell Greg P. Russell Jeffrey J. Haboush Joseph Geisinger The Incredibles Michael Silvers Randy Thom The Polar Express Randy Thom Dennis Leonard Spider-Man 2 Paul N.J. Ottosson Spider-Man 2 John Dykstra Scott Stokdyk Anthony LaMolinara John Frazier Harry Potter and the Prisoner of Azkaban Roger Guyett Tim Burke John Richardson Bill George I, Robot John Nelson Andrew R. Jones Erik Nash Joe Letteri Capote Philip Seymour Hoffman Hustle & Flow Terrence Howard Brokeback Mountain Heath Ledger Walk the Line Joaquin Phoenix Good Night, and Good Luck. David Strathairn Syriana George Clooney Crash Matt Dillon Cinderella Man Paul Giamatti Brokeback Mountain Jake Gyllenhaal A History of Violence William Hurt Walk the Line Reese Witherspoon Mrs. Henderson Presents Judi Dench Transamerica Felicity Huffman Pride & Prejudice Keira Knightley North Country Charlize Theron The Constant Gardner Rachel Weisz Junebug Amy Adams Capote Catherine Keener North Country Frances McDormand Brokeback Mountain Michelle Williams Wallace & Gromit in the Curse of the Were-Rabbit Nick Park Steve Box Howl's Moving Castle Hayao Miyazaki Tim Burton's Corpse Bride Mike Johnson Tim Burton Wallace & Gromit in the Curse of the Were-Rabbit Nick Park Steve Box Memoirs of a Geisha John Myhre Gretchen Rau Good Night, and Good Luck. Jim Bissell Jan Pascale Harry Potter and the Goblet of Fire Stuart Craig Stephenie McMillan King Kong Grant Major Dan Hennah Simon Bright Pride & Prejudice Sarah Greenwood Katie Spencer Crash Paul Haggis Cathy Schulman Brokeback Mountain Diana Ossana Names Schamus Capote Caroline Baron William Vince Michael Ohoven Good Night, and Good Luck. Grant Heslov Munich Kathleen Kennedy Steven Spielberg Barry Mendel Memoirs of a Geisha Dion Beebe Batman Begins Wally Pfister Brokeback Mountain Rodrigo Prieto Good Night, and Good Luck. Robert Elswit The New World Emmanuel Lubezki Memoirs of a Geisha Colleen Atwood Charlie and the Chocolate Factory Gabriella Pescucci Mrs. Henderson Presents Sandy Powell Pride & Prejudice Jacqueline Durran Walk the Line Arianne Phillips Brokeback Mountain Ang Lee Capote Bennett Miller Crash Paul Haggis Good Night, and Good Luck. George Clooney Munich Steven Spielberg March of the Penguins Luc Jacquet Yves Darondeau Darwin?s Nightmare Hubert Sauper Enron: The Smartest Guys in the Room Alex Gibney Jason Kliot Murderball Henry-Alex Rubin Dana Adam Shapiro Street Fight Marshall Curry A Note of Triumph: The Golden Age of Norman Corwin Corinne Marrinan Eric Simonson The Death of Kevin Carter: Casualty of the Bang Bang Club Dan Krauss God Sleeps in Rwanda Kimberlee Acquaro Stacy Sherman The Mushroom Club Steven Okazaki Crash Hughes Winborne Cinderella Man Mike Hill Dan Hanley The Constant Gardner Claire Simpson Munich Michael Kahn Walk the Line Michael McCusker Tsotsi South Africa Don't Tell Italy Joyeaux Noël France Paradise Now Palestine Sophie Scholl - The Final Days Germany The Chronicles of Narnia: The Lion, the Witch and the Wardrobe Howard Berger Tami Lane Cinderella Man David Leroy Anderson Lance Anderson Star Wars: Episode III Revenge of the Sith Dave Elsey Nikki Gooley Brokeback Mountain Gustavo Santaolalla The Constant Gardener Alberto Iglesias Memoirs of a Geisha John Williams Munich John Williams Pride & Prejudice Dario Marianelli It's Hard Out Here for a Pimp Hustle & Flow Jordan Houston Cedric Coleman Paul Beauregard In the Deep Crash Kathleen "Bird" York Michael Becker Travelin Thru Transamerica Dolly Parton Brokeback Mountain Larry McMurtry Diana Ossana Capote Dan Futterman The Constant Gardner Jeffrey Caine A History of Violence Josh Olson Munich Tony Kushner Eric Roth Crash Paul Haggis Bobby Moresco Good Night, and Good Luck. George Clooney Grant Heslov Match Point Woody Allen The Squid and the Whale Noah Baumbach Syriana Stephen Gaghan The Moon and the Son: An Imagined Conversation John Canemaker Peggy Stern Badgered Sharon Colman The Mysterious Geographic Explorations of Jasper Morello Anthony Lucas 9 Shane Acker One Man Band Andrew Jimenez Mark Andrews Six Shooter Martin McDonagh Ausreisser (The Runaway) Ulrike Grote Cashback Sean Ellis Lene Bausager The Last Farm Rúnar Rúnarsson Thor S. Sigurjónsson Our Time Is Up Rob Pearlstein Pia Clemente King Kong Christopher Boyes Michael Semanick Michael Hedges Hammond Peek The Chronicles of Narnia: The Lion, the Witch and the Wardrobe Terry Porter Dean A. Zupancic Tony Johnson Memoirs of a Geisha Kevin O'Connell Greg P. Russell Rick Kline John Pritchett Walk the Line Paul Massey D.M. Hemphill Peter F Kurland War of the Worlds Andy Nelson Anna Behlmer Ronald Judkins King Kong Mike Hopkins Ethan Van der Ryn Memoirs of a Geisha Wylie Stateman War of the Worlds Richard King King Kong Joe Letteri Brian Van't Hul Christian Rivers Richard Taylor The Chronicles of Narnia: The Lion, the Witch and the Wardrobe Dean Wright Bill Westenhofer Jim Berney Scott Farrar War of the Worlds Dennis Muren Pablo Helman Randal M. Dutra Daniel Sudick The Last King of Scotland Forest Whitaker Blood Diamond Leonardo DiCaprio Half Nelson Ryan Gosling Venus Peter O'Toole The Pursuit of Happyness Will Smith Little Miss Sunshine Alan Arkin Little Children Jackie Earle Haley Blood Diamond Djimon Hounsou Dreamgirls Eddie Murphy The Departed Mark Wahlberg The Queen Helen Mirren Volver Penélope Cruz Notes on a Scandal Judi Dench The Devil Wears Prada Meryl Streep Little Children Kate Winslet Dreamgirls Jennifer Hudson Babel Adriana Barraza Notes on a Scandal Cate Blanchett Little Miss Sunshine Abigail Breslin Babel Rinko Kikuchi Happy Feet George Miller Cars John Lasseter Monster House Gil Kenan Pan's Labyrinth Eugenio Caballero Pilar Revuelta Dreamgirls John Myhre Nancy Haigh The Good Shepherd Jeannine Oppewall Gretchen Rau Leslie E. Rollins Pirates of the Caribbean: Dead Man?s Chest Rick Heinrichs Cheryl Carasik The Prestige Nathan Crowley Julie Ochipinti The Departed Graham King Babel Alejandro González Iñárritu Jon Kilik Steve Golin Letters from Iwo Jima Clint Eastwood Steven Spielberg Robert Lorenz Little Miss Sunshine David T. Friendly Peter Saraf Marc Turtletaub The Queen Andy Harries Christine Langan Tracey Seaward Pan's Labyrinth Guillermo Navarro The Black Dahlia Vilmos Zsigmond Children of Men Emmanuel Lubezki The Illusionist Dick Pope The Prestige Wally Pfister Marie Antoinette Milena Canonero Curse of the Golden Flower Yee Chung Man The Devil Wears Prada Patricia Field Dreamgirls Sharen Davis The Queen Consolata Boyle The Departed Martin Scorsese Babel Alejandro González Iñárritu Letters from Iwo Jima Clint Eastwood The Queen Stephen Frears United 93 Paul Greengrass An Inconvenient Truth Davis Guggenheim Deliver Us from Evil Amy Berg Frank Donner Iraq in Fragments James Longley John Sinno Jesus Camp Heidi Ewing Rachel Grady My Country, My Country Laura Poitras Jocelyn Glatzer The Blood of Yingzhou District Ruby Yang Thomas Lennon Recyled Life Leslie Iwerks Mike Glad Rehearsing a Dream Karen Goodman Kirk Simon Two Hands Nathaniel Kahn Susan Rose Behr The Departed Thelma Schoonmaker Babel Stephen Mirrione Douglas Crise Blood Diamond Steven Rosenblum Children of Men Alex Rodriguez Alfonso Cuarón United 93 Clare Douglas Christopher Rouse Richard Pearson The Lives of Others Germany After the Wedding Denmark Days of Glory (Indigènes) Algeria Pan's Labyrinth Mexico Water Canada Pan's Labyrinth David Marti Montse Ribé Apocalypto Aldo Signoretti Vittorio Sodano Click Kazuhiro Tsuji Babel Gustavo Santaolalla The Good German Thomas Newman Notes on a Scandal Philip Glass Pan's Labyrinth Javier Navarrete The Queen Alexander Desplat I Need to Wake Up An Inconvenient Truth Melissa Etheridge Listen Dreamgirls Henry Krieger Scott Cutler Anne Preven Love You I Do Dreamgirls Henry Krieger Siedah Garrett Our Town Cars Randy Newman Patience Dreamgirls Henry Krieger Willie Reale The Departed William Monahan Borat Cultural Learnings of America for Make Benefit Glorious Nation of Kazakhstan Sacha Baron Cohen Anthony Hines Peter Baynham Dan Mazer Todd Phillips Children of Men Alfonso Cuarón Timothy J. Sexton David Arata Mark Fergus Hawk Ostby Little Children Todd Field Tom Perrotta Notes on a Scandal Patrick Marber Little Miss Sunshine Michael Arndt Bobby Moresco Babel Guillermo Arriaga Letters from Iwo Jima Iris Yamashita Pan's Labyrinth Guillermo del Toro The Queen Peter Morgan The Danish Poet Torill Kove Lifted Gary Rydstrom The Little Matchgirl Roger Allers Don Hahn Maestro Géza M. Tóth No Time for Nuts Chris Renaud Michael Thurmeier West Bank Story Ari Sandel Binta and the Great Idea (Binta Y La Gran Idea) Javier Fesser Luis Manso Éramos Pocos (One Too Many) Borja Cobeaga Helmer & Son Søren Pilmark Kim Magnusson The Saviour Pter Templeman Stuart Parkyn Dreamgirls Michael Minkler Bob Beemer Willie Burton Apocalypto Kevin O'Connell Greg P. Russell Fernando Cámara Blood Diamond Andy Nelson Anna Behlmer Ivan Sharrock Flags of Our Fathers John Reitz Dave Campbell Gregg Rudloff Walt Martin Pirates of the Caribbean: Dead Man's Chest Paul Massey Christopher Boyes Lee Orloff Letters from Iwo Jima Alan Robert Murray Bub Asman Apocalypto Sean McCormack Kami Asgar Blood Diamond Lon Bender Flags of Our Fathers Alan Robert Murray Bob Asman Pirates of the Caribbean: Dead Man's Chest Christopher Boyes George Watters II Pirates of the Caribbean: Dead Man's Chest John Knoll Hal Hickel Charles Gibson Allen Hall Poseidon Boyd Shermis Kim Libreri Chas Jarrett John Frazier Superman Returns Mark Stetson Neil Corbould Richard R. Hoover Jon Thum There Will Be Blood Daniel Day-Lewis Michael Clayton George Clooney Sweeney Todd The Demon Barber of Fleet Street Johnny Depp In the Valley of Elah Tommy Lee Jones Eastern Promises Viggo Mortensen No Country for Old Men Javier Bardem The Assassination of Jesse James by the Coward Robert Ford Casey Affleck Charlie Wilson's War Philip Seymour Hoffman Into the Wild Hal Holbrook Michael Clayton Tom Wilkinson La Vie en Rose Marion Cotillard Elizabeth: The Golden Age Cate Blanchett Away from Her Julie Christie The Savages Laura Linney Juno Ellen Page Michael Clayton Tilda Swinton I'm Not There Cate Blanchett American Gangster Ruby Dee Atonement Saoirse Ronan Gone Baby Gone Amy Ryan Ratatouille Brad Bird Persepolis Marjane Satrapi Vincent Paronnaud Surf's Up Ash Brannon Chris Buck Sweeney Todd The Demon Barber of Fleet Street Dante Ferretti Francesca Lo Schiavo American Gangster Arthur Max Beth A. Rubino Atonement Sarah Greenwood Katie Spencer The Golden Compass Dennis Gassner Anna Pinnock There Will Be Blood Jack Fisk Jim Erickson No Country for Old Men Scott Rudin Ethan Coen Joel Coen Atonement Tim Bevan Eric Fellner Paul Webster Juno Lianne Halfon Mason Novick Russell Smith Michael Clayton Sidney Pollack Jennifer Fox Kerry Orent There Will Be Blook JoAnne Sellar Paul Thomas Anderson Daniel Lupi There Will Be Blood Robert Elswit The Assassination of Jesse James by the Coward Robert Ford Roger Deakins Atonement Seamus McGarvey The Diving Bell and the Butterfly Janusz Kaminski No Country for Old Men Roger Deakins Elizabeth: The Golden Age Alexandra Byrne Across The Universe Albert Wolsky Atonement Jacqueline Durran La Vie en Rose Marit Allen Sweeney Todd The Demon Barber of Fleet Street Colleen Atwood No Country for Old Men Joel Coen Ethan Coen The Diving Bell and the Butterfly Julian Schnabel Juno Jason Reitman Michael Clayton Tony Gilroy There Will Be Blood Paul Thomas Anderson Taxi to the Dark Side Alex Gibney Eva Omer No End in Sight Charles Ferguson Audrey Marrs Operation Homecoming: Writing the Wartime Experience Richard E. Robbins Sicko Michael Moore Meghan O'Hara War/Dance Andrea Nix Fine Sean Fine Freeheld Cynthia Wade Vanessa Roth La Corona (The Crown) Amanda Micheli Isabel Vega Salim Baba Tim Sternberg Francisco Bello Sari's Mother James Longley The Bourne Ultimatum Christopher Rouse The Diving Bell and the Butterfly Juliette Welfling Into the Wild Jay Cassidy No Country for Old Men Roderick Jaynes There Will Be Blood Roderick Jaynes Dylan Tichenor The Counterfeiters Austria Beaufort Israel Katyń Poland Mongol Kazakhstan 12 Russia La Vie en Rose Didier Lavergne Jan Archibald Norbit Rick Baker Kazuhiro Tsuji Pirates of the Caribbean: At World's End Ve Neill Martin Samuel Atonement Dario Marianelli The Kite Runner Alberto Iglesias Michael Clayton James Newton Howard Ratatouille Michael Giacchino 3:10 to Yuma Marco Beltrami Falling Slowly Once Glen Hansard Marketa Irglova Happy Working Song Enchanted Alan Menken Stephen Schwartz Raise It Up August Rush Jamal Joseph Charles Mack Tevin Thomas So Close Enchanted Alan Menken Stephen Schwartz That's How You Know Enchanted Alan Menken Stephen Schwartz No Country for Old Men Joel Coen Ethan Coen Atonement Christopher Hampton Away from Her Sarah Polley The Diving Bell and the Butterfly Ronald Harwood There Will Be Blood Paul Thomas Anderson Juno Diablo Cody Lars and the Real Girl Nancy Oliver Michael Clayton Tony Gilroy Ratatouille Jan Pinkava Jim Capobianco Brad Bird The Savages Tamara Jenkins Peter & the Wolf Suzie Templeton Hugh Welchman I Met the Walrus Josh Raskin Madame Tutli-Putli Chris Lavis Maciek Szczerbowski Même les Pigeons Vont au Paradis (Even Pigeons Go to Heaven) Samuel Tourneux Simon Vanesse My Love (Moya Lyubov) Alexander Petrov Le Mozart des Pickpockets (The Mozart of Pickpockets) Philippe Pollet-Villard At Night Christian E. Christiansen Louise Vesth Il Supplente (The Substitute) Andrea Jublin Tanghi Argentini Guido Thys Anja Daelemans The Tonto Woman Daniel Barber Matthew Brown The Bourne Ultimatum Scott Millan David Parker Kirk Francis No Country for Old Men Skip Lievsay Craig Berkey Greg Orloff Peter Kurland Ratatouille Randy Thorn Michael Semanick Doc Kane 3:10 to Yuma Paul Massey David Giammarco Jim Stuebe Transformers Kevin O'Connell Greg P. Russell Peter J. Devlin The Bourne Ultimatum Karen Baker Landers Per Hallberg No Country for Old Men Skip Lievsay Ratatouille Randy Thorn Michael Silvers There Will Be Blood Christopher Scarabosio Matthew Wood Transformer Ethan Van der Ryn Mike Hopkins The Golden Compass Michael Fink Bill Westenhofer Ben Morris Trevor Wood Pirates of the Caribbean: At World's End John Knoll Charles Gibson John Frazier Transformer Scott Farrar Scott Benza Russell Earl John Frazier
\ No newline at end of file diff --git a/swingset3/com/sun/swingset3/demos/textfield/JHistoryTextField.java b/swingset3/com/sun/swingset3/demos/textfield/JHistoryTextField.java new file mode 100644 index 0000000..cdd67cf --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/textfield/JHistoryTextField.java @@ -0,0 +1,266 @@ +/* + * 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.demos.textfield; + +import java.awt.*; +import java.awt.event.*; +import java.util.*; +import java.util.List; +import javax.swing.*; +import javax.swing.border.LineBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/** + * JHistoryTextField + * + * @author Pavel Porvatov + */ +public class JHistoryTextField extends JTextField { + private static final int MAX_VISIBLE_ROWS = 8; + + private final List history = new ArrayList(); + + private final JPopupMenu popup = new JPopupMenu() { + public Dimension getPreferredSize() { + Dimension dimension = super.getPreferredSize(); + + dimension.width = JHistoryTextField.this.getWidth(); + + return dimension; + } + }; + + private final JList list = new JList(new DefaultListModel()); + + private String userText; + + private boolean notificationDenied; + + public JHistoryTextField() { + JScrollPane scrollPane = new JScrollPane(list, + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.setHorizontalScrollBar(null); + scrollPane.setBorder(null); + + list.setFocusable(false); + + popup.add(scrollPane); + popup.setFocusable(false); + popup.setBorder(new LineBorder(Color.BLACK, 1)); + + getDocument().addDocumentListener(new DocumentListener() { + public void insertUpdate(DocumentEvent e) { + onTextChanged(); + } + + public void removeUpdate(DocumentEvent e) { + onTextChanged(); + } + + public void changedUpdate(DocumentEvent e) { + onTextChanged(); + } + }); + + list.addMouseMotionListener(new MouseAdapter() { + public void mouseMoved(MouseEvent e) { + int index = list.locationToIndex(e.getPoint()); + + if (index >= 0 && list.getSelectedIndex() != index) { + list.setSelectedIndex(index); + } + } + }); + + list.addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e)) { + setTextWithoutNotification((String) list.getSelectedValue()); + + popup.setVisible(false); + } + } + }); + + addFocusListener(new FocusAdapter() { + public void focusLost(FocusEvent e) { + popup.setVisible(false); + } + }); + + addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (popup.isShowing()) { + switch (e.getKeyCode()) { + case KeyEvent.VK_UP: { + changeListSelectedIndex(-1); + + break; + } + + case KeyEvent.VK_PAGE_UP: { + changeListSelectedIndex(-list.getVisibleRowCount()); + + break; + } + + case KeyEvent.VK_DOWN: { + changeListSelectedIndex(1); + + break; + } + + case KeyEvent.VK_PAGE_DOWN: { + changeListSelectedIndex(list.getVisibleRowCount()); + + break; + } + + case KeyEvent.VK_ESCAPE: { + popup.setVisible(false); + + setTextWithoutNotification(userText); + + break; + } + + case KeyEvent.VK_ENTER: + case KeyEvent.VK_LEFT: + case KeyEvent.VK_RIGHT: { + popup.setVisible(false); + + break; + } + } + } else { + if (e.getKeyCode() == KeyEvent.VK_DOWN || + e.getKeyCode() == KeyEvent.VK_UP || + e.getKeyCode() == KeyEvent.VK_PAGE_UP || + e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) { + userText = getText(); + + showFilteredHistory(); + } + } + } + }); + } + + private void changeListSelectedIndex(int delta) { + int size = list.getModel().getSize(); + int index = list.getSelectedIndex(); + + int newIndex; + + if (index < 0) { + newIndex = delta > 0 ? 0 : size - 1; + } else { + newIndex = index + delta; + } + + if (newIndex >= size || newIndex < 0) { + newIndex = newIndex < 0 ? 0 : size - 1; + + if (index == newIndex) { + newIndex = -1; + } + } + + if (newIndex < 0) { + list.getSelectionModel().clearSelection(); + list.ensureIndexIsVisible(0); + + setTextWithoutNotification(userText); + } else { + list.setSelectedIndex(newIndex); + list.ensureIndexIsVisible(newIndex); + + setTextWithoutNotification((String) list.getSelectedValue()); + } + } + + private void setTextWithoutNotification(String text) { + notificationDenied = true; + + try { + setText(text); + } finally { + notificationDenied = false; + } + } + + private void onTextChanged() { + if (!notificationDenied) { + userText = getText(); + + showFilteredHistory(); + } + } + + private void showFilteredHistory() { + list.getSelectionModel().clearSelection(); + + DefaultListModel model = (DefaultListModel) list.getModel(); + + model.clear(); + + for (String s : history) { + if (s.contains(userText)) { + model.addElement(s); + } + } + + int size = model.size(); + + if (size == 0) { + popup.setVisible(false); + } else { + list.setVisibleRowCount(size < MAX_VISIBLE_ROWS ? size : MAX_VISIBLE_ROWS); + + popup.pack(); + + if (!popup.isShowing()) { + popup.show(JHistoryTextField.this, 0, getHeight()); + } + } + } + + public List getHistory() { + return Collections.unmodifiableList(history); + } + + public void setHistory(List history) { + this.history.clear(); + this.history.addAll(history); + } +} diff --git a/swingset3/com/sun/swingset3/demos/textfield/TextFieldDemo.java b/swingset3/com/sun/swingset3/demos/textfield/TextFieldDemo.java new file mode 100644 index 0000000..02eba77 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/textfield/TextFieldDemo.java @@ -0,0 +1,177 @@ +/* + * 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.demos.textfield; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.*; +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import com.sun.swingset3.demos.JGridPanel; +import com.sun.swingset3.demos.ResourceManager; +import com.sun.swingset3.DemoProperties; + +/** + * JTextField Demo + * + * @author Pavel Porvatov + */ +@DemoProperties( + value = "TextField Demo", + category = "Text", + description = "Demonstrates the JTextField, a control which allows to input text", + sourceFiles = { + "com/sun/swingset3/demos/textfield/TextFieldDemo.java", + "com/sun/swingset3/demos/textfield/JHistoryTextField.java", + "com/sun/swingset3/demos/JGridPanel.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/textfield/resources/TextFieldDemo.properties", + "com/sun/swingset3/demos/textfield/resources/images/TextFieldDemo.gif" + } +) +public class TextFieldDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final JLabel lbHistoryTextField = new JLabel(resourceManager.getString("TextFieldDemo.historytextfield.text")); + + private final JHistoryTextField tfHistory = new JHistoryTextField(); + + private final JLabel lbDow = new JLabel(resourceManager.getString("TextFieldDemo.dow.text")); + + private final JFormattedTextField tfDow = new JFormattedTextField(); + + private final JButton btnGo = new JButton(resourceManager.getString("TextFieldDemo.go.text")); + + private final JLabel lbDowResult = new JLabel(); + + private final JLabel lbPassword = new JLabel(resourceManager.getString("TextFieldDemo.password.text")); + + private final JPasswordField tfPassword1 = new JPasswordField(20); + + private final JPasswordField tfPassword2 = new JPasswordField(20); + + private final DocumentListener passwordListener = new DocumentListener() { + public void insertUpdate(DocumentEvent e) { + highlightPasswords(); + } + + public void removeUpdate(DocumentEvent e) { + highlightPasswords(); + } + + public void changedUpdate(DocumentEvent e) { + highlightPasswords(); + } + + private void highlightPasswords() { + Color color; + + if (tfPassword1.getPassword().length > 0 && + Arrays.equals(tfPassword1.getPassword(), tfPassword2.getPassword())) { + color = Color.GREEN; + } else { + color = UIManager.getColor("TextField.background"); + } + + tfPassword1.setBackground(color); + tfPassword2.setBackground(color); + } + }; + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(TextFieldDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new TextFieldDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public TextFieldDemo() { + setLayout(new BorderLayout()); + + initUI(); + + tfDow.setValue(new Date()); + + btnGo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Calendar calendar = Calendar.getInstance(Locale.ENGLISH); + + calendar.setTime((Date) tfDow.getValue()); + + lbDowResult.setText(calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.ENGLISH)); + } + }); + + tfPassword1.getDocument().addDocumentListener(passwordListener); + + tfPassword2.getDocument().addDocumentListener(passwordListener); + } + + private void initUI() { + tfHistory.setHistory(Arrays.asList(resourceManager.getString("TextFieldDemo.history.words").split("\\,"))); + + JGridPanel pnDow = new JGridPanel(3, 2); + + pnDow.cell(tfDow). + cell(btnGo). + cell(lbDowResult); + + JGridPanel pnPassword = new JGridPanel(3, 2); + + pnPassword.cell(tfPassword1). + cell(tfPassword2). + cell(); + + JGridPanel pnContent = new JGridPanel(1, 0, 6); + + pnContent.setBorderEqual(10); + + pnContent.cell(lbHistoryTextField). + cell(tfHistory). + cell(lbDow, new Insets(20, 0, 0, 0)). + cell(pnDow). + cell(lbPassword, new Insets(20, 0, 0, 0)). + cell(pnPassword). + cell(); + + add(pnContent); + } +} diff --git a/swingset3/com/sun/swingset3/demos/textfield/resources/TextFieldDemo.properties b/swingset3/com/sun/swingset3/demos/textfield/resources/TextFieldDemo.properties new file mode 100644 index 0000000..5bb7b0a --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/textfield/resources/TextFieldDemo.properties @@ -0,0 +1,7 @@ +### TextField Demo ### + +TextFieldDemo.historytextfield.text = This is an example of a text field with a history. To try it in action, type "cat". +TextFieldDemo.history.words = armageddon,cars,cartoon,casanova,casino,castle,castlevania,cat,category,caterpillar,click,dog,magpie,hare,rabbit +TextFieldDemo.dow.text = Enter a date and find out what day of the week it is. +TextFieldDemo.go.text = Go +TextFieldDemo.password.text = The text fields below become highlighted when they get identical values. diff --git a/swingset3/com/sun/swingset3/demos/textfield/resources/images/TextFieldDemo.gif b/swingset3/com/sun/swingset3/demos/textfield/resources/images/TextFieldDemo.gif new file mode 100644 index 0000000..a4053d7 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/textfield/resources/images/TextFieldDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/DirectionPanel.java b/swingset3/com/sun/swingset3/demos/togglebutton/DirectionPanel.java new file mode 100644 index 0000000..34413cb --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/togglebutton/DirectionPanel.java @@ -0,0 +1,148 @@ +/* + * 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.demos.togglebutton; + +import java.awt.event.ActionListener; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.border.Border; + +/** + * @version 1.8 11/17/05 + * @author Jeff Dinkins + * @author Chester Rose + * @author Brian Beck + */ + +public class DirectionPanel extends JPanel { + + private final ButtonGroup group; + + public DirectionPanel(boolean enable, String selection, ActionListener l) { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + setAlignmentY(TOP_ALIGNMENT); + setAlignmentX(LEFT_ALIGNMENT); + + Box firstThree = Box.createHorizontalBox(); + Box secondThree = Box.createHorizontalBox(); + Box thirdThree = Box.createHorizontalBox(); + + if (!enable) { + selection = "None"; + } + + group = new ButtonGroup(); + DirectionButton b; + b = (DirectionButton) firstThree.add(new DirectionButton(tl_dot, tldn_dot, "NW", "Sets the orientation to the North-West", l, group, selection.equals("NW"))); + b.setEnabled(enable); + b = (DirectionButton) firstThree.add(new DirectionButton(tm_dot, tmdn_dot, "N", "Sets the orientation to the North", l, group, selection.equals("N"))); + b.setEnabled(enable); + b = (DirectionButton) firstThree.add(new DirectionButton(tr_dot, trdn_dot, "NE", "Sets the orientation to the North-East", l, group, selection.equals("NE"))); + b.setEnabled(enable); + b = (DirectionButton) secondThree.add(new DirectionButton(ml_dot, mldn_dot, "W", "Sets the orientation to the West", l, group, selection.equals("W"))); + b.setEnabled(enable); + b = (DirectionButton) secondThree.add(new DirectionButton(c_dot, cdn_dot, "C", "Sets the orientation to the Center", l, group, selection.equals("C"))); + b.setEnabled(enable); + b = (DirectionButton) secondThree.add(new DirectionButton(mr_dot, mrdn_dot, "E", "Sets the orientation to the East", l, group, selection.equals("E"))); + b.setEnabled(enable); + b = (DirectionButton) thirdThree.add(new DirectionButton(bl_dot, bldn_dot, "SW", "Sets the orientation to the South-West", l, group, selection.equals("SW"))); + b.setEnabled(enable); + b = (DirectionButton) thirdThree.add(new DirectionButton(bm_dot, bmdn_dot, "S", "Sets the orientation to the South", l, group, selection.equals("S"))); + b.setEnabled(enable); + b = (DirectionButton) thirdThree.add(new DirectionButton(br_dot, brdn_dot, "SE", "Sets the orientation to the South-East", l, group, selection.equals("SE"))); + b.setEnabled(enable); + + add(firstThree); + add(secondThree); + add(thirdThree); + } + + // Chester's way cool layout buttons + private final ImageIcon bl_dot = loadImageIcon("bl.gif", "bottom left layout button"); + private final ImageIcon bldn_dot = loadImageIcon("bldn.gif", "selected bottom left layout button"); + private final ImageIcon bm_dot = loadImageIcon("bm.gif", "bottom middle layout button"); + private final ImageIcon bmdn_dot = loadImageIcon("bmdn.gif", "selected bottom middle layout button"); + private final ImageIcon br_dot = loadImageIcon("br.gif", "bottom right layout button"); + private final ImageIcon brdn_dot = loadImageIcon("brdn.gif", "selected bottom right layout button"); + private final ImageIcon c_dot = loadImageIcon("c.gif", "center layout button"); + private final ImageIcon cdn_dot = loadImageIcon("cdn.gif", "selected center layout button"); + private final ImageIcon ml_dot = loadImageIcon("ml.gif", "middle left layout button"); + private final ImageIcon mldn_dot = loadImageIcon("mldn.gif", "selected middle left layout button"); + private final ImageIcon mr_dot = loadImageIcon("mr.gif", "middle right layout button"); + private final ImageIcon mrdn_dot = loadImageIcon("mrdn.gif", "selected middle right layout button"); + private final ImageIcon tl_dot = loadImageIcon("tl.gif", "top left layout button"); + private final ImageIcon tldn_dot = loadImageIcon("tldn.gif", "selected top left layout button"); + private final ImageIcon tm_dot = loadImageIcon("tm.gif", "top middle layout button"); + private final ImageIcon tmdn_dot = loadImageIcon("tmdn.gif", "selected top middle layout button"); + private final ImageIcon tr_dot = loadImageIcon("tr.gif", "top right layout button"); + private final ImageIcon trdn_dot = loadImageIcon("trdn.gif", "selected top right layout button"); + + private ImageIcon loadImageIcon(String filename, String description) { + String path = "resources/images/" + filename; + return new ImageIcon(getClass().getResource(path), description); + } + + + private static class DirectionButton extends JRadioButton { + + /** + * A layout direction button + */ + public DirectionButton(Icon icon, Icon downIcon, String direction, + String description, ActionListener l, + ButtonGroup group, boolean selected) { + super(); + this.addActionListener(l); + setFocusPainted(false); + setHorizontalTextPosition(CENTER); + group.add(this); + setIcon(icon); + setSelectedIcon(downIcon); + setActionCommand(direction); + getAccessibleContext().setAccessibleName(direction); + getAccessibleContext().setAccessibleDescription(description); + setSelected(selected); + } + + public boolean isFocusTraversable() { + return false; + } + + public void setBorder(Border b) { + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/LayoutControlPanel.java b/swingset3/com/sun/swingset3/demos/togglebutton/LayoutControlPanel.java new file mode 100644 index 0000000..857fbb5 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/togglebutton/LayoutControlPanel.java @@ -0,0 +1,268 @@ +/* + * 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.demos.togglebutton; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; + +import com.sun.swingset3.demos.ResourceManager; + +/* + * The LayoutControlPanel contains controls for setting an + * AbstractButton's horizontal and vertical text position and + * horizontal and vertical alignment. + */ + +public class LayoutControlPanel extends JPanel implements SwingConstants { + private static final Dimension VGAP20 = new Dimension(1, 20); + + private final boolean absolutePositions; + private ToggleButtonDemo demo = null; + + // private ComponentOrientChanger componentOrientChanger = null; + + LayoutControlPanel(ToggleButtonDemo demo, ResourceManager resourceManager) { + this.demo = demo; + + // this.componentOrientationChanger = componentOrientationChanger; + + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + setAlignmentX(LEFT_ALIGNMENT); + setAlignmentY(TOP_ALIGNMENT); + + JLabel l; + + // If SwingSet has a ComponentOrientationChanger, then include control + // for choosing between absolute and relative positioning. This will + // only happen when we're running on JDK 1.2 or above. + // + // if(componentOrientationChanger != null ) { + // l = new JLabel("Positioning:"); + // add(l); + // + // ButtonGroup group = new ButtonGroup(); + // PositioningListener positioningListener = new PositioningListener(); + // JRadioButton absolutePos = new JRadioButton("Absolute"); + // absolutePos.setMnemonic('a'); + // absolutePos.setToolTipText("Text/Content positioning is independant of line direction"); + // group.add(absolutePos); + // absolutePos.addItemListener(positioningListener); + // add(absolutePos); + // + // JRadioButton relativePos = new JRadioButton("Relative"); + // relativePos.setMnemonic('r'); + // relativePos.setToolTipText("Text/Content positioning depends on line direction."); + // group.add(relativePos); + // relativePos.addItemListener(positioningListener); + // add(relativePos); + // + // add(Box.createRigidArea(demo.VGAP20)); + // + // absolutePositions = false; + // relativePos.setSelected(true); + // + // componentOrientationChanger.addActionListener( new OrientationChangeListener() ); + //} else { + absolutePositions = true; + //} + + DirectionPanel textPosition = new DirectionPanel(true, "E", new TextPositionListener()); + DirectionPanel labelAlignment = new DirectionPanel(true, "C", new LabelAlignmentListener()); + + // Make sure the controls' text position and label alignment match + // the initial value of the associated direction panel. + for (JComponent control : demo.getCurrentControls()) { + setPosition(control, RIGHT, CENTER); + setAlignment(control, CENTER, CENTER); + } + + l = new JLabel(resourceManager.getString("LayoutControlPanel.textposition_label")); + add(l); + add(textPosition); + + add(Box.createRigidArea(VGAP20)); + + l = new JLabel(resourceManager.getString("LayoutControlPanel.contentalignment_label")); + add(l); + add(labelAlignment); + + add(Box.createGlue()); + } + + // Text Position Listener + private class TextPositionListener implements ActionListener { + public void actionPerformed(ActionEvent e) { + JRadioButton rb = (JRadioButton) e.getSource(); + if (!rb.isSelected()) { + return; + } + String cmd = rb.getActionCommand(); + int hPos, vPos; + if (cmd.equals("NW")) { + hPos = LEFT; + vPos = TOP; + } else if (cmd.equals("N")) { + hPos = CENTER; + vPos = TOP; + } else if (cmd.equals("NE")) { + hPos = RIGHT; + vPos = TOP; + } else if (cmd.equals("W")) { + hPos = LEFT; + vPos = CENTER; + } else if (cmd.equals("C")) { + hPos = CENTER; + vPos = CENTER; + } else if (cmd.equals("E")) { + hPos = RIGHT; + vPos = CENTER; + } else if (cmd.equals("SW")) { + hPos = LEFT; + vPos = BOTTOM; + } else if (cmd.equals("S")) { + hPos = CENTER; + vPos = BOTTOM; + } else /*if(cmd.equals("SE"))*/ { + hPos = RIGHT; + vPos = BOTTOM; + } + for (JComponent control : demo.getCurrentControls()) { + setPosition(control, hPos, vPos); + } + demo.invalidate(); + demo.validate(); + demo.repaint(); + } + } + + // Label Alignment Listener + private class LabelAlignmentListener implements ActionListener { + public void actionPerformed(ActionEvent e) { + JRadioButton rb = (JRadioButton) e.getSource(); + if (!rb.isSelected()) { + return; + } + String cmd = rb.getActionCommand(); + int hPos, vPos; + if (cmd.equals("NW")) { + hPos = LEFT; + vPos = TOP; + } else if (cmd.equals("N")) { + hPos = CENTER; + vPos = TOP; + } else if (cmd.equals("NE")) { + hPos = RIGHT; + vPos = TOP; + } else if (cmd.equals("W")) { + hPos = LEFT; + vPos = CENTER; + } else if (cmd.equals("C")) { + hPos = CENTER; + vPos = CENTER; + } else if (cmd.equals("E")) { + hPos = RIGHT; + vPos = CENTER; + } else if (cmd.equals("SW")) { + hPos = LEFT; + vPos = BOTTOM; + } else if (cmd.equals("S")) { + hPos = CENTER; + vPos = BOTTOM; + } else /*if(cmd.equals("SE"))*/ { + hPos = RIGHT; + vPos = BOTTOM; + } + for (JComponent control : demo.getCurrentControls()) { + setAlignment(control, hPos, vPos); + control.invalidate(); + } + demo.invalidate(); + demo.validate(); + demo.repaint(); + } + } + + // Position + void setPosition(Component c, int hPos, int vPos) { + boolean ltr = c.getComponentOrientation().isLeftToRight(); + if (absolutePositions) { + if (hPos == LEADING) { + hPos = ltr ? LEFT : RIGHT; + } else if (hPos == TRAILING) { + hPos = ltr ? RIGHT : LEFT; + } + } else { + if (hPos == LEFT) { + hPos = ltr ? LEADING : TRAILING; + } else if (hPos == RIGHT) { + hPos = ltr ? TRAILING : LEADING; + } + } + if (c instanceof AbstractButton) { + AbstractButton x = (AbstractButton) c; + x.setHorizontalTextPosition(hPos); + x.setVerticalTextPosition(vPos); + } else if (c instanceof JLabel) { + JLabel x = (JLabel) c; + x.setHorizontalTextPosition(hPos); + x.setVerticalTextPosition(vPos); + } + } + + void setAlignment(Component c, int hPos, int vPos) { + boolean ltr = c.getComponentOrientation().isLeftToRight(); + if (absolutePositions) { + if (hPos == LEADING) { + hPos = ltr ? LEFT : RIGHT; + } else if (hPos == TRAILING) { + hPos = ltr ? RIGHT : LEFT; + } + } else { + if (hPos == LEFT) { + hPos = ltr ? LEADING : TRAILING; + } else if (hPos == RIGHT) { + hPos = ltr ? TRAILING : LEADING; + } + } + if (c instanceof AbstractButton) { + AbstractButton x = (AbstractButton) c; + x.setHorizontalAlignment(hPos); + x.setVerticalAlignment(vPos); + } else if (c instanceof JLabel) { + JLabel x = (JLabel) c; + x.setHorizontalAlignment(hPos); + x.setVerticalAlignment(vPos); + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/ToggleButtonDemo.java b/swingset3/com/sun/swingset3/demos/togglebutton/ToggleButtonDemo.java new file mode 100644 index 0000000..1828044 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/togglebutton/ToggleButtonDemo.java @@ -0,0 +1,635 @@ +/* + * 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.demos.togglebutton; + +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.*; +import java.util.List; +import javax.swing.*; +import javax.swing.border.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * JButton, JRadioButton, JToggleButton, JCheckBox Demos + * + * @version 1.15 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "ToggleButtons Demo", + category = "Controls", + description = "Demonstrates JCheckBox & JRadioButton", + sourceFiles = { + "com/sun/swingset3/demos/togglebutton/ToggleButtonDemo.java", + "com/sun/swingset3/demos/togglebutton/DirectionPanel.java", + "com/sun/swingset3/demos/togglebutton/LayoutControlPanel.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/togglebutton/resources/ToggleButtonDemo.properties", + "com/sun/swingset3/demos/togglebutton/resources/images/b1.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b1d.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b1p.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b1r.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b2.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b2d.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b2p.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b2r.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b3.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b3d.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b3p.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/b3r.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/bl.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/bldn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/bm.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/bmdn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/br.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/brdn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/c.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/cb.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/cbr.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/cbrs.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/cbs.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/cdn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/ml.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/mldn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/mr.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/mrdn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/rb.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/rbp.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/rbr.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/rbrs.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/rbs.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/tl.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/tldn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/tm.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/tmdn.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/ToggleButtonDemo.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/tr.gif", + "com/sun/swingset3/demos/togglebutton/resources/images/trdn.gif" + } +) +public class ToggleButtonDemo extends JPanel implements ChangeListener { + private static final Dimension HGAP10 = new Dimension(10, 1); + private static final Dimension HGAP20 = new Dimension(20, 1); + private static final Dimension VGAP20 = new Dimension(1, 20); + private static final Dimension VGAP30 = new Dimension(1, 30); + + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + private final JTabbedPane tab; + + private final JPanel buttonPanel = new JPanel(); + private final JPanel checkboxPanel = new JPanel(); + private final JPanel radioButtonPanel = new JPanel(); + private final JPanel toggleButtonPanel = new JPanel(); + + private final List buttons = new ArrayList(); + private final List checkboxes = new ArrayList(); + private final List radiobuttons = new ArrayList(); + private final List togglebuttons = new ArrayList(); + + private List currentControls = buttons; + + private final EmptyBorder border5 = new EmptyBorder(5, 5, 5, 5); + + private ItemListener buttonDisplayListener = null; + private ItemListener buttonPadListener = null; + + private final Insets insets0 = new Insets(0, 0, 0, 0); + private final Insets insets10 = new Insets(10, 10, 10, 10); + + private final Border loweredBorder = new CompoundBorder( + new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(5, 5, 5, 5)); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ToggleButtonDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * ButtonDemo Constructor + */ + public ToggleButtonDemo() { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + tab = new JTabbedPane(); + tab.getModel().addChangeListener(this); + + add(tab); + + //addButtons(); + addRadioButtons(); + addCheckBoxes(); + //addToggleButtons(); + currentControls = checkboxes; + } + + private void addButtons() { + tab.addTab(resourceManager.getString("ToggleButtonDemo.buttons"), buttonPanel); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); + buttonPanel.setBorder(border5); + + JPanel p1 = createVerticalPanel(true); + p1.setAlignmentY(TOP_ALIGNMENT); + buttonPanel.add(p1); + + // Text Buttons + JPanel p2 = createHorizontalPanel(false); + p1.add(p2); + p2.setBorder(new CompoundBorder(new TitledBorder(null, + resourceManager.getString("ToggleButtonDemo.textbuttons"), + TitledBorder.LEFT, TitledBorder.TOP), border5)); + + JButton button1 = new JButton(resourceManager.getString("ToggleButtonDemo.button1")); + buttons.add(button1); + p2.add(button1); + p2.add(Box.createRigidArea(HGAP10)); + + JButton button2 = new JButton(resourceManager.getString("ToggleButtonDemo.button2")); + buttons.add(button2); + p2.add(button2); + p2.add(Box.createRigidArea(HGAP10)); + + JButton button3 = new JButton(resourceManager.getString("ToggleButtonDemo.button3")); + buttons.add(button3); + p2.add(button3); + + // Image Buttons + p1.add(Box.createRigidArea(VGAP30)); + JPanel p3 = createHorizontalPanel(false); + p1.add(p3); + p3.setLayout(new BoxLayout(p3, BoxLayout.X_AXIS)); + p3.setBorder(new TitledBorder(null, resourceManager.getString("ToggleButtonDemo.imagebuttons"), + TitledBorder.LEFT, TitledBorder.TOP)); + + // home image button + String description = resourceManager.getString("ToggleButtonDemo.phone"); + JButton button = new JButton(resourceManager.createImageIcon("b1.gif", description)); + button.setPressedIcon(resourceManager.createImageIcon("b1p.gif", description)); + button.setRolloverIcon(resourceManager.createImageIcon("b1r.gif", description)); + button.setDisabledIcon(resourceManager.createImageIcon("b1d.gif", description)); + button.setMargin(new Insets(0, 0, 0, 0)); + p3.add(button); + buttons.add(button); + p3.add(Box.createRigidArea(HGAP10)); + + // write image button + description = resourceManager.getString("ToggleButtonDemo.write"); + button = new JButton(resourceManager.createImageIcon("b2.gif", description)); + button.setPressedIcon(resourceManager.createImageIcon("b2p.gif", description)); + button.setRolloverIcon(resourceManager.createImageIcon("b2r.gif", description)); + button.setDisabledIcon(resourceManager.createImageIcon("b2d.gif", description)); + button.setMargin(new Insets(0, 0, 0, 0)); + p3.add(button); + buttons.add(button); + p3.add(Box.createRigidArea(HGAP10)); + + // write image button + description = resourceManager.getString("ToggleButtonDemo.peace"); + button = new JButton(resourceManager.createImageIcon("b3.gif", description)); + button.setPressedIcon(resourceManager.createImageIcon("b3p.gif", description)); + button.setRolloverIcon(resourceManager.createImageIcon("b3r.gif", description)); + button.setDisabledIcon(resourceManager.createImageIcon("b3d.gif", description)); + button.setMargin(new Insets(0, 0, 0, 0)); + p3.add(button); + buttons.add(button); + + p1.add(Box.createVerticalGlue()); + + buttonPanel.add(Box.createHorizontalGlue()); + currentControls = buttons; + buttonPanel.add(createControls()); + } + + private void addRadioButtons() { + ButtonGroup group = new ButtonGroup(); + + tab.addTab(resourceManager.getString("ToggleButtonDemo.radiobuttons"), radioButtonPanel); + radioButtonPanel.setLayout(new BoxLayout(radioButtonPanel, BoxLayout.X_AXIS)); + radioButtonPanel.setBorder(border5); + + JPanel p1 = createVerticalPanel(true); + p1.setAlignmentY(TOP_ALIGNMENT); + radioButtonPanel.add(p1); + + // Text Radio Buttons + JPanel p2 = createHorizontalPanel(false); + p1.add(p2); + p2.setBorder(new CompoundBorder( + new TitledBorder( + null, resourceManager.getString("ToggleButtonDemo.textradiobuttons"), + TitledBorder.LEFT, TitledBorder.TOP), border5) + ); + + JRadioButton radio = (JRadioButton) p2.add( + new JRadioButton(resourceManager.getString("ToggleButtonDemo.radio1"))); + group.add(radio); + radiobuttons.add(radio); + p2.add(Box.createRigidArea(HGAP10)); + + radio = (JRadioButton) p2.add( + new JRadioButton(resourceManager.getString("ToggleButtonDemo.radio2"))); + group.add(radio); + radiobuttons.add(radio); + p2.add(Box.createRigidArea(HGAP10)); + + radio = (JRadioButton) p2.add( + new JRadioButton(resourceManager.getString("ToggleButtonDemo.radio3"))); + group.add(radio); + radiobuttons.add(radio); + + // Image Radio Buttons + group = new ButtonGroup(); + p1.add(Box.createRigidArea(VGAP30)); + JPanel p3 = createHorizontalPanel(false); + p1.add(p3); + p3.setLayout(new BoxLayout(p3, BoxLayout.X_AXIS)); + p3.setBorder(new TitledBorder(null, resourceManager.getString("ToggleButtonDemo.imageradiobuttons"), + TitledBorder.LEFT, TitledBorder.TOP)); + + // image radio button 1 + String description = resourceManager.getString("ToggleButtonDemo.customradio"); + String text = resourceManager.getString("ToggleButtonDemo.radio1"); + radio = new JRadioButton(text, resourceManager.createImageIcon("rb.gif", description)); + radio.setPressedIcon(resourceManager.createImageIcon("rbp.gif", description)); + radio.setRolloverIcon(resourceManager.createImageIcon("rbr.gif", description)); + radio.setRolloverSelectedIcon(resourceManager.createImageIcon("rbrs.gif", description)); + radio.setSelectedIcon(resourceManager.createImageIcon("rbs.gif", description)); + radio.setMargin(new Insets(0, 0, 0, 0)); + group.add(radio); + p3.add(radio); + radiobuttons.add(radio); + p3.add(Box.createRigidArea(HGAP20)); + + // image radio button 2 + text = resourceManager.getString("ToggleButtonDemo.radio2"); + radio = new JRadioButton(text, resourceManager.createImageIcon("rb.gif", description)); + radio.setPressedIcon(resourceManager.createImageIcon("rbp.gif", description)); + radio.setRolloverIcon(resourceManager.createImageIcon("rbr.gif", description)); + radio.setRolloverSelectedIcon(resourceManager.createImageIcon("rbrs.gif", description)); + radio.setSelectedIcon(resourceManager.createImageIcon("rbs.gif", description)); + radio.setMargin(new Insets(0, 0, 0, 0)); + group.add(radio); + p3.add(radio); + radiobuttons.add(radio); + p3.add(Box.createRigidArea(HGAP20)); + + // image radio button 3 + text = resourceManager.getString("ToggleButtonDemo.radio3"); + radio = new JRadioButton(text, resourceManager.createImageIcon("rb.gif", description)); + radio.setPressedIcon(resourceManager.createImageIcon("rbp.gif", description)); + radio.setRolloverIcon(resourceManager.createImageIcon("rbr.gif", description)); + radio.setRolloverSelectedIcon(resourceManager.createImageIcon("rbrs.gif", description)); + radio.setSelectedIcon(resourceManager.createImageIcon("rbs.gif", description)); + radio.setMargin(new Insets(0, 0, 0, 0)); + group.add(radio); + radiobuttons.add(radio); + p3.add(radio); + + // verticaly glue fills out the rest of the box + p1.add(Box.createVerticalGlue()); + + radioButtonPanel.add(Box.createHorizontalGlue()); + currentControls = radiobuttons; + radioButtonPanel.add(createControls()); + } + + + private void addCheckBoxes() { + tab.addTab(resourceManager.getString("ToggleButtonDemo.checkboxes"), checkboxPanel); + checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.X_AXIS)); + checkboxPanel.setBorder(border5); + + JPanel p1 = createVerticalPanel(true); + p1.setAlignmentY(TOP_ALIGNMENT); + checkboxPanel.add(p1); + + // Text Radio Buttons + JPanel p2 = createHorizontalPanel(false); + p1.add(p2); + p2.setBorder(new CompoundBorder( + new TitledBorder( + null, resourceManager.getString("ToggleButtonDemo.textcheckboxes"), + TitledBorder.LEFT, TitledBorder.TOP), border5) + ); + + JCheckBox checkBox1 = new JCheckBox(resourceManager.getString("ToggleButtonDemo.check1")); + checkboxes.add(checkBox1); + p2.add(checkBox1); + p2.add(Box.createRigidArea(HGAP10)); + + JCheckBox checkBox2 = new JCheckBox(resourceManager.getString("ToggleButtonDemo.check2")); + checkboxes.add(checkBox2); + p2.add(checkBox2); + p2.add(Box.createRigidArea(HGAP10)); + + JCheckBox checkBox3 = new JCheckBox(resourceManager.getString("ToggleButtonDemo.check3")); + checkboxes.add(checkBox3); + p2.add(checkBox3); + + // Image Radio Buttons + p1.add(Box.createRigidArea(VGAP30)); + JPanel p3 = createHorizontalPanel(false); + p1.add(p3); + p3.setLayout(new BoxLayout(p3, BoxLayout.X_AXIS)); + p3.setBorder(new TitledBorder(null, resourceManager.getString("ToggleButtonDemo.imagecheckboxes"), + TitledBorder.LEFT, TitledBorder.TOP)); + + // image checkbox 1 + String description = resourceManager.getString("ToggleButtonDemo.customcheck"); + String text = resourceManager.getString("ToggleButtonDemo.check1"); + JCheckBox check = new JCheckBox(text, + resourceManager.createImageIcon("cb.gif", description)); + check.setRolloverIcon(resourceManager.createImageIcon("cbr.gif", description)); + check.setRolloverSelectedIcon(resourceManager.createImageIcon("cbrs.gif", description)); + check.setSelectedIcon(resourceManager.createImageIcon("cbs.gif", description)); + check.setMargin(new Insets(0, 0, 0, 0)); + p3.add(check); + checkboxes.add(check); + p3.add(Box.createRigidArea(HGAP20)); + + // image checkbox 2 + text = resourceManager.getString("ToggleButtonDemo.check2"); + check = new JCheckBox(text, resourceManager.createImageIcon("cb.gif", description)); + check.setRolloverIcon(resourceManager.createImageIcon("cbr.gif", description)); + check.setRolloverSelectedIcon(resourceManager.createImageIcon("cbrs.gif", description)); + check.setSelectedIcon(resourceManager.createImageIcon("cbs.gif", description)); + check.setMargin(new Insets(0, 0, 0, 0)); + p3.add(check); + checkboxes.add(check); + p3.add(Box.createRigidArea(HGAP20)); + + // image checkbox 3 + text = resourceManager.getString("ToggleButtonDemo.check3"); + check = new JCheckBox(text, resourceManager.createImageIcon("cb.gif", description)); + check.setRolloverIcon(resourceManager.createImageIcon("cbr.gif", description)); + check.setRolloverSelectedIcon(resourceManager.createImageIcon("cbrs.gif", description)); + check.setSelectedIcon(resourceManager.createImageIcon("cbs.gif", description)); + check.setMargin(new Insets(0, 0, 0, 0)); + p3.add(check); + checkboxes.add(check); + + // verticaly glue fills out the rest of the box + p1.add(Box.createVerticalGlue()); + + checkboxPanel.add(Box.createHorizontalGlue()); + currentControls = checkboxes; + checkboxPanel.add(createControls()); + } + + private void addToggleButtons() { + tab.addTab(resourceManager.getString("ToggleButtonDemo.togglebuttons"), toggleButtonPanel); + } + + private JPanel createControls() { + JPanel controls = new JPanel() { + public Dimension getMaximumSize() { + return new Dimension(300, super.getMaximumSize().height); + } + }; + controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS)); + controls.setAlignmentY(TOP_ALIGNMENT); + controls.setAlignmentX(LEFT_ALIGNMENT); + + JPanel buttonControls = createHorizontalPanel(true); + buttonControls.setAlignmentY(TOP_ALIGNMENT); + buttonControls.setAlignmentX(LEFT_ALIGNMENT); + + JPanel leftColumn = createVerticalPanel(false); + leftColumn.setAlignmentX(LEFT_ALIGNMENT); + leftColumn.setAlignmentY(TOP_ALIGNMENT); + + JPanel rightColumn = new LayoutControlPanel(this, resourceManager); + + buttonControls.add(leftColumn); + buttonControls.add(Box.createRigidArea(HGAP20)); + buttonControls.add(rightColumn); + buttonControls.add(Box.createRigidArea(HGAP20)); + + controls.add(buttonControls); + + createListeners(); + + // Display Options + JLabel l = new JLabel(resourceManager.getString("ToggleButtonDemo.controlpanel_label")); + leftColumn.add(l); + + JCheckBox bordered = new JCheckBox(resourceManager.getString("ToggleButtonDemo.paintborder")); + bordered.setActionCommand("PaintBorder"); + bordered.setToolTipText(resourceManager.getString("ToggleButtonDemo.paintborder_tooltip")); + bordered.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.paintborder_mnemonic")); + if (currentControls == buttons) { + bordered.setSelected(true); + } + bordered.addItemListener(buttonDisplayListener); + leftColumn.add(bordered); + + JCheckBox focused = new JCheckBox(resourceManager.getString("ToggleButtonDemo.paintfocus")); + focused.setActionCommand("PaintFocus"); + focused.setToolTipText(resourceManager.getString("ToggleButtonDemo.paintfocus_tooltip")); + focused.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.paintfocus_mnemonic")); + focused.setSelected(true); + focused.addItemListener(buttonDisplayListener); + leftColumn.add(focused); + + JCheckBox enabled = new JCheckBox(resourceManager.getString("ToggleButtonDemo.enabled")); + enabled.setActionCommand("Enabled"); + enabled.setToolTipText(resourceManager.getString("ToggleButtonDemo.enabled_tooltip")); + enabled.setSelected(true); + enabled.addItemListener(buttonDisplayListener); + enabled.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.enabled_mnemonic")); + leftColumn.add(enabled); + + JCheckBox filled = new JCheckBox(resourceManager.getString("ToggleButtonDemo.contentfilled")); + filled.setActionCommand("ContentFilled"); + filled.setToolTipText(resourceManager.getString("ToggleButtonDemo.contentfilled_tooltip")); + filled.setSelected(true); + filled.addItemListener(buttonDisplayListener); + filled.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.contentfilled_mnemonic")); + leftColumn.add(filled); + + leftColumn.add(Box.createRigidArea(VGAP20)); + + l = new JLabel(resourceManager.getString("ToggleButtonDemo.padamount_label")); + leftColumn.add(l); + ButtonGroup group = new ButtonGroup(); + JRadioButton defaultPad = new JRadioButton(resourceManager.getString("ToggleButtonDemo.default")); + defaultPad.setToolTipText(resourceManager.getString("ToggleButtonDemo.default_tooltip")); + defaultPad.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.default_mnemonic")); + defaultPad.addItemListener(buttonPadListener); + group.add(defaultPad); + defaultPad.setSelected(true); + leftColumn.add(defaultPad); + + JRadioButton zeroPad = new JRadioButton(resourceManager.getString("ToggleButtonDemo.zero")); + zeroPad.setActionCommand("ZeroPad"); + zeroPad.setToolTipText(resourceManager.getString("ToggleButtonDemo.zero_tooltip")); + zeroPad.addItemListener(buttonPadListener); + zeroPad.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.zero_mnemonic")); + group.add(zeroPad); + leftColumn.add(zeroPad); + + JRadioButton tenPad = new JRadioButton(resourceManager.getString("ToggleButtonDemo.ten")); + tenPad.setActionCommand("TenPad"); + tenPad.setMnemonic(resourceManager.getMnemonic("ToggleButtonDemo.ten_mnemonic")); + tenPad.setToolTipText(resourceManager.getString("ToggleButtonDemo.ten_tooltip")); + tenPad.addItemListener(buttonPadListener); + group.add(tenPad); + leftColumn.add(tenPad); + + leftColumn.add(Box.createRigidArea(VGAP20)); + return controls; + } + + private void createListeners() { + buttonDisplayListener = new ItemListener() { + public void itemStateChanged(ItemEvent e) { + JCheckBox cb = (JCheckBox) e.getSource(); + String command = cb.getActionCommand(); + if (command == "Enabled") { + for (JComponent control : currentControls) { + control.setEnabled(cb.isSelected()); + control.invalidate(); + } + } else if (command == "PaintBorder") { + if (currentControls.get(0) instanceof AbstractButton) { + for (JComponent control : currentControls) { + AbstractButton b = (AbstractButton) control; + b.setBorderPainted(cb.isSelected()); + b.invalidate(); + } + } + } else if (command == "PaintFocus") { + if (currentControls.get(0) instanceof AbstractButton) { + for (JComponent control : currentControls) { + AbstractButton b = (AbstractButton) control; + b.setFocusPainted(cb.isSelected()); + b.invalidate(); + } + } + } else if (command == "ContentFilled") { + if (currentControls.get(0) instanceof AbstractButton) { + for (JComponent control : currentControls) { + AbstractButton b = (AbstractButton) control; + b.setContentAreaFilled(cb.isSelected()); + b.invalidate(); + } + } + } + invalidate(); + validate(); + repaint(); + } + }; + + buttonPadListener = new ItemListener() { + public void itemStateChanged(ItemEvent e) { + // *** pad = 0 + int pad = -1; + JRadioButton rb = (JRadioButton) e.getSource(); + String command = rb.getActionCommand(); + if (command == "ZeroPad" && rb.isSelected()) { + pad = 0; + } else if (command == "TenPad" && rb.isSelected()) { + pad = 10; + } + + for (JComponent control : currentControls) { + AbstractButton b = (AbstractButton) control; + if (pad == -1) { + b.setMargin(null); + } else if (pad == 0) { + b.setMargin(insets0); + } else { + b.setMargin(insets10); + } + } + invalidate(); + validate(); + repaint(); + } + }; + } + + public void stateChanged(ChangeEvent e) { + SingleSelectionModel model = (SingleSelectionModel) e.getSource(); + if (model.getSelectedIndex() == 0) { + currentControls = buttons; + } else if (model.getSelectedIndex() == 1) { + currentControls = radiobuttons; + } else if (model.getSelectedIndex() == 2) { + currentControls = checkboxes; + } else { + currentControls = togglebuttons; + } + } + + public List getCurrentControls() { + return currentControls; + } + + private JPanel createHorizontalPanel(boolean threeD) { + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.setAlignmentY(TOP_ALIGNMENT); + p.setAlignmentX(LEFT_ALIGNMENT); + if (threeD) { + p.setBorder(loweredBorder); + } + return p; + } + + private JPanel createVerticalPanel(boolean threeD) { + JPanel p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); + p.setAlignmentY(TOP_ALIGNMENT); + p.setAlignmentX(LEFT_ALIGNMENT); + if (threeD) { + p.setBorder(loweredBorder); + } + return p; + } +} diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/ToggleButtonDemo.properties b/swingset3/com/sun/swingset3/demos/togglebutton/resources/ToggleButtonDemo.properties new file mode 100644 index 0000000..241368a --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/togglebutton/resources/ToggleButtonDemo.properties @@ -0,0 +1,69 @@ +### Button Demo ### + +ToggleButtonDemo.accessible_description=The ButtonDemo shows examples of using JButton, JRadioButton, JToggleButton, and JCheckBox +ToggleButtonDemo.tooltip=JButton, JRadioButton, JToggleButton, JCheckbox demos +ToggleButtonDemo.name=Button Demo + +ToggleButtonDemo.buttons=Buttons +ToggleButtonDemo.checkboxes=Check Boxes +ToggleButtonDemo.radiobuttons=Radio Buttons +ToggleButtonDemo.togglebuttons=Toggle Buttons + +ToggleButtonDemo.textbuttons=Text Buttons +ToggleButtonDemo.imagebuttons=Image Buttons +ToggleButtonDemo.textradiobuttons=Text Radio Buttons +ToggleButtonDemo.imageradiobuttons=Image Radio Buttons +ToggleButtonDemo.texttogglebuttons=Text Toggle Buttons +ToggleButtonDemo.imagetogglebuttons=Image Toggle Buttons +ToggleButtonDemo.textcheckboxes=Text CheckBoxes +ToggleButtonDemo.imagecheckboxes=Image CheckBoxes + +ToggleButtonDemo.button1=One +ToggleButtonDemo.button2=Two +ToggleButtonDemo.button3=Three! + +ToggleButtonDemo.radio1=Radio One +ToggleButtonDemo.radio2=Radio Two +ToggleButtonDemo.radio3=Radio Three +ToggleButtonDemo.radioX=Three(HTML!) + +ToggleButtonDemo.check1=One +ToggleButtonDemo.check2=Two +ToggleButtonDemo.check3=Three +ToggleButtonDemo.checkX=Three(HTML!) + +ToggleButtonDemo.customradio=A custom "chrome" radio button. +ToggleButtonDemo.customcheck=A custom lightbulb checkbox. + +ToggleButtonDemo.phone=Phone +ToggleButtonDemo.write=Write +ToggleButtonDemo.peace=Peace + +ToggleButtonDemo.controlpanel_label=Display Options: +ToggleButtonDemo.paintborder=Paint Border +ToggleButtonDemo.paintborder_tooltip=Click here to turn border painting on or off. +ToggleButtonDemo.paintborder_mnemonic=b +ToggleButtonDemo.paintfocus=Paint Focus +ToggleButtonDemo.paintfocus_tooltip=Click here to turn focus painting on or off. +ToggleButtonDemo.paintfocus_mnemonic=f +ToggleButtonDemo.enabled=Enabled +ToggleButtonDemo.enabled_tooltip=Click here to enable or disable the buttons. +ToggleButtonDemo.enabled_mnemonic=e +ToggleButtonDemo.contentfilled=Content Filled +ToggleButtonDemo.contentfilled_tooltip=Click here to control the filling of the content area. +ToggleButtonDemo.contentfilled_mnemonic=i + +ToggleButtonDemo.padamount_label=Pad Amount: +ToggleButtonDemo.default=Default +ToggleButtonDemo.default_tooltip=Uses the default padding between the border and label. +ToggleButtonDemo.default_mnemonic=d +ToggleButtonDemo.zero=0 +ToggleButtonDemo.zero_mnemonic=0 +ToggleButtonDemo.zero_tooltip=Uses no padding between the border and label. +ToggleButtonDemo.ten=10 +ToggleButtonDemo.ten_mnemonic=1 +ToggleButtonDemo.ten_tooltip=Uses a 10 pixel pad between the border and label. + +LayoutControlPanel.textposition_label=Text Position: +LayoutControlPanel.contentalignment_label=Content Alignment: + diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/ToggleButtonDemo.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/ToggleButtonDemo.gif new file mode 100644 index 0000000..35099bb Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/ToggleButtonDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1.gif new file mode 100644 index 0000000..24a7dea Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1d.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1d.gif new file mode 100644 index 0000000..383404e Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1d.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1p.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1p.gif new file mode 100644 index 0000000..1f3fd66 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1p.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1r.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1r.gif new file mode 100644 index 0000000..2a669a2 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b1r.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2.gif new file mode 100644 index 0000000..af6d626 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2d.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2d.gif new file mode 100644 index 0000000..b745943 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2d.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2p.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2p.gif new file mode 100644 index 0000000..0f4abf3 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2p.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2r.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2r.gif new file mode 100644 index 0000000..21becb9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b2r.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3.gif new file mode 100644 index 0000000..6787626 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3d.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3d.gif new file mode 100644 index 0000000..4d397a3 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3d.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3p.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3p.gif new file mode 100644 index 0000000..0db029f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3p.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3r.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3r.gif new file mode 100644 index 0000000..7ddd2f9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/b3r.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bl.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bl.gif new file mode 100644 index 0000000..75fd0b9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bl.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bldn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bldn.gif new file mode 100644 index 0000000..546f06f Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bldn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bm.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bm.gif new file mode 100644 index 0000000..80f7352 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bm.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bmdn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bmdn.gif new file mode 100644 index 0000000..3d42d0b Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/bmdn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/br.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/br.gif new file mode 100644 index 0000000..b02e448 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/br.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/brdn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/brdn.gif new file mode 100644 index 0000000..58cf892 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/brdn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/c.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/c.gif new file mode 100644 index 0000000..66d0276 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/c.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cb.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cb.gif new file mode 100644 index 0000000..f3acd97 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cb.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbr.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbr.gif new file mode 100644 index 0000000..278dab9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbr.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbrs.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbrs.gif new file mode 100644 index 0000000..0cd04d7 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbrs.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbs.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbs.gif new file mode 100644 index 0000000..dbbd338 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cbs.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cdn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cdn.gif new file mode 100644 index 0000000..8a2ca4b Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/cdn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/ml.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/ml.gif new file mode 100644 index 0000000..d8ad580 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/ml.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mldn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mldn.gif new file mode 100644 index 0000000..0902554 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mldn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mr.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mr.gif new file mode 100644 index 0000000..c94cc82 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mr.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mrdn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mrdn.gif new file mode 100644 index 0000000..3b70077 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/mrdn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rb.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rb.gif new file mode 100644 index 0000000..f6ff994 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rb.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbp.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbp.gif new file mode 100644 index 0000000..e82d607 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbp.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbr.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbr.gif new file mode 100644 index 0000000..9836e0c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbr.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbrs.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbrs.gif new file mode 100644 index 0000000..f48e799 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbrs.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbs.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbs.gif new file mode 100644 index 0000000..5c11fce Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/rbs.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tl.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tl.gif new file mode 100644 index 0000000..5d7a11c Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tl.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tldn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tldn.gif new file mode 100644 index 0000000..5db2fc1 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tldn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tm.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tm.gif new file mode 100644 index 0000000..c69edc9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tm.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tmdn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tmdn.gif new file mode 100644 index 0000000..8f765b9 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tmdn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tr.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tr.gif new file mode 100644 index 0000000..42e6017 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/tr.gif differ diff --git a/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/trdn.gif b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/trdn.gif new file mode 100644 index 0000000..8f3c186 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/togglebutton/resources/images/trdn.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tooltip/ToolTipDemo.java b/swingset3/com/sun/swingset3/demos/tooltip/ToolTipDemo.java new file mode 100644 index 0000000..efc9536 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tooltip/ToolTipDemo.java @@ -0,0 +1,155 @@ +/* + * 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.demos.tooltip; + +import java.awt.*; +import javax.swing.*; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * ToolTip Demo + * + * @version 1.9 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "ToolTips Demo", + category = "General", + description = "Demonstrates how tooltips can be easily added to Swing GUI components", + sourceFiles = { + "com/sun/swingset3/demos/tooltip/ToolTipDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties", + "com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png", + "com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif" + } +) +public class ToolTipDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(ToolTipDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new ToolTipDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * ToolTipDemo Constructor + */ + public ToolTipDemo() { + setLayout(new BorderLayout()); + + // Create a panel which contains specific tooltip regions. + Toolbox toolbox = new Toolbox(); + + add(toolbox, BorderLayout.CENTER); + } + + public class Toolbox extends JPanel { + private final Rectangle plainRect = new Rectangle(44, 0, 186, 128); + private final Rectangle htmlRect = new Rectangle(240, 134, 186, 186); + private final Rectangle styledRect = new Rectangle(45, 327, 188, 134); + + private final JLabel background; + private final JComponent plainToolTipRegion; + private final JComponent htmlToolTipRegion; + private final JComponent styledToolTipRegion; + + public Toolbox() { + setLayout(null); + + background = new JLabel(resourceManager.createImageIcon("tooltip_background.png", + resourceManager.getString("ToolTipDemo.toolbox"))); + + background.setVerticalAlignment(JLabel.TOP); + background.setHorizontalAlignment(JLabel.LEFT); + + // Note: tooltip text isn't retrieved from properties file in order + // to make this code easier to understand + + //Create region for displaying plain tooltip + plainToolTipRegion = createToolTipRegion(resourceManager.getString("ToolTipDemo.plain")); + plainToolTipRegion.setToolTipText("A simple one line tip."); + // + + //Create region for displaying HTML tooltip + htmlToolTipRegion = createToolTipRegion(resourceManager.getString("ToolTipDemo.html")); + htmlToolTipRegion.setToolTipText("In case you thought that tooltips had to be

" + + "boring, one line descriptions, the Swing! team

" + + "is happy to shatter your illusions.

" + + "In Swing, you can use HTML to

  • Have Lists
  • Bold text
  • emphasized" + + "text
  • text with Color
  • text in different sizes" + + "
  • and Fonts
Oh, and they can be multi-line, too."); + //
+ + //Create region for displaying styled tooltip + styledToolTipRegion = createToolTipRegion(resourceManager.getString("ToolTipDemo.styled")); + styledToolTipRegion.setToolTipText("Tips can be styled to be" + + "
interesting and fun"); + //
+ + add(htmlToolTipRegion); + add(styledToolTipRegion); + add(plainToolTipRegion); + + add(background); + } + + public void doLayout() { + background.setBounds(0, 0, getWidth(), getHeight()); + plainToolTipRegion.setBounds(plainRect); + htmlToolTipRegion.setBounds(htmlRect); + styledToolTipRegion.setBounds(styledRect); + } + + private JComponent createToolTipRegion(String text) { + JLabel region = new JLabel(text); + + region.setForeground(Color.white); + region.setFont(getFont().deriveFont(18f)); + region.setHorizontalAlignment(JLabel.CENTER); + region.setVerticalAlignment(JLabel.CENTER); + + return region; + } + } +} diff --git a/swingset3/com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties b/swingset3/com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties new file mode 100644 index 0000000..999dddb --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tooltip/resources/ToolTipDemo.properties @@ -0,0 +1,10 @@ +### ToolTip Demo ### + +ToolTipDemo.accessible_description=ToolTips show short help descriptions for a component +ToolTipDemo.tooltip=ToolTip demo +ToolTipDemo.name=ToolTip Demo +ToolTipDemo.toolbox=Toolbox containing tooltip regions +ToolTipDemo.plain=

Roll over here
to see a tooltip

+ToolTipDemo.html=

Roll over this box
to see a tooltip
in HTML

+ToolTipDemo.styled=

Roll over here\nto see a tooltip
in styled text

+ diff --git a/swingset3/com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif b/swingset3/com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif new file mode 100644 index 0000000..eb5b125 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tooltip/resources/images/ToolTipDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png b/swingset3/com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png new file mode 100644 index 0000000..bbffa05 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tooltip/resources/images/tooltip_background.png differ diff --git a/swingset3/com/sun/swingset3/demos/tree/TreeDemo.java b/swingset3/com/sun/swingset3/demos/tree/TreeDemo.java new file mode 100644 index 0000000..2e4158b --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tree/TreeDemo.java @@ -0,0 +1,148 @@ +/* + * 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.demos.tree; + +import java.awt.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.ResourceManager; + +/** + * JTree Demo + * + * @version 1.13 11/17/05 + * @author Jeff Dinkins + */ +@DemoProperties( + value = "JTree Demo", + category = "Data", + description = "Demonstrates JTree, a component which supports display/editing of hierarchical data", + sourceFiles = { + "com/sun/swingset3/demos/tree/TreeDemo.java", + "com/sun/swingset3/demos/ResourceManager.java", + "com/sun/swingset3/demos/tree/resources/tree.txt", + "com/sun/swingset3/demos/tree/resources/TreeDemo.properties", + "com/sun/swingset3/demos/tree/resources/images/TreeDemo.gif" + } +) +public class TreeDemo extends JPanel { + private final ResourceManager resourceManager = new ResourceManager(this.getClass()); + + /** + * main method allows us to run as a standalone demo. + */ + public static void main(String[] args) { + JFrame frame = new JFrame(TreeDemo.class.getAnnotation(DemoProperties.class).value()); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.getContentPane().add(new TreeDemo()); + frame.setPreferredSize(new Dimension(800, 600)); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + /** + * TreeDemo Constructor + */ + public TreeDemo() { + setLayout(new BorderLayout()); + + add(new JScrollPane(createTree()), BorderLayout.CENTER); + } + + private JTree createTree() { + DefaultMutableTreeNode top = new DefaultMutableTreeNode(resourceManager.getString("TreeDemo.music")); + DefaultMutableTreeNode catagory = null; + DefaultMutableTreeNode artist = null; + DefaultMutableTreeNode record = null; + + // open tree data + URL url = getClass().getResource("resources/tree.txt"); + + try { + // convert url to buffered string + InputStream is = url.openStream(); + InputStreamReader isr = new InputStreamReader(is, "UTF-8"); + BufferedReader reader = new BufferedReader(isr); + + // read one line at a time, put into tree + String line = reader.readLine(); + while (line != null) { + // System.out.println("reading in: ->" + line + "<-"); + char linetype = line.charAt(0); + switch (linetype) { + case 'C': + catagory = new DefaultMutableTreeNode(line.substring(2)); + top.add(catagory); + break; + case 'A': + if (catagory != null) { + catagory.add(artist = new DefaultMutableTreeNode(line.substring(2))); + } + break; + case 'R': + if (artist != null) { + artist.add(record = new DefaultMutableTreeNode(line.substring(2))); + } + break; + case 'S': + if (record != null) { + record.add(new DefaultMutableTreeNode(line.substring(2))); + } + break; + default: + break; + } + line = reader.readLine(); + } + } catch (IOException e) { + } + + JTree tree = new JTree(top) { + public Insets getInsets() { + return new Insets(5, 5, 5, 5); + } + }; + + tree.setEditable(true); + + return tree; + } +} diff --git a/swingset3/com/sun/swingset3/demos/tree/resources/TreeDemo.properties b/swingset3/com/sun/swingset3/demos/tree/resources/TreeDemo.properties new file mode 100644 index 0000000..77c6f82 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tree/resources/TreeDemo.properties @@ -0,0 +1,8 @@ +### Tree Demo ### + +TreeDemo.accessible_description=This demo shows shows a sample usage of a JTree component. +TreeDemo.tooltip=JTree demo +TreeDemo.name=Tree Demo +TreeDemo.music=Music + + diff --git a/swingset3/com/sun/swingset3/demos/tree/resources/images/TreeDemo.gif b/swingset3/com/sun/swingset3/demos/tree/resources/images/TreeDemo.gif new file mode 100644 index 0000000..0f72dca Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/tree/resources/images/TreeDemo.gif differ diff --git a/swingset3/com/sun/swingset3/demos/tree/resources/tree.txt b/swingset3/com/sun/swingset3/demos/tree/resources/tree.txt new file mode 100644 index 0000000..2c92fca --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/tree/resources/tree.txt @@ -0,0 +1,628 @@ +################################################################################ +# Note: do not add blank lines, the data parser in TreeDemo.java cannot # +# handle them. # +# # +# Key: # +# Popular / Classical # +# ---------------------------- # +# A = Artist / Composer # +# R = Record / Style # +# S = Song Name / Composition # +# C = Catagory # +# # +################################################################################ +C Classical +A Beethoven +R concertos +S No. 1 - C +S No. 2 - B-Flat Major +S No. 3 - C Minor +S No. 4 - G Major +S No. 5 - E-Flat Major +R Quartets +S Six String Quartets +S Three String Quartets +S Grosse Fugue for String Quartets +R Sonatas +S Sonata in A Minor +S Sonata in F Major +R Symphonies +S No. 1 - C Major +S No. 2 - D Major +S No. 3 - E-Flat Major +S No. 4 - B-Flat Major +S No. 5 - C Minor +S No. 6 - F Major +S No. 7 - A Major +S No. 8 - F Major +S No. 9 - D Minor +A Brahms +R Concertos +S Violin Concerto +S Double Concerto - A Minor +S Piano Concerto No. 1 - D Minor +S Piano Concerto No. 2 - B-Flat Major +R Quartets +S Piano Quartet No. 1 - G Minor +S Piano Quartet No. 2 - A Major +S Piano Quartet No. 3 - C Minor +S String Quartet No. 3 - B-Flat Minor +R Sonatas +S Two Sonatas for Clarinet - F Minor +S Two Sonatas for Clarinet - E-Flat Major +R Symphonies +S No. 1 - C Minor +S No. 2 - D Minor +S No. 3 - F Major +S No. 4 - E Minor +A Mozart +R Concertos +S Piano Concerto No. 12 +S Piano Concerto No. 17 +S Clarinet Concerto +S Violin Concerto No. 5 +S Violin Concerto No. 4 +C Jazz +A Albert Ayler +R My Name is Albert Ayler +S Bye Bye Blackbird +S Billie's Bounce +S Summertime +S On Green Dolphin Street +S C.T. +R Swing Low Sweet Spiritual +S Goin' Home +S Old Man River +S When The Saints Go Marching In +S Deep River +S Down By The Riverside +S Spirits +S Witches and Devils +S Holy, Holy +S Saints +R Prophesy +S Spirits +S Wizard +S Ghosts +S Prophecy +R New Grass +S Free At Last +S Everybody's Movin' +S New Generation +S Heart Love +S Sun Watcher +A Chet Baker +R Sings and Plays +S Let's Get Lost +S This Is Always +S Long Ago and Far Away +S I Wish I Knew +S Daybreak +S Grey December +S I Remember You +R My Funny Valentine +S My Funny Valentine +S Someone To Watch Over Me +S Moonlight Becomes You +S I'm Glad There is You +S This is Always +S Time After Time +S Sweet Lorraine +S It's Always You +S Moon Love +S Like Someone In Love +S I've Never Been In Love Before +S Isn't it Romantic +S I Fall In Love Too Easily +R Grey December +S Grey December +S I Wish I Knew +S Someone To Watch Over Me +S Headline +S Bockhanal +S A Dandy Line +S Pro Defunctus +S Little Old Lady +S Goodbye +R The Route +S Tynan Time +S The Route +S Minor Yours +S Little Girl +S Ol' Croix +S The Great Lie +S Sweet Lorrain +S If I Should Lose You +A John Coltrane +R Blue Train +S Blue Train +S Moment's Notice +S Locomotion +S I'm Old Fashioned +S Lazy Bird +R Giant Steps +S Giant Steps +S Cousin Mary Steps +S Countdown +S Spiral +S Syeeda's Song Flute +S Naima +S Mr. P.C. +R My Favorite Things +S My Favorite Things +S Everytime We Say Goodbye +S Summertime +S But Not For Me +R Crescent +S Crescent +S Wise One +S Bessie's Blues +S Lonnie's Lament +S The Drum Thing +R Interstellar Space +S Mars +S Leo +S Venus +S Jupiter Variation +S Jupiter +S Saturn +A Miles Davis +R Transition +S Autumn Leaves +S Two Bass Hit +S Love, I've Found You +S I Thought About You +S All Blues +S Seven Steps To Heaven +R Quiet Nights +S Once Upon a Summertime +S Aos Pes Da Cruz +S Wait Till You See Her +S Corcovado +S Summer Nights +R My Funny Valentine +S All of You +S Stella By Starlight +S All Blues +S I Thought About You +R Voodoo Down +S Automn Leaves +S Footprints +S Directions +S Bitches Brew +S Hush +C Rock +A The Beatles +R A Hard Day's Night +S A Hard Day's Night +S I Should Have Known Better +S If I Fell +S I'm Happy Just To Dance With You +S And I Love Her +S Tell Me Why +S Can't Buy Me Love +S Any Time At All +S I'll Cry Instead +S Things We Said Today +S When I Get Home +S You Can't Do That +R Beatles For Sale +S No Reply +S I'm a Loser +S Baby's In Black +S Rock And Roll Music +S I'll Follow the Sun +S Mr. Moonlight +S Kansas City/Hey Hey Hey Hey +S Eight Days a Week +S Words Of Love +S Honey Don't +S Every Little Thing +S I Don't Want To Spoil the Party +S What You're Doing +S Everybody's Trying To Be My Baby +R Help! +S Help! +S The Night Before +S You've Got To Hide Your Love Away +S I Need You +S Another Girl +S You're Going To Lose That Girl +S Ticket To Ride +S Act Naturally +S It's Only Love +S You Like Me Too Much +S Tell Me What You See +S I've Just Seen a Face +S Yesterday +S Dizzy Miss Lizzie +R Rubber Soul +S Drive My Car +S Norwegian Wood +S You Won't See Me +S Nowhere Man +S Think For Yourself +S The Word +S Michelle +S What Goes On? +S Girl +S I'm Looking Through You +S In My Life +S Wait +S If I Needed Someone +S Run For Your Life +R Revolver +S Taxman +S Rigby +S I'm Only Sleeping +S For You To +S Here There And Everywhere +S Yellow Submarine +S She Said She Said +S Good Day Sunshine +S And Your Bird Can Sing +S For No One +S Doctor Robert +S I Want To Tell You +S Got To Get You Into My Life +S Tomorrow Never Knows +R Sgt. Pepper's Lonely Hearts Club Band +S Sgt. Pepper's Lonely Hearts Club Band +S With a Little Help From My Friends +S Lucy in the Sky With Diamonds +S Getting Better +S Fixing a Hole +S She's Leaving Home +S Being For the Benefit of Mr. Kite +S Within You Without You +S When I'm Sixty Four +S Lovely Rita +S Good Morning +S Sgt. Pepper's Reprise +S A Day In The Life +R Magical Mystery Tour +S Magical Mystery Tour +S Fool on the Hill +S Flying +S Blue Jay Way +S Your Mother Should Know +S I Am The Walrus +S Hello Goodbye +S Strawberry Fields Forever +S Penny Lane +S Baby You're a Rich Man +S All You Need Is Love +R The White Album +S Back in the USSR +S Dear Prudence +S Glass Onion +S Wild Honey Pie +S Bungalow Bill +S While My Guitar Gently Weeps +S Martha My Dear +S I'm So Tired +S Blackbird +S Piggies +S Rocky Raccoon +S Don't Pass Me By +S Why Don't We Do It In The Road +S I Will +S Julia +S Birthday +S Yer Blues +S Mother Nature's Son +S Sexy Sadie +S Helter Skelter +S Long Long Long +S Revolution 1 +S Honey Pie +S Savoy Truffle +S Cry Baby Cry +S Revolution 9 +S Good Night +R Abbey Road +S Come Together +S Something +S Maxwell's Silver Hammer +S Octopus's Garden +S She's So Heavy +S Here Comes The Sun +S Because +S You Never Give Me Your Money +S Sun King +S Mean Mr. Mustard +S Polythene Pam +S She Came In Through The Bathroom Window +S Golden Slumbers +S Carry That Weight +S The End +S Her Majesty +R Let It Be +S Two of Us +S Dig A Pony +S Across the Universe +S I Me Mine +S Dig It +S Let It Be +S Maggie Mae +S I've Got A Feeling +S One After 909 +S The Long and Winding Road +S For You Blue +S Get Back +A Crowded House +R Crowded House +S Mean To Me +S World Where You Live +S Now We're Getting Somewhere +S Don't Dream It's Over +S Love You Til The Day I Die +S Something So Strong +S Hole In The River +S Can't Carry On +S I Walk Away +S Tombstone +S That's What I Call Live +R Temple of Low Men +S I Feel Possessed +S Kill Eye +S Into Temptation +S Mansion In The Slums +S When You Come +S Never Be The Same +S Love This Life +S Sister Madly +S In The Lowlands +S Better Be Home Soon +R Woodface +S Chocolate Cake +S It's Only Natural +S Fall At Your Feet +S Tall Trees +S Weather With You +S Whispers and Moans +S Four Seasons in One Day +S There Goes God +S Fame Is +S All I Ask +S As Sure As I Am +S Italian Plastic +S She Goes On +S How Will You Go +R Together Alone +S Kare Kare +S In My Command +S Nails In My Feet +S Black & White Boy +S Fingers of Love +S Pineapple Head +S Locked Out +S Private Universe +S Walking on the Spot +S Distant Sun +S Catherine Wheels +S Skin Feeling +S Together Alone +A The Fixx +R Shuttered Room +S Some People +S Stand or Fall +S Cameras In Paris +S Shuttered Room +S The Fool +S Lost Planes +S I Live +S Sinking Island +S Time in a Glass +S Red Skies +R Reach The Beach +S One Thing Leads To Another +S The Sign of Fire +S Running +S Saved By Zero +S Opinions +S Reach The Beach +S Changing +S Liner +S Privilege +S Outside +R Phantoms +S Lose Face +S Less Cities, More Moving People +S Sunshine in the Shade +S Woman on a Train +S Wish +S Lost in Battle Overseas +S Question +S In Suspense +S Facing the Wind +S Are We Ourselves +S I Will +S Phantom Living +R Walkabout +S Secret Separation +S Built for the Future +S Treasure It +S Can't Finish +S Walkabout +S One Look Up +S Read Between The Lines +S Sense The Adventure +S Camphor +S Peace On Earth/Do What You Can +R Calm Animals +S I'm Life +S Driven Out +S Subterranean +S Precious Stone +S Gypsy Feet +S Calm Animals +S Shred of Evidence +S The Flow +S World Weary +S Caused To Be Alarmed +R Ink +S All is Fair +S How much Is Enough +S No One Has To Cry +S Crucified +S Falling In Love +S Shut It Out +S Still Around +S All The Best Things +S Yesterday, Today +S One Jungle +S Climb The Hill +S Make No Plans +R Elemental +S Two Different Views +S Going Without +S Is That It? +S Happy Landings +S Silent House +S Fatal Shore +S Ocean Blue +S You Know Me +S We Once Held Hands +S Life's What's Killing Me +A Harvin Garvel +R Harvin Garvel I +S Body +S What You Said +S All Rights Reserved +S High Purity +S Lies +S Get Real +S Gradma Cries +S First Feel +S Somethings wrong +S Shoes +S Spice Rack +S Dark Feel +S Tug of War +S Ant Song +R Harvin Garvel II +S We Ain't Through +S Trash and Spend +S Kick +S The Garden +S One & Only +S Squid Frenzy +S Soul In Soul +S The Desert +S He Grew Up +S Talk +S Image +S Tomorrow +S R70 +R Full Grown Dog +S I Am +S Say +S Is This Real +S What She Said +S Mirror Lies +S Girls +S Your Will +S Slow Motion Sunday +S Simple Life +S The Road Song +S The Same Way +S Stop Tryin +R Persia +S Exonic +S Drift +S Cruise +S MugWump +S Smear +S Everything +S Keep +S Circle +R Sensative Beak +S Whatcha Gotta Do +S Somewhere In This World +S Awaken +S Just A Dog +S I Can Dance +S Tomorrow +S Love Who? +S Is There Something +S I Like It +S Easy Chair +S As We Are One +S Far Away +S Leaving Science +S What A Life +A Komeda +R Plan 714 Till +S Fuego De La Vida +S Herbamore +S Som I Fjol +S En Spricka I Taket +R Genius Of +S More Is More +S Fire +S Rocket Plane (Music On The Moon) +S Boogie Woogie/Rock 'N' Roll +S Disko +S Top Star +S Light O' My Life +S If +S Frolic +S In Orbit +S Arbogast +S New New No +R What Makes It Go +S Binario +S It's Alright, Baby +S Curious +S Cul de Sac +S Living Things +S Flabbergast +S Campfire +S Happyment +S Our Hospitality +S Focus +S A Simple Formality +A Steve Miller Band +R Circle Of Love +S Heart Like A Wheel +S Get On Home +S Baby Wanna Dance +S Circle Of Love +S Macho City +R Fly Like An Eagle +S Space Intro +S Fly Like An Eagle +S Wild Mountain Honey +S Serenade +S Dance, Dance, Dance +S Mercury Blues +S Take the Money and Run +S Rockin' Me +S You Send Me +S Blue Odyssey +S Sweet Maree +S The Window +R Book Of Dreams +S Threshold +S Jet Airliner +S Winter Time +S Swingtown +S True Fine Love +S Wish Upon A Star +S Jungle Love +S Electrolux Imbroglio +S Sacrifice +S The Stake +S My Own Space +S Babes In The Wood +R Joker +S Sugar, Babe +S Mary Lou +S Shu Ba Da Du Ma +S Your Cash Ain't Nothin' But Trash +S The Joker +S The Lovin' Cup +S Come On In My Kitchen +S Evil +S Something To Believe In diff --git a/swingset3/com/sun/swingset3/demos/window/WindowDemo.java b/swingset3/com/sun/swingset3/demos/window/WindowDemo.java new file mode 100644 index 0000000..c2ca5a8 --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/window/WindowDemo.java @@ -0,0 +1,165 @@ +/* + * 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.demos.window; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; + +import com.sun.swingset3.DemoProperties; +import com.sun.swingset3.demos.DemoUtilities; + +/** + * @author aim + */ +@DemoProperties( + value = "JWindow Demo", + category = "Toplevel Containers", + description = "Demonstrates JWindow, a toplevel container with no system border.", + sourceFiles = { + "com/sun/swingset3/demos/window/WindowDemo.java", + "com/sun/swingset3/demos/DemoUtilities.java", + "com/sun/swingset3/demos/window/resources/WindowDemo.html", + "com/sun/swingset3/demos/window/resources/images/WindowDemo.gif" + } +) +public class WindowDemo extends JPanel { + + private JWindow window; + + private JComponent windowSpaceholder; + + public WindowDemo() { + initComponents(); + } + + protected void initComponents() { + window = createWindow(); + + setLayout(new BorderLayout()); + add(createControlPanel(), BorderLayout.WEST); + windowSpaceholder = createWindowSpaceholder(window); + add(windowSpaceholder, BorderLayout.CENTER); + } + + protected JComponent createControlPanel() { + Box controlPanel = Box.createVerticalBox(); + controlPanel.setBorder(new EmptyBorder(8, 8, 8, 8)); + + // Create button to control visibility of frame + JButton showButton = new JButton("Show JWindow..."); + showButton.addActionListener(new ShowActionListener()); + controlPanel.add(showButton); + + return controlPanel; + } + + private static JComponent createWindowSpaceholder(JWindow window) { + JPanel windowPlaceholder = new JPanel(); + Dimension prefSize = window.getPreferredSize(); + prefSize.width += 12; + prefSize.height += 12; + windowPlaceholder.setPreferredSize(prefSize); + + return windowPlaceholder; + } + + private static JWindow createWindow() { + + //Create window + JWindow window = new JWindow(); + // + + //Add a border to the window + window.getRootPane().setBorder(new LineBorder(Color.BLACK, 1)); + // + + //Add window's content + JLabel label = new JLabel("I have no system border."); + label.setHorizontalAlignment(JLabel.CENTER); + label.setPreferredSize(new Dimension(250, 200)); + window.add(label); + // + + //Initialize window's size + // which will shrink-to-fit its contents + window.pack(); + // + + return window; + } + + public void start() { + DemoUtilities.setToplevelLocation(window, windowSpaceholder, SwingConstants.CENTER); + showWindow(); + } + + public void stop() { + //Hide window + window.setVisible(false); + // + } + + public void showWindow() { + //Show window + // if window already visible, then bring to the front + if (window.isShowing()) { + window.toFront(); + } else { + window.setVisible(true); + } + // + } + + private class ShowActionListener implements ActionListener { + public void actionPerformed(ActionEvent actionEvent) { + showWindow(); + } + } + + public static void main(String args[]) { + EventQueue.invokeLater(new Runnable() { + public void run() { + JFrame frame = new JFrame(); + WindowDemo demo = new WindowDemo(); + frame.add(demo); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + demo.start(); + } + }); + } +} diff --git a/swingset3/com/sun/swingset3/demos/window/resources/WindowDemo.html b/swingset3/com/sun/swingset3/demos/window/resources/WindowDemo.html new file mode 100644 index 0000000..75e6dbb --- /dev/null +++ b/swingset3/com/sun/swingset3/demos/window/resources/WindowDemo.html @@ -0,0 +1,13 @@ + + + + +

+ Show how Swing's top-level container, + JWindow, can be used to create areas on the screen which + do not have system-supplied borders and therefore cannot be moved or resized + by the user like frames or dialogs. JWindow is commonly used to implement menus, + tooltips, and popups. +

+ + diff --git a/swingset3/com/sun/swingset3/demos/window/resources/images/WindowDemo.gif b/swingset3/com/sun/swingset3/demos/window/resources/images/WindowDemo.gif new file mode 100644 index 0000000..4eef882 Binary files /dev/null and b/swingset3/com/sun/swingset3/demos/window/resources/images/WindowDemo.gif differ diff --git a/swingset3/com/sun/swingset3/resources/SwingSet3.properties b/swingset3/com/sun/swingset3/resources/SwingSet3.properties new file mode 100644 index 0000000..c49210a --- /dev/null +++ b/swingset3/com/sun/swingset3/resources/SwingSet3.properties @@ -0,0 +1,25 @@ +# Sample ResourceBundle properties file +Application.id = SwingSet3 +Application.title = SwingSet3 +Application.version = .6 +Application.vendor = Sun Microsystems, Inc. +Application.vendorId = Sun +Application.homepage = https://swingset3.dev.java.net +Application.description = A demo showcase application for the Swing GUI toolkit +Application.icon = images/swingset3_icon.png + +mainFrame.title = ${Application.title} + +file.text = File +exit.text = Exit +view.text = View +lookAndFeel.text = Look and Feel +sourceCodeCheckboxItem.text = Show Source Code + +demos.title = GUI Components + +error.title = ${Application.title} Error +error.noDemosLoaded = ${Application.title} was unable to load demos \nbecause demo list was empty +error.unableToChangelookAndFeel = ${Application.title) was unable to switch look and feel + +demoPanel.loadingMessage = demo loading \ No newline at end of file diff --git a/swingset3/com/sun/swingset3/resources/default.html b/swingset3/com/sun/swingset3/resources/default.html new file mode 100644 index 0000000..7bdb71b --- /dev/null +++ b/swingset3/com/sun/swingset3/resources/default.html @@ -0,0 +1,16 @@ + + + + + DEMO_TITLE + + + + +
+ + +
+ + + diff --git a/swingset3/com/sun/swingset3/resources/images/about.jpg b/swingset3/com/sun/swingset3/resources/images/about.jpg new file mode 100644 index 0000000..45224dd Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/about.jpg differ diff --git a/swingset3/com/sun/swingset3/resources/images/home.png b/swingset3/com/sun/swingset3/resources/images/home.png new file mode 100644 index 0000000..2a89ad0 Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/home.png differ diff --git a/swingset3/com/sun/swingset3/resources/images/home_notext.png b/swingset3/com/sun/swingset3/resources/images/home_notext.png new file mode 100644 index 0000000..dd0f3aa Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/home_notext.png differ diff --git a/swingset3/com/sun/swingset3/resources/images/home_text.png b/swingset3/com/sun/swingset3/resources/images/home_text.png new file mode 100644 index 0000000..2efcb87 Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/home_text.png differ diff --git a/swingset3/com/sun/swingset3/resources/images/splash.png b/swingset3/com/sun/swingset3/resources/images/splash.png new file mode 100644 index 0000000..268290c Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/splash.png differ diff --git a/swingset3/com/sun/swingset3/resources/images/ss3_splash_nointro.png b/swingset3/com/sun/swingset3/resources/images/ss3_splash_nointro.png new file mode 100644 index 0000000..aaf4fc4 Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/ss3_splash_nointro.png differ diff --git a/swingset3/com/sun/swingset3/resources/images/swingset3_icon.png b/swingset3/com/sun/swingset3/resources/images/swingset3_icon.png new file mode 100644 index 0000000..6065782 Binary files /dev/null and b/swingset3/com/sun/swingset3/resources/images/swingset3_icon.png differ diff --git a/swingset3/com/sun/swingset3/utilities/AnimatingSplitPane.java b/swingset3/com/sun/swingset3/utilities/AnimatingSplitPane.java new file mode 100644 index 0000000..50d6267 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/AnimatingSplitPane.java @@ -0,0 +1,82 @@ +/* + * 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.utilities; + +import java.awt.Graphics; +import javax.swing.JSplitPane; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.basic.BasicSplitPaneDivider; +import javax.swing.plaf.basic.BasicSplitPaneUI; +import org.jdesktop.animation.timing.Animator; +import org.jdesktop.animation.timing.interpolation.PropertySetter; + +/** + * + * @author Amy Fowler + */ +public class AnimatingSplitPane extends JSplitPane { + private boolean firstExpanded = false; + + private int lastDividerLocation = -1; + + public AnimatingSplitPane(int orientation) { + super(orientation); + setOneTouchExpandable(false); + } + + public void setExpanded(boolean expanded) { + if (expanded != firstExpanded) { + + if (!firstExpanded) { + lastDividerLocation = getDividerLocation(); + } + + this.firstExpanded = expanded; + + Animator animator = new Animator(500, new PropertySetter(this, "dividerLocation", + getDividerLocation(), (expanded? getHeight() : lastDividerLocation))); + + animator.setStartDelay(10); + animator.setAcceleration(.2f); + animator.setDeceleration(.3f); + animator.start(); + } + } + + // workaround for bug where the animator blows up without it; + // possibly a bug in reflection when method is in super class (?) + public void setDividerLocation(int dividerLocation) { + super.setDividerLocation(dividerLocation); + } +} diff --git a/swingset3/com/sun/swingset3/utilities/ArrowIcon.java b/swingset3/com/sun/swingset3/utilities/ArrowIcon.java new file mode 100644 index 0000000..e5ac088 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/ArrowIcon.java @@ -0,0 +1,177 @@ +/* + * 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.utilities; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import javax.swing.Icon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.UIManager; + +/** + * + * @author Administrator + */ +public class ArrowIcon implements Icon, SwingConstants { + private static final float DB = -.06f; + private int direction; + private int size; + private Color color; + private BufferedImage arrowImage; + + public ArrowIcon(int direction) { + this(direction, 10, null); + } + + public ArrowIcon(int direction, Color color) { + this(direction, 10, color); + } + + public ArrowIcon(int direction, int size, Color color) { + this.size = size; + this.direction = direction; + this.color = color; + } + + public int getIconHeight() { + return size; + } + + public int getIconWidth() { + return size; + } + + public void paintIcon(Component c, Graphics g, int x, int y) { + g.drawImage(getArrowImage(), x, y, c); + } + + protected Image getArrowImage() { + if (arrowImage == null) { + arrowImage = Utilities.createTranslucentImage(size, size); + AffineTransform atx = direction != SOUTH? new AffineTransform() : null; + switch(direction ) { + case NORTH: + atx.setToRotation(Math.PI, size/2, size/2); + break; + case EAST: + atx.setToRotation(-(Math.PI/2), size/2, size/2); + break; + case WEST: + atx.setToRotation(Math.PI/2, size/2, size/2); + case SOUTH: + default:{ /* no xform*/ } + } + Graphics2D ig = (Graphics2D)arrowImage.getGraphics(); + if (atx != null) { + ig.setTransform(atx); + } + int width = size; + int height = size/2 + 1; + int xx = (size - width)/2; + int yy = (size - height + 1)/2; + + Color base = color != null? color : UIManager.getColor("controlDkShadow").darker(); + + paintArrow(ig, base, xx, yy); + paintArrowBevel(ig, base, xx, yy); + paintArrowBevel(ig, Utilities.deriveColorHSB(base, 0f, 0f, .20f), xx, yy + 1); + } + return arrowImage; + } + + protected void paintArrow(Graphics2D g, Color base, int x, int y) { + g.setColor(base); + /* + Path2D.Float arrowShape = new Path2D.Float(); + arrowShape.moveTo(x, y-1); + System.out.println("moveTo "+(x)+","+(y-1)); + arrowShape.lineTo(size-1, y-1); + System.out.println("lineTo "+(size-1)+","+(y-1)); + arrowShape.lineTo(size/2, y+(size/2)); + System.out.println("lineTo "+(size/2)+","+(y+(size/2))); + arrowShape.lineTo(size/2 - 1, y+(size/2)); + System.out.println("lineTo "+ (size/2 - 1)+","+(y+(size/2))); + arrowShape.lineTo(x, y-1); + System.out.println("lineTo "+(x)+","+(y-1)); + g.fill(arrowShape); +*/ + int len = size - 2; + int xx = x; + int yy = y-1; + while (len >= 2) { + xx++; + yy++; + g.fillRect(xx, yy, len, 1); + len -= 2; + } + } + + protected void paintArrowBevel(Graphics g, Color base, int x, int y) { + int len = size; + int xx = x; + int yy = y; + Color c2 = Utilities.deriveColorHSB(base, 0f, 0f, (-DB)*(size/2)); + while (len >= 2) { + c2 = Utilities.deriveColorHSB(c2, 0f, 0f, DB); + g.setColor(c2); + g.fillRect(xx, yy, 1, 1); + g.fillRect(xx + len - 1, yy, 1, 1); + len -= 2; + xx++; + yy++; + } + + } + public static void main(String args[]) { + JFrame frame = new JFrame(); + JPanel panel = new JPanel(); + frame.add(panel); + + panel.add(new JLabel("north", new ArrowIcon(ArrowIcon.NORTH), JLabel.CENTER)); + panel.add(new JLabel("west", new ArrowIcon(ArrowIcon.WEST), JLabel.CENTER)); + panel.add(new JLabel("south", new ArrowIcon(ArrowIcon.SOUTH), JLabel.CENTER)); + panel.add(new JLabel("east", new ArrowIcon(ArrowIcon.EAST), JLabel.CENTER)); + panel.add(new JLabel("east-20", new ArrowIcon(ArrowIcon.EAST, 20, Color.blue), JLabel.CENTER)); + + frame.pack(); + frame.setVisible(true); + } + +} diff --git a/swingset3/com/sun/swingset3/utilities/CollapsiblePanel.java b/swingset3/com/sun/swingset3/utilities/CollapsiblePanel.java new file mode 100644 index 0000000..c3c8c72 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/CollapsiblePanel.java @@ -0,0 +1,222 @@ +/* + * 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.utilities; + +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 javax.swing.Box; +import javax.swing.Icon; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.jdesktop.animation.timing.Animator; +import org.jdesktop.animation.timing.interpolation.PropertySetter; + +/** + * + * @author aim + */ +public class CollapsiblePanel extends JPanel { + public enum Orientation { HORIZONTAL, VERTICAL } + + private JPanel panel; + private JComponent child; + + private JCheckBox expandCheckBox; // may be null, if no title was supplied + private Orientation orientation = Orientation.VERTICAL; + private Dimension childPrefSize; + private boolean expanded = true; + + public CollapsiblePanel(JComponent child) { + this(child, Orientation.VERTICAL); + } + + public CollapsiblePanel(JComponent child, Orientation orientation) { + this.orientation = orientation; + this.child = child; + setLayout(new BorderLayout()); + panel = new JPanel(new BorderLayout()); + add(panel, BorderLayout.CENTER); + panel.add(child, BorderLayout.CENTER); + } + + /** Creates a new instance of CollapsiblePanel */ + public CollapsiblePanel(JComponent child, String title, String tooltip) { + this(child, Orientation.VERTICAL, title, tooltip); + } + + public CollapsiblePanel(JComponent child, String title) { + this(child, Orientation.VERTICAL, title, null); + } + + public CollapsiblePanel(JComponent child, Orientation orientation, + String title, String tooltip) { + this(child, orientation); + add(createCollapseControl(title, tooltip), + orientation == Orientation.HORIZONTAL? + BorderLayout.WEST : BorderLayout.NORTH); + + } + + protected Component createCollapseControl(String title, String tooltip) { + // Add upper panel to hold collapse control + Box box = Box.createHorizontalBox(); + + expandCheckBox = new JCheckBox(title); + expandCheckBox.setBorder(new EmptyBorder(0,4,0,0)); + expandCheckBox.setToolTipText(tooltip); + expandCheckBox.setHorizontalTextPosition(JCheckBox.RIGHT); + expandCheckBox.setSelectedIcon(new ArrowIcon(ArrowIcon.SOUTH)); + expandCheckBox.setIcon(new ArrowIcon(ArrowIcon.EAST)); + expandCheckBox.setSelected(isExpanded()); + + expandCheckBox.addChangeListener(new CollapseListener()); + box.add(expandCheckBox); + + return box; + } + + public void setExpanded(boolean expanded) { + boolean oldExpanded = this.expanded; + if (oldExpanded != expanded) { + if (expandCheckBox != null) { + expandCheckBox.setSelected(expanded); + } + childPrefSize = child.getPreferredSize(); + this.expanded = expanded; + + if (isShowing()) { + // only animate if currently showing + Animator animator = null; + if (orientation == Orientation.VERTICAL) { + animator = new Animator(600, new PropertySetter(this, "collapseHeight", + expanded ? 0 : childPrefSize.height, expanded ? childPrefSize.height : 0)); + + } + if (orientation == Orientation.HORIZONTAL) { + animator = new Animator(600, new PropertySetter(this, "collapseWidth", + expanded ? 0 : childPrefSize.width, expanded ? childPrefSize.width : 0)); + } + animator.setStartDelay(10); + animator.setAcceleration(.2f); + animator.setDeceleration(.3f); + animator.start(); + } else { + if (orientation == Orientation.VERTICAL) { + setCollapseHeight(expanded? childPrefSize.height : 0); + + } else if (orientation == Orientation.HORIZONTAL) { + setCollapseWidth(expanded? childPrefSize.width : 0); + } + } + firePropertyChange("expanded", oldExpanded, expanded); + + } + } + + // intended only for animator, but must be public + public void setCollapseHeight(int height) { + panel.setPreferredSize(new Dimension(childPrefSize.width, height)); + child.revalidate(); + repaint(); + } + + // intended only for animator, but must be public + public void setCollapseWidth(int width) { + panel.setPreferredSize(new Dimension(width, childPrefSize.height)); + child.revalidate(); + repaint(); + } + + public boolean isExpanded() { + return expanded; + } + + public void setExpandedIcon(Icon expandedIcon) { + if (expandCheckBox != null) { + expandCheckBox.setSelectedIcon(expandedIcon); + } + } + + public void setCollapsedIcon(Icon collapsedIcon) { + if (expandCheckBox != null) { + expandCheckBox.setIcon(collapsedIcon); + } + } + + @Override + public void setFont(Font font) { + super.setFont(font); + if (expandCheckBox != null) { + expandCheckBox.setFont(font); + } + } + + @Override + public void setForeground(Color foreground) { + super.setForeground(foreground); + if (expandCheckBox != null) { + expandCheckBox.setForeground(foreground); + } + } + + @Override + public void updateUI() { + super.updateUI(); + //configureDefaults(); + } + + protected void configureDefaults() { + if (expandCheckBox != null) { + if (UIManager.getLookAndFeel().getName().equals("Nimbus")) { + expandCheckBox.setBorder(new EmptyBorder(0,4,0,0)); + } else { + expandCheckBox.setBorder(new EmptyBorder(0,0,0,0)); + } + } + } + + // only used if checkbox is present + private class CollapseListener implements ChangeListener { + public void stateChanged(ChangeEvent event) { + setExpanded(expandCheckBox.isSelected()); + } + } +} diff --git a/swingset3/com/sun/swingset3/utilities/DefaultsDisplay.java b/swingset3/com/sun/swingset3/utilities/DefaultsDisplay.java new file mode 100644 index 0000000..7eff534 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/DefaultsDisplay.java @@ -0,0 +1,561 @@ +/* + * 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.utilities; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.*; +import javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.LookAndFeel; +import javax.swing.RowFilter; +import javax.swing.SwingUtilities; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; + +/** + * Simple application which displays the contents of the UIDefaults hash map + * for the current look and feel. + * + * @author aim + */ +public class DefaultsDisplay extends JPanel { + private static final int rowHeight = 32; + + public static void main(String[] args) { + + EventQueue.invokeLater(new Runnable() { + public void run() { + JFrame frame = new JFrame("UIDefaults Display"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.add(new DefaultsDisplay()); + frame.pack(); + frame.setVisible(true); + } + }); + } + + + private String OSXLookAndFeelName; // hack for look-and-feel name mismatch on OS X + + private Map lookAndFeelsMap; + private final Map defaultsTablesMap; + + private JComboBox lookAndFeelComboBox; + private JCheckBox onlyVisualsCheckBox; + private JTabbedPane tabPane; + + private RowFilter visualsFilter; + + + /** Creates a new instance of DefaultsDisplayer */ + public DefaultsDisplay() { + defaultsTablesMap = new HashMap(); + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + if (System.getProperty("os.name").equals("Mac OS X")) { + OSXLookAndFeelName = UIManager.getLookAndFeel().getName(); + } + } catch (Exception ex) { + // better work :-) + } + + setLayout(new BorderLayout()); + + JPanel controls = new JPanel(); + controls.add(createLookAndFeelControl()); + controls.add(createFilterControl()); + add(controls, BorderLayout.NORTH); + + tabPane = new JTabbedPane(); + add(tabPane, BorderLayout.CENTER); + + addDefaultsTab(); + + } + + protected JComponent createLookAndFeelControl() { + JPanel panel = new JPanel(); + + JLabel label = new JLabel("Current Look and Feel"); + lookAndFeelComboBox = new JComboBox(); + label.setLabelFor(lookAndFeelComboBox); + panel.add(label); + panel.add(lookAndFeelComboBox); + + // Look for toolkit look and feels first + UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels(); + lookAndFeelsMap = new HashMap(); + for(UIManager.LookAndFeelInfo info : lookAndFeelInfos) { + String name = info.getName(); + // workaround for problem where Info and name property don't match on OS X + if (name.equals("Mac OS X")) { + name = OSXLookAndFeelName; + } + // workaround for bug where Nimbus classname is incorrect + lookAndFeelsMap.put(name, name.equals("Nimbus")? + "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" : + info.getClassName()); + lookAndFeelComboBox.addItem(name); + } + lookAndFeelComboBox.setSelectedItem(UIManager.getLookAndFeel().getName()); + lookAndFeelComboBox.addActionListener(new ChangeLookAndFeelAction()); + + return panel; + } + + protected JComponent createFilterControl() { + + onlyVisualsCheckBox = new JCheckBox("Show Only Visual Defaults"); + onlyVisualsCheckBox.setSelected(true); + onlyVisualsCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + boolean showOnlyVisuals = onlyVisualsCheckBox.isSelected(); + for(int i = 0; i < tabPane.getTabCount() ; i++) { + JScrollPane scrollpane = (JScrollPane)tabPane.getComponentAt(i); + JTable table = (JTable)scrollpane.getViewport().getView(); + TableRowSorter sorter = (TableRowSorter)table.getRowSorter(); + sorter.setRowFilter(showOnlyVisuals? visualsFilter : null); + } + } + }); + return onlyVisualsCheckBox; + } + + protected boolean hasDefaultsTab(String lookAndFeelName) { + return defaultsTablesMap.get(lookAndFeelName) != null; + } + + protected void addDefaultsTab() { + LookAndFeel lookAndFeel = UIManager.getLookAndFeel(); + JScrollPane scrollPane = new JScrollPane(createDefaultsTable()); + tabPane.addTab(lookAndFeel.getName() + " Defaults", scrollPane); + defaultsTablesMap.put(lookAndFeel.getName(), scrollPane); + } + + protected JTable createDefaultsTable() { + JTable table = new JTable(new UIDefaultsTableModel()); + table.setRowHeight(rowHeight); + table.setShowHorizontalLines(false); + table.setShowVerticalLines(false); + table.setIntercellSpacing(new Dimension(0,0)); + table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + initFilters(table); + + DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); + + Color rowColors[] = new Color[2]; + rowColors[0] = UIManager.getColor("Table.background"); + rowColors[1] = new Color((int)(rowColors[0].getRed() * .90), + (int)(rowColors[0].getGreen() * .95), + (int)(rowColors[0].getBlue() * .95)); + + int width = 0; + + TableColumn column = new TableColumn(); + column.setCellRenderer(new KeyRenderer(rowColors)); + column.setModelIndex(UIDefaultsTableModel.KEY_COLUMN); + column.setHeaderValue("Key"); + column.setPreferredWidth(250); + columnModel.addColumn(column); + width += column.getPreferredWidth(); + + column = new TableColumn(); + column.setCellRenderer(new RowRenderer(rowColors)); + column.setModelIndex(UIDefaultsTableModel.TYPE_COLUMN); + column.setHeaderValue("Type"); + column.setPreferredWidth(250); + columnModel.addColumn(column); + width += column.getPreferredWidth(); + + column = new TableColumn(); + column.setCellRenderer(new ValueRenderer(rowColors)); + column.setModelIndex(UIDefaultsTableModel.VALUE_COLUMN); + column.setHeaderValue("Value"); + column.setPreferredWidth(300); + columnModel.addColumn(column); + width += column.getPreferredWidth(); + + table.setColumnModel(columnModel); + + table.setPreferredScrollableViewportSize(new Dimension(width, 12 * rowHeight)); + + return table; + + } + + protected void initFilters(JTable table) { + TableRowSorter sorter = new TableRowSorter(table.getModel()); + table.setRowSorter(sorter); + + if (visualsFilter == null) { + visualsFilter = new RowFilter() { + public boolean include(Entry entry) { + UIDefaultsTableModel model = entry.getModel(); + Object defaultsValue = model.getValueAt(entry.getIdentifier().intValue(), + UIDefaultsTableModel.VALUE_COLUMN); + + return defaultsValue instanceof Color || + defaultsValue instanceof Font || + defaultsValue instanceof Icon; + } + }; + } + + if (onlyVisualsCheckBox.isSelected()) { + sorter.setRowFilter(visualsFilter); + } + } + + private class ChangeLookAndFeelAction extends AbstractAction { + + public ChangeLookAndFeelAction() { + super("Change LookAndFeel"); + } + + public void actionPerformed(ActionEvent event) { + String lookAndFeelName = (String)lookAndFeelComboBox.getSelectedItem(); + try { + UIManager.setLookAndFeel(lookAndFeelsMap.get(lookAndFeelName)); + SwingUtilities.updateComponentTreeUI(DefaultsDisplay.this.getTopLevelAncestor()); + if (!hasDefaultsTab(lookAndFeelName)) { + addDefaultsTab(); + } + tabPane.setSelectedComponent(defaultsTablesMap.get(lookAndFeelName)); + } catch (Exception ex) { + System.err.println("could not change look and feel to " + lookAndFeelName); + System.err.println(ex); + } + } + } + + private static class UIDefaultsTableModel extends AbstractTableModel { + private static final int KEY_COLUMN = 0; + private static final int TYPE_COLUMN = 1; + private static final int VALUE_COLUMN = 2; + + private UIDefaults defaults; + private List keys; + + public UIDefaultsTableModel() { + // make a local copy of the defaults table in case the look and feel changes + defaults = new UIDefaults(); + keys = new ArrayList(); + UIDefaults realDefaults = UIManager.getDefaults(); + Enumeration keysEnum = realDefaults.keys(); + while (keysEnum.hasMoreElements()) { + Object key = keysEnum.nextElement(); + if (!defaults.containsKey(key)) { + keys.add(key); + defaults.put(key, realDefaults.get(key)); + } else { + System.out.println("found duplicate key:"+key); + } + } + } + + public int getColumnCount() { + return 3; + } + + public int getRowCount() { + return defaults.size(); + } + + public Class getColumnClass(int column) { + Class klass = null; + switch(column) { + case KEY_COLUMN: { + klass = String.class; + break; + } + case TYPE_COLUMN: { + klass = String.class; + break; + } + case VALUE_COLUMN: { + klass = Object.class; + } + } + return klass; + } + + public Object getValueAt(int row, int column) { + Object value = null; + switch(column) { + case KEY_COLUMN: { + value = keys.get(row); + break; + } + case TYPE_COLUMN: { + Object key = keys.get(row); + Object defaultsValue = defaults.get(key); + value = defaultsValue != null? defaultsValue.getClass().getName() : ""; + break; + } + case VALUE_COLUMN: { + value = defaults.get(keys.get(row)); + } + } + return value; + } + + } + + private static class RowRenderer extends JLabel implements TableCellRenderer { + private final Color[] rowColors; + private final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); + + public RowRenderer(Color colors[]) { + rowColors = colors; + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + setText(value != null? value.toString() : "unknown"); + setIcon(null); + setColors(table, row, isSelected); + setBorder(this, hasFocus, isSelected); + return this; + } + + protected void setColors(JTable table, int row, boolean isSelected) { + if (!isSelected) { + setBackground(rowColors[row % rowColors.length]); + setForeground(table.getForeground()); + } else { + setBackground(table.getSelectionBackground()); + setForeground(table.getSelectionForeground()); + } + } + + protected void setBorder(JComponent renderer, boolean hasFocus, boolean isSelected) { + + if (hasFocus) { + Border border = null; + if (isSelected) { + border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); + } + if (border == null) { + border = UIManager.getBorder("Table.focusCellHighlightBorder"); + } + renderer.setBorder(border); + + } else { + renderer.setBorder(noFocusBorder); + } + } + } + + private static class KeyRenderer extends RowRenderer { + + public KeyRenderer(Color colors[]) { + super(colors); + setFont(getFont().deriveFont(Font.BOLD)); + } + } + + private static class ValueRenderer extends RowRenderer { + private final JButton buttonIconRenderer; + private final JRadioButton radioIconRenderer; + private final JMenuItem menuItemIconRenderer; + private final JCheckBox checkboxIconRenderer; + + public ValueRenderer(Color colors[]) { + super(colors); + buttonIconRenderer = new JButton(); + buttonIconRenderer.setBorderPainted(false); + buttonIconRenderer.setContentAreaFilled(false); + buttonIconRenderer.setText("(for AbstractButtons only)"); + radioIconRenderer = new JRadioButton(); + radioIconRenderer.setBorderPainted(false); + radioIconRenderer.setText("for JRadioButtons only)"); + checkboxIconRenderer = new JCheckBox(); + checkboxIconRenderer.setBorderPainted(false); + checkboxIconRenderer.setText("for JCheckBoxes only)"); + menuItemIconRenderer = new JMenuItem(); + menuItemIconRenderer.setBorderPainted(false); + menuItemIconRenderer.setText("(for JMenuItems only)"); + + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + JComponent renderer = null; + + if (value instanceof Icon) { + Icon icon = (Icon)value; + // Hack to fix problem where some plaf Icons cast the component to + // various component classes. yikes! not very re-usable icons :( + String className = (String)table.getValueAt(row, UIDefaultsTableModel.TYPE_COLUMN); + if (className.contains("BasicIconFactory$RadioButtonMenuItemIcon") || + className.contains("BasicIconFactory$CheckBoxMenuItemIcon") || + className.contains("OceanTheme$IFIcon") || + className.contains("MotifIconFactory$RadioButtonIcon") || + className.contains("MotifIconFactory$CheckBoxIcon") || + className.contains("MotifIconFactory$MenuArrowIcon") || + className.contains("WindowsIconFactory$FrameButtonIcon") || + className.contains("WindowsIconFactory$RadioButtonIcon")) { + buttonIconRenderer.setIcon(icon); + buttonIconRenderer.setSelected(true); + renderer = buttonIconRenderer; + + } else if (className.contains("MetalIconFactory$RadioButtonIcon")) { + radioIconRenderer.setIcon(icon); + renderer = radioIconRenderer; + + } else if (className.contains("MetalIconFactory$RadioButtonMenuItemIcon") || + className.contains("MetalIconFactory$CheckBoxMenuItemIcon") || + className.contains("MetalIconFactory$MenuArrowIcon") || + className.contains("MetalIconFactory$MenuItemArrowIcon")) { + menuItemIconRenderer.setIcon(icon); + menuItemIconRenderer.setSelected(true); + renderer = menuItemIconRenderer; + + } else if (className.contains("MetalIconFactory$CheckBoxIcon") || + className.contains("WindowsIconFactory$CheckBoxIcon")) { + checkboxIconRenderer.setIcon(icon); + checkboxIconRenderer.setSelected(true); + renderer = checkboxIconRenderer; + } + } + + if (renderer != null) { + // special hack renderer for icons needs to be colorized because + // it doesn't extend RowRenderer + setColors(table, row, isSelected); + setBorder(renderer, hasFocus, isSelected); + + } else { + // renderer == this + renderer = (JComponent)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (value instanceof Color) { + Color color = (Color)value; + float[] hsb = Color.RGBtoHSB(color.getRed(), + color.getGreen(), color.getBlue(), null); + + setIcon(ColorIcon.getIcon(color)); + setText("RGB=" + color.getRed() + ","+ color.getGreen() + ","+ color.getBlue() + " " + + "HSB=" + String.format("%.0f%n",hsb[0]*360) + "," + + String.format("%.3f%n",hsb[1]) + "," + + String.format("%.3f%n", hsb[2])); + + } else if (value instanceof Font) { + Font font = (Font)value; + setFont(font); + setText(font.getFontName() + " size="+ font.getSize2D()); + setIcon(null); + + } else if (value instanceof Icon) { + setIcon((Icon)value); + setText(""); + } + } + return renderer; + } + + @Override + protected void paintComponent(Graphics g) { + try { + super.paintComponent(g); + } catch (ClassCastException ex) { + System.out.println("cast exception:" + ex.getMessage()); + } + } + } + + private static class ColorIcon implements Icon { + private static HashMap icons; + + private Color color; + private int size = DefaultsDisplay.rowHeight - 3; + + public static ColorIcon getIcon(Color color) { + if (icons == null) { + icons = new HashMap(); + } + ColorIcon icon = icons.get(color); + if (icon == null) { + icon = new ColorIcon(color); + icons.put(color, icon); + } + return icon; + } + + protected ColorIcon(Color color) { + this.color = color; + } + + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(color); + g.fillRect(x, y, size, size); + g.setColor(Color.black); + g.drawRect(x, y, size, size); + } + + public int getIconWidth() { + return size; + } + + public int getIconHeight() { + return size; + } + } +} diff --git a/swingset3/com/sun/swingset3/utilities/GradientPanel.java b/swingset3/com/sun/swingset3/utilities/GradientPanel.java new file mode 100644 index 0000000..5028777 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/GradientPanel.java @@ -0,0 +1,94 @@ +/* + * 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.utilities; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import javax.swing.JPanel; + +/** + * Simple panel subclass which renders a 2-color vertical linear gradient + * as the background. + * @author Aim + */ +public class GradientPanel extends JPanel { + private final Color[] colors = new Color[2]; + private Image image; + + public GradientPanel(Color color1, Color color2) { + super(); + setOpaque(false); // unfortunately required to disable automatic bg painting + setBackground(color1); // in case colors are derived from background + colors[0] = color1; + colors[1] = color2; + } + + public void setGradientColor1(Color color) { + changeGradientColor(0, color); + } + + public void setGradientColor2(Color color) { + changeGradientColor(1, color); + } + + protected void changeGradientColor(int colorIndex, Color newColor) { + Color oldColor = colors[colorIndex]; + colors[colorIndex] = newColor; + if (!oldColor.equals(newColor)) { + image = null; + firePropertyChange("gradientColor"+colorIndex, oldColor, newColor); + } + } + + protected Image getGradientImage() { + Dimension size = getSize(); + if (image == null || + image.getWidth(null) != size.width || + image.getHeight(null) != size.height) { + + image = Utilities.createGradientImage(size.width, size.height, + colors[0], colors[1]); + + } + return image; + } + + @Override + protected void paintComponent(Graphics g) { + Image gradientImage = getGradientImage(); + g.drawImage(gradientImage, 0, 0, null); + super.paintComponent(g); + } + +} diff --git a/swingset3/com/sun/swingset3/utilities/HTMLPanel.java b/swingset3/com/sun/swingset3/utilities/HTMLPanel.java new file mode 100644 index 0000000..2025836 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/HTMLPanel.java @@ -0,0 +1,185 @@ +/* + * 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.utilities; + +import java.awt.Component; +import java.awt.Cursor; +import java.awt.EventQueue; +import java.util.EventListener; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.AbstractDocument; +import javax.swing.text.AttributeSet; +import javax.swing.text.Element; +import javax.swing.text.StyleConstants; +import javax.swing.text.View; +import javax.swing.text.ViewFactory; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.ObjectView; + +import com.sun.swingset3.demos.DemoUtilities; + +/** + * + * Extends JEditorPane for more convenient display of an HTML page. + *

+ * Swing's HTML support allows Swing components to be embedded in the HTML using + * the tag, + * e.g.
+ *
    
+ *	
+ * 
+ * These embedded components will be instantiated deep inside the text package and
+ * it is difficult to get a handle on the resulting instantiated component instance.
+ * Thus, this class supports adding a ComponentCreationListener to be notified just
+ * after the component is created.

+ *

+ * This class also automatically installs a hyperlink listener to ensure that + * clicking on hyperlinks bring up the associated url in the browser. + * + * @author aim + */ +public class HTMLPanel extends JEditorPane { + /** + * Callback interface for getting notification when components specified in the + * tag are created in the editor pane. + */ + public static interface ComponentCreationListener extends EventListener { + public void componentCreated(HTMLPanel htmlPanel, Component component); + } + + private static HyperlinkHandler hyperlinkHandler; + + /** + * Creates a new instance of HTMLPanel with a default content type of "text/html" + */ + public HTMLPanel() { + setContentType("text/html"); + setEditorKit(new ComponentEditorKit()); // brute force + setEditable(false); // VERY IMPORTANT! + if (hyperlinkHandler == null) { + hyperlinkHandler = new HyperlinkHandler(); + } + addHyperlinkListener(hyperlinkHandler); + } + + public void addComponentCreationListener(HTMLPanel.ComponentCreationListener l) { + listenerList.add(ComponentCreationListener.class, l); + } + + public void removeComponentCreationListener(HTMLPanel.ComponentCreationListener l) { + listenerList.remove(HTMLPanel.ComponentCreationListener.class, l); + } + + private class ComponentEditorKit extends HTMLEditorKit { + @Override + public ViewFactory getViewFactory() { + return new ComponentFactory(); + } + } + + protected class ComponentFactory extends HTMLEditorKit.HTMLFactory { + public ComponentFactory() { + super(); + } + + @Override + public View create(Element element) { + AttributeSet attrs = element.getAttributes(); + Object elementName = + attrs.getAttribute(AbstractDocument.ElementNameAttribute); + Object o = (elementName != null) ? + null : attrs.getAttribute(StyleConstants.NameAttribute); + if (o instanceof HTML.Tag) { + if (o == HTML.Tag.OBJECT) { + return new ComponentView(element); + } + } + return super.create(element); + } + } + + protected class ComponentView extends ObjectView { + public ComponentView(Element element) { + super(element); + } + + @Override + protected Component createComponent() { + final Component component = super.createComponent(); + + Runnable notifier = new Runnable() { + public void run() { + final ComponentCreationListener listeners[] = + HTMLPanel.this.listenerList.getListeners(ComponentCreationListener.class); + for (ComponentCreationListener l : listeners) { + l.componentCreated(HTMLPanel.this, component); + } + } + }; + // just in case document is being loaded in separate thread. (?) + if (EventQueue.isDispatchThread()) { + notifier.run(); + } else { + EventQueue.invokeLater(notifier); + } + return component; + } + } + + // single instance of handler is shared for ALL DemoPanel instances + public static class HyperlinkHandler implements HyperlinkListener { + Cursor defaultCursor; + + public void hyperlinkUpdate(HyperlinkEvent event) { + JEditorPane descriptionPane = (JEditorPane) event.getSource(); + HyperlinkEvent.EventType type = event.getEventType(); + if (type == HyperlinkEvent.EventType.ACTIVATED) { + try { + DemoUtilities.browse(event.getURL().toURI()); + } catch (Exception e) { + e.printStackTrace(); + System.err.println(e); + } + + } else if (type == HyperlinkEvent.EventType.ENTERED) { + defaultCursor = descriptionPane.getCursor(); + descriptionPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + + } else if (type == HyperlinkEvent.EventType.EXITED) { + descriptionPane.setCursor(defaultCursor); + } + } + } +} diff --git a/swingset3/com/sun/swingset3/utilities/RoundedBorder.java b/swingset3/com/sun/swingset3/utilities/RoundedBorder.java new file mode 100644 index 0000000..8179273 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/RoundedBorder.java @@ -0,0 +1,87 @@ +/* + * 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.utilities; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.RenderingHints; +import javax.swing.border.Border; + +/** + * + * @author Administrator + */ +public class RoundedBorder implements Border { + private int cornerRadius; + + public RoundedBorder() { + this(10); + } + + public RoundedBorder(int cornerRadius) { + this.cornerRadius = cornerRadius; + } + + public Insets getBorderInsets(Component c) { + return getBorderInsets(c, new Insets(0,0,0,0)); + } + + public Insets getBorderInsets(Component c, Insets insets) { + insets.top = insets.bottom = cornerRadius/2; + insets.left = insets.right = 1; + return insets; + } + + public boolean isBorderOpaque() { + return false; + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2 = (Graphics2D)g.create(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + Color color = Utilities.deriveColorHSB(c.getBackground(), 0, 0, -.3f); + + g2.setColor(Utilities.deriveColorAlpha(color, 40)); + g2.drawRoundRect(x, y + 2, width - 1, height - 3, cornerRadius, cornerRadius); + g2.setColor(Utilities.deriveColorAlpha(color, 90)); + g2.drawRoundRect(x, y + 1, width - 1, height - 2, cornerRadius, cornerRadius); + g2.setColor(Utilities.deriveColorAlpha(color, 255)); + g2.drawRoundRect(x, y, width - 1, height - 1, cornerRadius, cornerRadius); + + g2.dispose(); + } +} diff --git a/swingset3/com/sun/swingset3/utilities/RoundedPanel.java b/swingset3/com/sun/swingset3/utilities/RoundedPanel.java new file mode 100644 index 0000000..9b1276b --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/RoundedPanel.java @@ -0,0 +1,108 @@ +/* + * 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.utilities; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LayoutManager; +import java.awt.geom.RoundRectangle2D; +import javax.swing.JFrame; +import javax.swing.JPanel; +import org.jdesktop.swingx.JXPanel; + +/** + * + * @author Administrator + */ +public class RoundedPanel extends JXPanel { + private final int cornerRadius; + private boolean contentAreaFilled; + + private transient RoundRectangle2D.Float roundBounds; + + public RoundedPanel() { + this(10); + } + + public RoundedPanel(LayoutManager layout) { + this(layout, 10); + } + + public RoundedPanel(int cornerRadius) { + this(new FlowLayout(), cornerRadius); + } + + public RoundedPanel(LayoutManager layout, int cornerRadius) { + super(layout); + this.cornerRadius = cornerRadius; + this.roundBounds = new RoundRectangle2D.Float(0,0,0,0, + cornerRadius, cornerRadius); + this.contentAreaFilled = true; + setOpaque(false); + } + + public void setContentAreaFilled(boolean contentFilled) { + this.contentAreaFilled = contentFilled; + } + + public boolean isContentAreaFilled() { + return contentAreaFilled; + } + + @Override + protected void paintComponent(Graphics g) { + if (isContentAreaFilled()) { + Graphics2D g2 = (Graphics2D) g; + Dimension size = getSize(); + roundBounds.width = size.width; + roundBounds.height = size.height; + g2.setColor(getBackground()); + g2.fill(roundBounds); + } + super.paintComponent(g); + } + + public static void main(String args[]) { + JFrame frame = new JFrame(); + RoundedPanel p = new RoundedPanel(new BorderLayout(), 16); + JPanel p2 = new JPanel(); + p2.setBackground(Color.blue); + p.add(p2); + frame.add(p); + frame.setSize(200, 200); + frame.setVisible(true); + } +} diff --git a/swingset3/com/sun/swingset3/utilities/RoundedTitleBorder.java b/swingset3/com/sun/swingset3/utilities/RoundedTitleBorder.java new file mode 100644 index 0000000..438e829 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/RoundedTitleBorder.java @@ -0,0 +1,113 @@ +/* + * 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.utilities; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.FontMetrics; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; + +/** + * + * @author Administrator + */ +public class RoundedTitleBorder extends RoundedBorder { + private final String title; + private final Color[] titleGradientColors; + + public RoundedTitleBorder(String title, Color titleGradientColor1, Color titleGradientColor2) { + super(10); + this.title = title; + this.titleGradientColors = new Color[2]; + this.titleGradientColors[0] = titleGradientColor1; + this.titleGradientColors[1] = titleGradientColor2; + } + + public Insets getBorderInsets(Component c, Insets insets) { + Insets borderInsets = super.getBorderInsets(c, insets); + borderInsets.top = getTitleHeight(c); + return borderInsets; + } + + protected int getTitleHeight(Component c) { + FontMetrics metrics = c.getFontMetrics(c.getFont()); + return (int)(metrics.getHeight() * 1.80); + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + int titleHeight = getTitleHeight(c); + + // create image with vertical gradient and then use alpha composite to + // render the image with a horizontal fade + BufferedImage titleImage = Utilities.createTranslucentImage(width, titleHeight); + GradientPaint gradient = new GradientPaint(0, 0, + titleGradientColors[0], 0, titleHeight, + titleGradientColors[1], false); + Graphics2D g2 = (Graphics2D)titleImage.getGraphics(); + g2.setPaint(gradient); + g2.fillRoundRect(x, y, width, height, 10, 10); + g2.setColor(Utilities.deriveColorHSB( + titleGradientColors[1], 0, 0, -.2f)); + g2.drawLine(x + 1, titleHeight - 1, width - 2, titleHeight - 1); + g2.setColor(Utilities.deriveColorHSB( + titleGradientColors[1], 0, -.5f, .5f)); + g2.drawLine(x + 1, titleHeight, width - 2, titleHeight); + g2.setPaint(new GradientPaint(0, 0, new Color(0.0f, 0.0f, 0.0f, 1.0f), + width, 0, new Color(0.0f, 0.0f, 0.0f, 0.0f))); + g2.setComposite(AlphaComposite.DstIn); + g2.fillRect(x, y, width, titleHeight); + g2.dispose(); + + g.drawImage(titleImage, x, y, c); + + // draw rounded border + super.paintBorder(c, g, x, y, width, height); + + // draw title string + g2 = (Graphics2D)g.create(); + g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2.setColor(c.getForeground()); + g2.setFont(c.getFont()); + FontMetrics metrics = c.getFontMetrics(c.getFont()); + g2.drawString(title, x + 8, + y + (titleHeight - metrics.getHeight())/2 + metrics.getAscent()); + g2.dispose(); + + } +} diff --git a/swingset3/com/sun/swingset3/utilities/Utilities.java b/swingset3/com/sun/swingset3/utilities/Utilities.java new file mode 100644 index 0000000..2b19ad6 --- /dev/null +++ b/swingset3/com/sun/swingset3/utilities/Utilities.java @@ -0,0 +1,159 @@ +/* + * 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.utilities; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.Transparency; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.net.URL; +import javax.jnlp.ServiceManager; +import javax.swing.SwingConstants; + +/** + * + * @author aim + */ +public class Utilities { + + private Utilities() { + // never instantiate + } + + public static boolean runningFromWebStart() { + return ServiceManager.getServiceNames() != null; + } + + public static String getURLFileName(URL url) { + String path = url.getPath(); + return path.substring(path.lastIndexOf("/") + 1); + } + + private static BufferedImage createCompatibleImage(int width, int height) { + + return GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height); + + } + + public static BufferedImage createTranslucentImage(int width, int height) { + + return GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); + + } + + public static BufferedImage createGradientImage(int width, int height, Color gradient1, Color gradient2) { + + BufferedImage gradientImage = createCompatibleImage(width, height); + GradientPaint gradient = new GradientPaint(0, 0, gradient1, 0, height, gradient2, false); + Graphics2D g2 = (Graphics2D)gradientImage.getGraphics(); + g2.setPaint(gradient); + g2.fillRect(0, 0, width, height); + g2.dispose(); + + return gradientImage; + } + + + public static BufferedImage createGradientMask(int width, int height, int orientation) { + // algorithm derived from Romain Guy's blog + BufferedImage gradient = new BufferedImage(width, height, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g = gradient.createGraphics(); + GradientPaint paint = new GradientPaint(0.0f, 0.0f, + new Color(1.0f, 1.0f, 1.0f, 1.0f), + orientation == SwingConstants.HORIZONTAL? width : 0.0f, + orientation == SwingConstants.VERTICAL? height : 0.0f, + new Color(1.0f, 1.0f, 1.0f, 0.0f)); + g.setPaint(paint); + g.fill(new Rectangle2D.Double(0, 0, width, height)); + + g.dispose(); + gradient.flush(); + + return gradient; + } + + public static Color deriveColorAlpha(Color base, int alpha) { + return new Color(base.getRed(), base.getGreen(), base.getBlue(), alpha); + } + + /** + * Derives a color by adding the specified offsets to the base color's + * hue, saturation, and brightness values. The resulting hue, saturation, + * and brightness values will be contrained to be between 0 and 1. + * @param base the color to which the HSV offsets will be added + * @param dH the offset for hue + * @param dS the offset for saturation + * @param dB the offset for brightness + * @return Color with modified HSV values + */ + public static Color deriveColorHSB(Color base, float dH, float dS, float dB) { + float hsb[] = Color.RGBtoHSB( + base.getRed(), base.getGreen(), base.getBlue(), null); + + hsb[0] += dH; + hsb[1] += dS; + hsb[2] += dB; + return Color.getHSBColor( + hsb[0] < 0? 0 : (hsb[0] > 1? 1 : hsb[0]), + hsb[1] < 0? 0 : (hsb[1] > 1? 1 : hsb[1]), + hsb[2] < 0? 0 : (hsb[2] > 1? 1 : hsb[2])); + + } + + public static String getHTMLColorString(Color color) { + String red = Integer.toHexString(color.getRed()); + String green = Integer.toHexString(color.getGreen()); + String blue = Integer.toHexString(color.getBlue()); + + return "#" + + (red.length() == 1? "0" + red : red) + + (green.length() == 1? "0" + green : green) + + (blue.length() == 1? "0" + blue : blue); + } + + public static void printColor(String key, Color color) { + float hsb[] = Color.RGBtoHSB( + color.getRed(), color.getGreen(), + color.getBlue(), null); + System.out.println(key+": RGB=" + + color.getRed() + ","+ color.getGreen() + ","+ color.getBlue() + " " + + "HSB=" + String.format("%.0f%n",hsb[0]*360) + "," + + String.format("%.3f%n",hsb[1]) + "," + + String.format("%.3f%n", hsb[2])); + } +} diff --git a/swingset3/org/jdesktop/swingx/JXPanel.java b/swingset3/org/jdesktop/swingx/JXPanel.java new file mode 100644 index 0000000..19cd51a --- /dev/null +++ b/swingset3/org/jdesktop/swingx/JXPanel.java @@ -0,0 +1,220 @@ +/* + * $Id: JXPanel.java,v 1.27 2007/11/25 15:52:56 kschaefe Exp $ + * + * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, + * Santa Clara, California 95054, U.S.A. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package org.jdesktop.swingx; + +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LayoutManager; +import java.awt.Rectangle; + +import java.awt.image.BufferedImage; +import javax.swing.JPanel; +import javax.swing.RepaintManager; +import javax.swing.Scrollable; +import org.jdesktop.swingx.RepaintManagerX; +import org.jdesktop.swingx.TranslucentRepaintManager; +import org.jdesktop.swingx.graphics.GraphicsUtilities; + +/** + * A simple JPanel extension that adds translucency support. + * This component and all of its content will be displayed with the specified + * "alpha" transluscency property value. It also supports the + * Painters using the backgroundPainter property. For example, to change the background of the + * panel to a checkeboard do something like this: + * + * + *
 JXPanel panel = new JXPanel();
+ * panel.setBackgroundPainter(new CheckerboardPainter());
+ * @author rbair + * + * Note: This has been imported directly into the SwingSet3 source in order + * to make a critical bugfix which was needed for SwingSet3. + */ +public class JXPanel extends JPanel implements Scrollable { + private boolean scrollableTracksViewportHeight; + private boolean scrollableTracksViewportWidth; + + /** + * The alpha level for this component. + */ + private float alpha = 1.0f; + /** + * If the old alpha value was 1.0, I keep track of the opaque setting because + * a translucent component is not opaque, but I want to be able to restore + * opacity to its default setting if the alpha is 1.0. Honestly, I don't know + * if this is necessary or not, but it sounded good on paper :) + *

TODO: Check whether this variable is necessary or not

+ */ + private boolean oldOpaque; + + /** + * Creates a new instance of JXPanel + */ + public JXPanel() { + } + + /** + * @param isDoubleBuffered + */ + public JXPanel(boolean isDoubleBuffered) { + super(isDoubleBuffered); + } + + /** + * @param layout + */ + public JXPanel(LayoutManager layout) { + super(layout); + } + + /** + * @param layout + * @param isDoubleBuffered + */ + public JXPanel(LayoutManager layout, boolean isDoubleBuffered) { + super(layout, isDoubleBuffered); + } + + /** + * Set the alpha transparency level for this component. This automatically + * causes a repaint of the component. + * + * @param alpha must be a value between 0 and 1 inclusive. + */ + public void setAlpha(float alpha) { + if (alpha < 0 || alpha > 1) { + throw new IllegalArgumentException("Alpha must be between 0 and 1 inclusive"); + } + + if (this.alpha != alpha) { + float oldAlpha = this.alpha; + this.alpha = alpha; + if (alpha > 0f && alpha < 1f) { + if (oldAlpha == 1) { + //it used to be 1, but now is not. Save the oldOpaque + oldOpaque = isOpaque(); + setOpaque(false); + } + + //TODO this was quite the controversial choice, in automatically + //replacing the repaint manager. In retrospect, I'd probably + //opt for making this a manual choice. There really isn't a clear + //win, no matter the approach. + RepaintManager manager = RepaintManager.currentManager(this); + if (!manager.getClass().isAnnotationPresent(TranslucentRepaintManager.class)) { + RepaintManager.setCurrentManager(new RepaintManagerX()); + } + } else if (alpha == 1) { + //restore the oldOpaque if it was true (since opaque is false now) + if (oldOpaque) { + setOpaque(true); + } + } + firePropertyChange("alpha", oldAlpha, alpha); + repaint(); + } + } + + /** + * @return the alpha translucency level for this component. This will be + * a value between 0 and 1, inclusive. + */ + public float getAlpha() { + return alpha; + } + + /* (non-Javadoc) + * @see javax.swing.Scrollable#getScrollableTracksViewportHeight() + */ + public boolean getScrollableTracksViewportHeight() { + return scrollableTracksViewportHeight; + } + + /* (non-Javadoc) + * @see javax.swing.Scrollable#getScrollableTracksViewportWidth() + */ + public boolean getScrollableTracksViewportWidth() { + return scrollableTracksViewportWidth; + } + + /* (non-Javadoc) + * @see javax.swing.Scrollable#getPreferredScrollableViewportSize() + */ + public Dimension getPreferredScrollableViewportSize() { + return getPreferredSize(); + } + + /* (non-Javadoc) + * @see javax.swing.Scrollable#getScrollableBlockIncrement(java.awt.Rectangle, int, int) + */ + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { + return 10; + } + + /* (non-Javadoc) + * @see javax.swing.Scrollable#getScrollableUnitIncrement(java.awt.Rectangle, int, int) + */ + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { + return 10; + } + /** + * @param scrollableTracksViewportHeight The scrollableTracksViewportHeight to set. + */ + public void setScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight) { + this.scrollableTracksViewportHeight = scrollableTracksViewportHeight; + } + /** + * @param scrollableTracksViewportWidth The scrollableTracksViewportWidth to set. + */ + public void setScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth) { + this.scrollableTracksViewportWidth = scrollableTracksViewportWidth; + } + + /** + * Overriden paint method to take into account the alpha setting + * @param g + */ + @Override + public void paint(Graphics g) { + float a = getAlpha(); + if (a == 1) { + super.paint(g); + } else { + //the component is translucent, so we need to render to + //an intermediate image before painting + BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(getWidth(), getHeight()); + Graphics2D gfx = img.createGraphics(); + super.paint(gfx); + gfx.dispose(); + Graphics2D g2d = (Graphics2D)g; + Composite oldComp = g2d.getComposite(); + Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, a); + g2d.setComposite(alphaComp); + g2d.drawImage(img, null, 0, 0); + g2d.setComposite(oldComp); + } + } +} +