SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
2011   2   26
Griffon
                Groovy


                Swing


                DI   MVC   CoC

                            Java


2011   2   26
Swing(Java)
       package sample;                                                        contentPane.add(button);

       import   java.awt.Container;                                           setDefaultCloseOperation(EXIT_ON_CLOSE);
       import   java.awt.GridLayout;                                          pack();
       import   java.awt.event.ActionEvent;                                   setVisible(true);
       import   java.awt.event.ActionListener;                            }

       import   javax.swing.JButton;                                      public static void main(String[] args) {
       import   javax.swing.JFrame;                                           SwingUtilities.invokeLater(new Runnable() {
       import   javax.swing.JLabel;                                               public void run() {
       import   javax.swing.JTextArea;                                                new Hello();
       import   javax.swing.SwingUtilities;                                       }
                                                                              });
       public class Hello extends JFrame {                                }
                                                                      }
            public Hello() {
                super("Hello");

                 Container contentPane = getContentPane();
                 contentPane.setLayout(new GridLayout(3, 1));

                 JLabel label = new JLabel("Label");
                 contentPane.add(label);

                 JTextArea textArea = new JTextArea("Text Area");
                 textArea.setColumns(20);
                 textArea.setRows(2);
                 contentPane.add(textArea);

                 JButton button = new JButton("Button");
                 button.addActionListener(new ActionListener() {
                     public void actionPerformed(ActionEvent evt) {

                       }
                 });



2011   2   26
Groovy
                import groovy.swing.SwingBuilder

                new SwingBuilder().edt {
                    frame(title:'Hello', show:true, pack:true) {
                        gridLayout(cols:1, rows:3)
                        label 'Label'
                        textArea('Text Area', rows:2, columns:20)
                        button('Button', actionPerformed:{ evt ->
                            ...
                        })
                    }
                }




2011   2   26
import groovy.swing.SwingBuilder

           new SwingBuilder().edt {
               frame(title:'Login', show:true, pack:true) {
                   tableLayout {
                       tr {
                            td {
                                 label 'User Name'
                            }
                            td {
                                 textField(columns:20)
                            }
                       }
                       tr {
                            td {
                                 label 'Password'
                            }
                            td {
                                 passwordField(columns:20)
                            }
                       }
                       tr {
                            td(colspan:2, align:'right') {
                                 button 'Submit'
                            }
                       }
                   }
               }
           }

2011   2   26
2011   2   26
Java Swing


2011   2   26
2011   2   26
button.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        ...
                    }
                });

                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        ...
                    }
                });




2011   2   26
Groovy
                import groovy.swing.SwingBuilder

                new SwingBuilder().edt {
                    frame(title:'Hello', show:true, pack:true) {
                        gridLayout(cols:1, rows:3)
                        label 'Label'
                        textArea('Text Area', rows:2, columns:20)
                        button('Button', actionPerformed:{ evt ->
                            ...
                        })
                    }
                }




2011   2   26
Groovy




2011   2   26
2011   2   26
Getting Started
                $ griffon create-app myapp
                $ cd myapp
                $ griffon run-app




2011   2   26
Griffon   MVC




                MVC
2011   2   26
2011   2   26
// Model
                import groovy.beans.Bindable
                class SampleModel {
                    @Bindable String text
                }


                // View
                application(...) {
                    textField(text:bind(source:model, ’text’))
                }


                 Model                         View
2011   2   26
// Model
                import groovy.beans.Bindable
                class SampleModel {
                    @Bindable String text
                }


                // View
                application(...) {
                    textField(text:bind(target:model, ’text’))
                }


                 View                      Model
2011   2   26
2011   2   26
Java
                public void actionPerformed(ActionEvent evt) {
                    new Thread() {
                        public void run() {
                            heavyTask();
                            try {
                                SwingUtilities.invokeAndWait(new Runnable() {
                                    public void run() {
                                         textArea.append("Complete!n");
                                    }
                                });
                            } catch (InterruptedException e) {
                                ...
                            } catch (InvocationTargetException e) {
                                ...
                            }
                        }
                    }.start();
                }




