@@ -12,6 +12,7 @@ import java.awt.Insets
1212import java.awt.GridBagConstraints
1313import java.awt.Dimension
1414import java.awt.GridBagLayout
15+ import java.awt.GridLayout
1516import java.awt.Point
1617import java.awt.event.*
1718
@@ -263,7 +264,12 @@ class ToM_ui{
263264 }
264265
265266// genera panel con botón
266- def static createButtonPanel (htmlMsg , buttonLabel , buttonToolTip , buttonAction , boolean isToggleButton = false ){
267+ def static createButtonPanel (String htmlMsg , buttonLabel , buttonToolTip , buttonAction , boolean isToggleButton = false ){
268+ def botones = [] << [buttonLabel, buttonToolTip, buttonAction, null , isToggleButton]
269+ createButtonPanel(htmlMsg, botones)
270+ }
271+
272+ def static createButtonPanel (String htmlMsg , botones ){
267273 def panel = swing. panel(
268274 border : new LineBorder (Color . gray, 1 ),
269275 name : myButtonPanelName,
@@ -279,33 +285,45 @@ class ToM_ui{
279285 constraints : CENTER ,
280286 clientProperties : [(JEditorPane . HONOR_DISPLAY_PROPERTIES ):true ]
281287 )
282- vbox(constraints :SOUTH ) {
288+ if (botones. size()> 0 ){
289+ panel(
290+ constraints :EAST ,
291+ background : Color . white,
292+ ) {
293+ borderLayout()
283294 panel(
284- // border : new LineBorder(Color.black, 1),
285- border : new EmptyBorder (2 , 10 , 2 , 10 ), // <------- éste
286- // border: new CompoundBorder(new LineBorder(Color.red, 1),new EmptyBorder(5, 10, 5, 10)) // éste es de prueba poder ver el borde
287- // insets : new Insets(30,10,30,10),
288- ) {
289- borderLayout()
290- if (isToggleButton){
295+ constraints :SOUTH ,
296+ background : Color . white,
297+ // // border : new LineBorder(Color.black, 1),
298+ border : new EmptyBorder (2 , 2 , 2 , 2 ), // <------- éste
299+ // //border: new CompoundBorder(new LineBorder(Color.red, 1),new EmptyBorder(5, 10, 5, 10)) // éste es de prueba poder ver el borde
300+ // //insets : new Insets(30,10,30,10),
301+ ) {
302+ gridLayout(new GridLayout (0 ,1 ))
303+ botones. each{ b ->
304+ if ( b[4 ] == true ){
291305 toggleButton(
292- label : buttonLabel,
293- constraints : EAST ,
294- margin : new Insets (10 ,15 ,10 ,15 ),
295- toolTipText : buttonToolTip,
296- actionPerformed : buttonAction,
306+ label : b[0 ],
307+ // constraints : EAST,
308+ margin : new Insets (3 ,6 ,3 ,6 ),
309+ toolTipText : b[1 ],
310+ actionPerformed : b[2 ],
311+ icon : b[3 ],
297312 )
298313 } else {
299314 button(
300- label : buttonLabel,
301- constraints : EAST ,
302- margin : new Insets (10 ,15 ,10 ,15 ),
303- toolTipText : buttonToolTip,
304- actionPerformed : buttonAction,
315+ label : b[0 ],
316+ // constraints : EAST,
317+ margin : new Insets (3 ,6 ,3 ,6 ),
318+ toolTipText : b[1 ],
319+ actionPerformed : b[2 ],
320+ icon : b[3 ],
305321 )
306322 }
307323 }
308- }
324+ }
325+ }
326+ }
309327 }
310328 return panel
311329 }
0 commit comments