Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#29 LayoutConstraints and BorderLayoutManager

open
nobody
None
General
1
2013-03-27
2013-03-27
Thomas Jancar
No

Since the BorderLayoutManager creates its own BorderLayoutConstraints, this subclass should inherit from DefaultLayoutManager.DefaultLayoutConstraints.

When you do something like that:

BorderLayoutManager layout = new BorderLayoutManager();
[.. (bindToContainer, create Label, ...) ]
layout.addWidget(label, BorderLayoutManager.CENTER, ...);

a RuntimeException will be thrown:

Exception in thread "main" java.lang.RuntimeException: unknown constraint: jcurses.widgets.BorderLayoutConstraint
at jcurses.widgets.DefaultLayoutManager.layout(DefaultLayoutManager.java:33)
at jcurses.widgets.WidgetContainer.packChild(WidgetContainer.java:89)
at jcurses.widgets.WidgetContainer.pack(WidgetContainer.java:101)
at jcurses.widgets.WidgetContainer.pack(WidgetContainer.java:103)
at jcurses.widgets.Window.pack(Window.java:520)
at jcurses.widgets.Window.setVisible(Window.java:141)
at jcurses.widgets.Window.show(Window.java:120)
[..]

A quick look in the source code shows, that BorderLayoutManager.BorderLayoutConstraints inherit only from Object. But in DefaultLayoutManager.java:33 it is required, that the Constraints inherit from DefaultLayoutConstraints.

jcurses: 0.9.5b
Debian Linux x64

Discussion

  • Thomas Jancar
    Thomas Jancar
    2013-03-27

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Since the BorderLayoutManager creates its own BorderLayoutConstraints, this subclass should inherit form DefaultLayoutManager.DefaultLayoutConstraints.
    +Since the BorderLayoutManager creates its own BorderLayoutConstraints, this subclass should inherit from DefaultLayoutManager.DefaultLayoutConstraints.
    
     When you do something like that:
    
    @@ -6,7 +6,7 @@
     [.. (bindToContainer, create Label, ...) ]
     layout.addWidget(label, BorderLayoutManager.CENTER, ...);
    
    -an RuntimeException will be thrown:
    +a RuntimeException will be thrown:
    
     Exception in thread "main" java.lang.RuntimeException: unknown constraint: jcurses.widgets.BorderLayoutConstraint
     at jcurses.widgets.DefaultLayoutManager.layout(DefaultLayoutManager.java:33)