2011   2   26
Groovy

                // Controller
                def heavyAction = { evt ->
                    doOutside {
                        heavyTask()
                        edt {
                            textArea.append 'Complete!n'
                        }
                    }
                }




2011   2   26
2011   2   26
2011   2   26
2011   2   26
2011   2   26
2011   2   26
http://www.jroller.com/aalmiray/entry/so_who_uses_griffon_afterall
2011   2   26
2011   2   26

Weitere ähnliche Inhalte

Was ist angesagt? (6)

Condicional
CondicionalCondicional
Condicional
 
ECMA2015 INSIDE
ECMA2015 INSIDEECMA2015 INSIDE
ECMA2015 INSIDE
 
Lista trabajador
Lista trabajadorLista trabajador
Lista trabajador
 
Создание новых объектов
Создание новых объектовСоздание новых объектов
Создание новых объектов
 
Gui component
Gui componentGui component
Gui component
 
Membuat kalkulator penilaian Sederhana Java
Membuat kalkulator penilaian Sederhana JavaMembuat kalkulator penilaian Sederhana Java
Membuat kalkulator penilaian Sederhana Java
 

Andere mochten auch

Andere mochten auch (7)

BaseScriptについて
BaseScriptについてBaseScriptについて
BaseScriptについて
 
Jenkins plugin memo
Jenkins plugin memoJenkins plugin memo
Jenkins plugin memo
 
ミニ四駆ジャパンカップで勝つ方法を考える
ミニ四駆ジャパンカップで勝つ方法を考えるミニ四駆ジャパンカップで勝つ方法を考える
ミニ四駆ジャパンカップで勝つ方法を考える
 
javafx-mini4wd
javafx-mini4wdjavafx-mini4wd
javafx-mini4wd
 
Spockの基礎
Spockの基礎Spockの基礎
Spockの基礎
 
JUC2012
JUC2012JUC2012
JUC2012
 
Advanced java programming-contents
Advanced java programming-contentsAdvanced java programming-contents
Advanced java programming-contents
 

Mehr von Kiyotaka Oku

巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
Kiyotaka Oku
 
GDK48総選挙の裏側
GDK48総選挙の裏側GDK48総選挙の裏側
GDK48総選挙の裏側
Kiyotaka Oku
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
Kiyotaka Oku
 
Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜
Kiyotaka Oku
 
日本Grails/Groovyユーザーグループ
日本Grails/Groovyユーザーグループ日本Grails/Groovyユーザーグループ
日本Grails/Groovyユーザーグループ
Kiyotaka Oku
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 
Jenkinsプラグインの作り方
Jenkinsプラグインの作り方Jenkinsプラグインの作り方
Jenkinsプラグインの作り方
Kiyotaka Oku
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and Groovy
Kiyotaka Oku
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語
Kiyotaka Oku
 
Groovy and-hudson2
Groovy and-hudson2Groovy and-hudson2
Groovy and-hudson2
Kiyotaka Oku
 

Mehr von Kiyotaka Oku (18)

Osaka Venture Meetup #3
Osaka Venture Meetup #3Osaka Venture Meetup #3
Osaka Venture Meetup #3
 
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
 
GDK48総選挙の裏側
GDK48総選挙の裏側GDK48総選挙の裏側
GDK48総選挙の裏側
 
Jenkins入門
Jenkins入門Jenkins入門
Jenkins入門
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
 
Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜
 
日本Grails/Groovyユーザーグループ
日本Grails/Groovyユーザーグループ日本Grails/Groovyユーザーグループ
日本Grails/Groovyユーザーグループ
 
GroovyConsole2
GroovyConsole2GroovyConsole2
GroovyConsole2
 
GroovyConsole
GroovyConsoleGroovyConsole
GroovyConsole
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
Jenkinsプラグインの作り方
Jenkinsプラグインの作り方Jenkinsプラグインの作り方
Jenkinsプラグインの作り方
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and Groovy
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語
 
