git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
#29 avoid potential NPE
[nikiroo-utils.git]
/
src
/
jexer
/
demos
/
DemoTextWindow.java
diff --git
a/src/jexer/demos/DemoTextWindow.java
b/src/jexer/demos/DemoTextWindow.java
index 1c51296af5900b14f010433278f16eb660566742..969ca6381aa79bfc6fe0b9c5f1e41cfe5d27cb20 100644
(file)
--- a/
src/jexer/demos/DemoTextWindow.java
+++ b/
src/jexer/demos/DemoTextWindow.java
@@
-39,11
+39,19
@@
import static jexer.TKeypress.*;
*/
public class DemoTextWindow extends TWindow {
*/
public class DemoTextWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Hang onto my TText so I can resize it with the window.
*/
private TText textField;
/**
* Hang onto my TText so I can resize it with the window.
*/
private TText textField;
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Public constructor makes a text window out of any string.
*
/**
* Public constructor makes a text window out of any string.
*
@@
-111,6
+119,10
@@
public class DemoTextWindow extends TWindow {
}
}
+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Handle window/screen resize events.
*
/**
* Handle window/screen resize events.
*
@@
-120,9
+132,9
@@
public class DemoTextWindow extends TWindow {
public void onResize(final TResizeEvent event) {
if (event.getType() == TResizeEvent.Type.WIDGET) {
// Resize the text field
public void onResize(final TResizeEvent event) {
if (event.getType() == TResizeEvent.Type.WIDGET) {
// Resize the text field
- textField.setWidth(event.getWidth() - 4);
-
textField.setHeight(
event.getHeight() - 6);
- textField.
reflow(
);
+ TResizeEvent textSize = new TResizeEvent(TResizeEvent.Type.WIDGET,
+
event.getWidth() - 4,
event.getHeight() - 6);
+ textField.
onResize(textSize
);
return;
}
return;
}