Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import groovy.swing.SwingBuilder
- import javax.swing.JFrame
- import javax.swing.JOptionPane
- import java.awt.Color
- import java.awt.Font
- import static javax.swing.SwingConstants.BOTTOM
- import static javax.swing.SwingConstants.CENTER
- import static javax.swing.WindowConstants.*
- import static javax.swing.JOptionPane.showInputDialog
- final fontSizeList = ['FlowLayout', 'BorderLayout', 'GridLayout', 'BoxLayout', 'MigLayout']
- swing = new SwingBuilder()
- JFrame f = new JFrame()
- def choosenLayout = showInputDialog(f,"Choose layout",
- "Layouts",
- JOptionPane.QUESTION_MESSAGE, null, fontSizeList as Object[], 'FlowLayout'
- )
- swing.edt {
- lookAndFeel('nimbus')
- frame(title: 'Layout demo', pack: true, visible: true,
- defaultCloseOperation: EXIT_ON_CLOSE) {
- panel() {
- button( id: 'buttonFlowLayout',
- text: 'FLowLayout',
- foreground: Color.BLUE,
- background: Color.GREEN,
- font: new Font('Dialog', Font.BOLD, 24),
- verticalTextPosition: BOTTOM,
- horizontalTextPosition: CENTER,
- actionPerformed: {
- // button1.background = colorsList[counter]
- // counter++
- // if(counter > colorsList.size() -1) counter = 0
- }
- )
- button( id: 'buttonBorderLayout',
- text: 'BorderLayout',
- foreground: Color.BLUE,
- background: Color.GREEN,
- font: new Font('Dialog', Font.BOLD, 24),
- verticalTextPosition: BOTTOM,
- horizontalTextPosition: CENTER,
- actionPerformed: {
- // button1.background = colorsList[counter]
- // counter++
- // if(counter > colorsList.size() -1) counter = 0
- }
- )
- button( id: 'buttonGridLayout',
- text: 'GridLayout',
- foreground: Color.BLUE,
- background: Color.GREEN,
- font: new Font('Dialog', Font.BOLD, 24),
- verticalTextPosition: BOTTOM,
- horizontalTextPosition: CENTER,
- actionPerformed: {
- // button1.background = colorsList[counter]
- // counter++
- // if(counter > colorsList.size() -1) counter = 0
- }
- )
- button( id: 'buttonBoxLayout',
- text: 'BoxLayout',
- foreground: Color.BLUE,
- background: Color.GREEN,
- font: new Font('Dialog', Font.BOLD, 24),
- verticalTextPosition: BOTTOM,
- horizontalTextPosition: CENTER,
- actionPerformed: {
- // button1.background = colorsList[counter]
- // counter++
- // if(counter > colorsList.size() -1) counter = 0
- }
- )
- button( id: 'buttonMigLayout',
- text: 'MigLayout',
- foreground: Color.BLUE,
- background: Color.GREEN,
- font: new Font('Dialog', Font.BOLD, 24),
- verticalTextPosition: BOTTOM,
- horizontalTextPosition: CENTER,
- actionPerformed: {
- // button1.background = colorsList[counter]
- // counter++
- // if(counter > colorsList.size() -1) counter = 0
- }
- )
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement