Advertisement
Guest User

Untitled

a guest
Feb 14th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. package builders.swing.miglayout.simple
  2. import groovy.swing.SwingBuilder
  3. import net.miginfocom.swing.MigLayout
  4. import javafx.scene.layout.VBox;
  5. import javax.swing.BoxLayout
  6. import javax.swing.Icon
  7. import javax.swing.JScrollPane
  8. import javax.swing.plaf.IconUIResource
  9. import java.awt.Font
  10.  
  11. import static javax.swing.WindowConstants.EXIT_ON_CLOSE
  12. import static javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE
  13. import java.awt.image.*;
  14. import javax.swing.ImageIcon
  15.  
  16.  
  17. //Fonts
  18. Font title = new Font("Serif", Font.BOLD, 30)
  19. Font name = new Font("Serif", Font.BOLD, 25)
  20.  
  21.  
  22. //Contact List
  23. 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[]
  24.  
  25.  
  26.  
  27. //Number Of contacts
  28. int numPanels= 17
  29.  
  30. swing = new SwingBuilder()
  31. swing.build {
  32. frame1 = frame(
  33. title: "Contacts",
  34. pack: true,
  35. show: true,
  36. defaultCloseOperation: EXIT_ON_CLOSE,
  37. layout: new MigLayout(
  38. "fill",
  39. "[][][][]", //Column constraints
  40. "[]10[]" //Row constraints
  41. )
  42. ) {
  43. label(text: "Welcome to your contacts book", constraints: "dock north,gap 50px 50px, span 6,wrap , height 60px").setFont(title)
  44.  
  45.  
  46. scrollPane( verticalScrollBarPolicy: JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ) {
  47. vbox{
  48. (0..numPanels).each { num ->
  49. def Contact = Names[num]
  50. label(text: "$Contact", constraints: "align left, span 3, gap 100px 0px").setFont(name)
  51. button(text: "Menu", constraints: "align right,span 3, gap 0px 100px, wrap",actionPerformed:{
  52. frame1.setEnabled(false);
  53. frame2 = frame(
  54. title: "Contacts",
  55. pack: true,
  56. show: true,
  57. defaultCloseOperation: DO_NOTHING_ON_CLOSE,
  58. layout: new MigLayout(
  59. "fill",
  60. "[][][][]", //Column constraints
  61. "[]10[]" //Row constraints
  62. )
  63. ){
  64.  
  65. label(text: "$Contact", constraints: "align left, span 3, gap 10px 0px").setFont(name)
  66. button( id: "buttonpanel$num", text:"OK", actionPerformed: {
  67. frame1.setEnabled(true);
  68. frame2.visible = false
  69.  
  70.  
  71. }
  72. )
  73. }
  74. })
  75.  
  76. }
  77. }
  78. }
  79. boxLayout(axis: BoxLayout.Y_AXIS)
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement