Advertisement
Guest User

Untitled

a guest
Jan 11th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 3.76 KB | None | 0 0
  1. import groovy.swing.SwingBuilder
  2. import javax.swing.JFrame
  3. import javax.swing.JOptionPane
  4. import java.awt.Color
  5. import java.awt.Font
  6.  
  7. import static javax.swing.SwingConstants.BOTTOM
  8. import static javax.swing.SwingConstants.CENTER
  9. import static javax.swing.WindowConstants.*
  10.  
  11.  
  12. import static javax.swing.JOptionPane.showInputDialog
  13.  
  14. final fontSizeList = ['FlowLayout', 'BorderLayout', 'GridLayout', 'BoxLayout', 'MigLayout']
  15. swing = new SwingBuilder()
  16. JFrame f = new JFrame()
  17. def choosenLayout = showInputDialog(f,"Choose layout",
  18.         "Layouts",
  19.         JOptionPane.QUESTION_MESSAGE, null, fontSizeList as Object[], 'FlowLayout'
  20.  
  21. )
  22. swing.edt {
  23.     lookAndFeel('nimbus')
  24.  
  25.     frame(title: 'Layout demo', pack: true, visible: true,
  26.             defaultCloseOperation: EXIT_ON_CLOSE) {
  27.  
  28.         panel() {
  29.             button( id: 'buttonFlowLayout',
  30.                     text: 'FLowLayout',
  31.                     foreground: Color.BLUE,
  32.                     background: Color.GREEN,
  33.                     font: new Font('Dialog', Font.BOLD, 24),
  34.                     verticalTextPosition: BOTTOM,
  35.                     horizontalTextPosition: CENTER,
  36.                     actionPerformed: {
  37. //                        button1.background = colorsList[counter]
  38. //                        counter++
  39. //                        if(counter > colorsList.size() -1) counter = 0
  40.                     }
  41.             )
  42.             button( id: 'buttonBorderLayout',
  43.                     text: 'BorderLayout',
  44.                     foreground: Color.BLUE,
  45.                     background: Color.GREEN,
  46.                     font: new Font('Dialog', Font.BOLD, 24),
  47.                     verticalTextPosition: BOTTOM,
  48.                     horizontalTextPosition: CENTER,
  49.                     actionPerformed: {
  50. //                        button1.background = colorsList[counter]
  51. //                        counter++
  52. //                        if(counter > colorsList.size() -1) counter = 0
  53.                     }
  54.             )
  55.             button( id: 'buttonGridLayout',
  56.                     text: 'GridLayout',
  57.                     foreground: Color.BLUE,
  58.                     background: Color.GREEN,
  59.                     font: new Font('Dialog', Font.BOLD, 24),
  60.                     verticalTextPosition: BOTTOM,
  61.                     horizontalTextPosition: CENTER,
  62.                     actionPerformed: {
  63. //                        button1.background = colorsList[counter]
  64. //                        counter++
  65. //                        if(counter > colorsList.size() -1) counter = 0
  66.                     }
  67.             )
  68.             button( id: 'buttonBoxLayout',
  69.                     text: 'BoxLayout',
  70.                     foreground: Color.BLUE,
  71.                     background: Color.GREEN,
  72.                     font: new Font('Dialog', Font.BOLD, 24),
  73.                     verticalTextPosition: BOTTOM,
  74.                     horizontalTextPosition: CENTER,
  75.                     actionPerformed: {
  76. //                        button1.background = colorsList[counter]
  77. //                        counter++
  78. //                        if(counter > colorsList.size() -1) counter = 0
  79.                     }
  80.             )
  81.             button( id: 'buttonMigLayout',
  82.                     text: 'MigLayout',
  83.                     foreground: Color.BLUE,
  84.                     background: Color.GREEN,
  85.                     font: new Font('Dialog', Font.BOLD, 24),
  86.                     verticalTextPosition: BOTTOM,
  87.                     horizontalTextPosition: CENTER,
  88.                     actionPerformed: {
  89. //                        button1.background = colorsList[counter]
  90. //                        counter++
  91. //                        if(counter > colorsList.size() -1) counter = 0
  92.                     }
  93.             )
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement