Skip to content

Commit 6cbda99

Browse files
committed
Added Component Listener for resizing
1 parent 7c9a4cb commit 6cbda99

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package edofro.tutorialomatic
2+
3+
//import edofro.tutorialomatic.TabPane
4+
import edofro.tutorialomatic.ToM_ui as tomui
5+
6+
import java.awt.event.*
7+
8+
9+
10+
class CustomComponentListener implements ComponentListener {
11+
public void componentResized(ComponentEvent e) { //https://docs.oracle.com/javase/8/docs/api/java/awt/event/ComponentEvent.html
12+
def comp = e.component
13+
//ToM_ui.resizeContentPanel(comp, tomui.maxContentPaneHeigth)
14+
sleep(100)
15+
ToM_ui.resizeContentPanel(comp, comp.height + 500)
16+
// TabPane.repaint()
17+
}
18+
public void componentMoved(ComponentEvent e) {
19+
// e.source.title = " moved. "
20+
}
21+
public void componentShown(ComponentEvent e) {
22+
// e.source.title = " shown. "
23+
}
24+
public void componentHidden(ComponentEvent e) {
25+
// e.getSource().title = " hidden. "
26+
}
27+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package edofro.tutorialomatic
22

33
import edofro.tutorialomatic.TabPane
4+
import edofro.tutorialomatic.CustomComponentListener
45

56
import java.util.Timer
67

@@ -144,6 +145,7 @@ class ToM_ui{
144145
layout: new GridBagLayout(),
145146
// background: Color.gray
146147
){}
148+
contentPane.addComponentListener(new CustomComponentListener())
147149
def panel = swing.panel(
148150
layout: new GridBagLayout(),
149151
preferredSize: new Dimension(minContentPaneWidth, maxContentPaneHeigth),

0 commit comments

Comments
 (0)