Skip to content

Commit edb50c4

Browse files
committed
Update ToM_ui.groovy
adding methods getButtonPanel() and getTabContentPane() to be called from the clicked button in the panel
1 parent 5991371 commit edb50c4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Tutorial-o-Matic/src/main/groovy/ToM_ui.groovy

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import java.awt.GridBagLayout
1515
import javax.swing.border.EmptyBorder
1616
import javax.swing.border.LineBorder
1717
import javax.swing.border.CompoundBorder
18+
import javax.swing.SwingUtilities as SU
1819

1920
import groovy.swing.SwingBuilder
2021

@@ -27,7 +28,8 @@ class ToM_ui{
2728

2829
static final int minContentPaneWidth = 408
2930
static final int maxContentPaneHeigth = 50000
30-
static final String myPaneName = 'PanelDeContenido'
31+
static final String myPaneName = 'myContentPanel'
32+
static final String myButtonPanelName = 'aButtonPane'
3133

3234
static SwingBuilder swing = new SwingBuilder()
3335

@@ -120,7 +122,15 @@ class ToM_ui{
120122
}
121123
}
122124

123-
def static getTabContentPane(tabName){
125+
def static getButtonPanel(javax.swing.JComponent comp){
126+
return SU.getAncestorNamed(myButtonPanelName, comp)
127+
}
128+
129+
def static getTabContentPane(javax.swing.JComponent comp){
130+
return SU.getAncestorNamed(myPaneName, comp)
131+
}
132+
133+
def static getTabContentPane(String tabName){
124134
def contentPane
125135
if( !TabPane.hasTab(tabName)) {
126136
contentPane = swing.panel(
@@ -142,7 +152,7 @@ class ToM_ui{
142152
return contentPane
143153
}
144154

145-
def static getContentPaneFromMyTab(myTabName, doClear){
155+
def static getContentPaneFromMyTab(String myTabName, boolean doClear){
146156
def cPane = ToM_ui.getTabContentPane(myTabName)
147157
if(doClear) cPane.removeAll() //eliminar contenido existente en el panel
148158
TabPane.showTab(myTabName)
@@ -153,7 +163,8 @@ class ToM_ui{
153163
// genera panel con botón
154164
def static getButtonPanel(htmlMsg, buttonLabel, buttonToolTip, buttonAction, boolean isToggleButton = false){
155165
def panel = swing.panel(
156-
border : new LineBorder(Color.gray, 1)
166+
border : new LineBorder(Color.gray, 1),
167+
name : myButtonPanelName,
157168
) {
158169
borderLayout()
159170
editorPane(

0 commit comments

Comments
 (0)