Mote Hudson
Mote HudsonMote Hudson
Mote Hudson
 
Groovy and-hudson2
Groovy and-hudson2Groovy and-hudson2
Groovy and-hudson2
 
Gaelyk
GaelykGaelyk
Gaelyk
 
JDO
JDOJDO
JDO
 
Grails on GAE/J
Grails on GAE/JGrails on GAE/J
Grails on GAE/J
 

Devsumi Openjam

  • 1. 2011 2 26
  • 2. Griffon Groovy Swing DI MVC CoC Java 2011 2 26
  • 3. Swing(Java) package sample; contentPane.add(button); import java.awt.Container; setDefaultCloseOperation(EXIT_ON_CLOSE); import java.awt.GridLayout; pack(); import java.awt.event.ActionEvent; setVisible(true); import java.awt.event.ActionListener; } import javax.swing.JButton; public static void main(String[] args) { import javax.swing.JFrame; SwingUtilities.invokeLater(new Runnable() { import javax.swing.JLabel; public void run() { import javax.swing.JTextArea; new Hello(); import javax.swing.SwingUtilities; } }); public class Hello extends JFrame { } } public Hello() { super("Hello"); Container contentPane = getContentPane(); contentPane.setLayout(new GridLayout(3, 1)); JLabel label = new JLabel("Label"); contentPane.add(label); JTextArea textArea = new JTextArea("Text Area"); textArea.setColumns(20); textArea.setRows(2); contentPane.add(textArea); JButton button = new JButton("Button"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { } }); 2011 2 26
  • 4. Groovy import groovy.swing.SwingBuilder new SwingBuilder().edt { frame(title:'Hello', show:true, pack:true) { gridLayout(cols:1, rows:3) label 'Label' textArea('Text Area', rows:2, columns:20) button('Button', actionPerformed:{ evt -> ... }) } } 2011 2 26
  • 5. import groovy.swing.SwingBuilder new SwingBuilder().edt { frame(title:'Login', show:true, pack:true) { tableLayout { tr { td { label 'User Name' } td { textField(columns:20) } } tr { td { label 'Password' } td { passwordField(columns:20) } } tr { td(colspan:2, align:'right') { button 'Submit' } } } } } 2011 2 26
  • 6. 2011 2 26
  • 8. 2011 2 26
  • 9. button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ... } }); SwingUtilities.invokeLater(new Runnable() { public void run() { ... } }); 2011 2 26
  • 10. Groovy import groovy.swing.SwingBuilder new SwingBuilder().edt { frame(title:'Hello', show:true, pack:true) { gridLayout(cols:1, rows:3) label 'Label' textArea('Text Area', rows:2, columns:20) button('Button', actionPerformed:{ evt -> ... }) } } 2011 2 26
  • 11. Groovy 2011 2 26
  • 12. 2011 2 26
  • 13. Getting Started $ griffon create-app myapp $ cd myapp $ griffon run-app 2011 2 26
  • 14. Griffon MVC MVC 2011 2 26
  • 15. 2011 2 26
  • 16. // Model import groovy.beans.Bindable class SampleModel { @Bindable String text } // View application(...) { textField(text:bind(source:model, ’text’)) } Model View 2011 2 26
  • 17. // Model import groovy.beans.Bindable class SampleModel { @Bindable String text } // View application(...) { textField(text:bind(target:model, ’text’)) } View Model 2011 2 26
  • 18. 2011 2 26
  • 19. Java public void actionPerformed(ActionEvent evt) { new Thread() { public void run() { heavyTask(); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { textArea.append("Complete!n"); } }); } catch (InterruptedException e) { ... } catch (InvocationTargetException e) { ... } } }.start(); } 2011 2 26
  • 20. Groovy // Controller def heavyAction = { evt -> doOutside { heavyTask() edt { textArea.append 'Complete!n' } } } 2011 2 26
  • 21. 2011 2 26
  • 22. 2011 2 26
  • 23. 2011 2 26
  • 24. 2011 2 26
  • 25. 2011 2 26
  • 27. 2011 2 26