Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package builders.swing.miglayout.simple
- import groovy.swing.SwingBuilder
- import net.miginfocom.swing.MigLayout
- import javafx.scene.layout.VBox;
- import javax.swing.BoxLayout
- import javax.swing.Icon
- import javax.swing.JScrollPane
- import javax.swing.plaf.IconUIResource
- import java.awt.Font
- import static javax.swing.WindowConstants.EXIT_ON_CLOSE
- import static javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE
- import java.awt.image.*;
- import javax.swing.ImageIcon
- //Fonts
- Font title = new Font("Serif", Font.BOLD, 30)
- Font name = new Font("Serif", Font.BOLD, 25)
- //Contact List
- def Names = ["James","Jhon","Jim","Jerry","Barry","Bill","Bob","Bill","Brexit","Bowser","Tara","Angry Cat","Neon Cat","Pepper","Freddie","Dog","Cat","Tiger","bear",] as String[]
- //Number Of contacts
- int numPanels= 17
- swing = new SwingBuilder()
- swing.build {
- frame1 = frame(
- title: "Contacts",
- pack: true,
- show: true,
- defaultCloseOperation: EXIT_ON_CLOSE,
- layout: new MigLayout(
- "fill",
- "[][][][]", //Column constraints
- "[]10[]" //Row constraints
- )
- ) {
- label(text: "Welcome to your contacts book", constraints: "dock north,gap 50px 50px, span 6,wrap , height 60px").setFont(title)
- scrollPane( verticalScrollBarPolicy: JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ) {
- vbox{
- (0..numPanels).each { num ->
- def Contact = Names[num]
- label(text: "$Contact", constraints: "align left, span 3, gap 100px 0px").setFont(name)
- button(text: "Menu", constraints: "align right,span 3, gap 0px 100px, wrap",actionPerformed:{
- frame1.setEnabled(false);
- frame2 = frame(
- title: "Contacts",
- pack: true,
- show: true,
- defaultCloseOperation: DO_NOTHING_ON_CLOSE,
- layout: new MigLayout(
- "fill",
- "[][][][]", //Column constraints
- "[]10[]" //Row constraints
- )
- ){
- label(text: "$Contact", constraints: "align left, span 3, gap 10px 0px").setFont(name)
- button( id: "buttonpanel$num", text:"OK", actionPerformed: {
- frame1.setEnabled(true);
- frame2.visible = false
- }
- )
- }
- })
- }
- }
- }
- boxLayout(axis: BoxLayout.Y_AXIS)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement