Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to handle a HUD Frame close??  (Read 2640 times)
0 Members and 1 Guest are viewing this topic.
Offline hawkwind

Junior Member




Java games rock!


« Posted 2006-10-18 02:17:40 »

I want tocatch when a user clicks the close button on a Frame HUD widget so I can setVisibility and NOT have the widget destroyed.  Using the following I can see
my override method called but the associated Frame is still destroyed.  Note I am not calling any super() here so I expected to isolate myself from the default closing behavior.   Thoughts???


1  
2  
3  
4  
5  
6  
7  
public class JournalPageHUD extends Frame implements WidgetActionListener,
      WidgetStateListener, DialogListener, FrameListener{

public void onFrameClosed(Frame frame) {
      // TODO Auto-generated method stub
     System.out.println("fram close x");
   }
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #1 - Posted 2006-10-18 02:38:37 »

I want tocatch when a user clicks the close button on a Frame HUD widget so I can setVisibility and NOT have the widget destroyed.  Using the following I can see
my override method called but the associated Frame is still destroyed.  Note I am not calling any super() here so I expected to isolate myself from the default closing behavior.   Thoughts???


1  
2  
3  
4  
5  
6  
7  
public class JournalPageHUD extends Frame implements WidgetActionListener,
      WidgetStateListener, DialogListener, FrameListener{

public void onFrameClosed(Frame frame) {
      // TODO Auto-generated method stub
     System.out.println("fram close x");
   }


Hmm... 1st: I don't know, where you override this method. It only exists in FrameListener. So it is not overridden, but implemented. But Maybe you mean that.
2nd: The Frame is not destroyed when it's closed, but only removed from it's parent (the HUD itself), which is nearly the same as setting it invisible. But only nearly. And this little difference is needed for frames. So just keep your Frame pointer stored and readd it to the HUD, when you want to re-show it. I guess this will solve your problems, does it?

Marvin
Offline hawkwind

Junior Member




Java games rock!


« Reply #2 - Posted 2006-10-21 17:14:28 »

What am I doing wrong??  In this situation I have manually closed the Frame.  I wish to redisplay it and have re-added the Frame to the HUD.

if(C.journalFrame.beenClosed)
         {
            C.hud.addWidget(C.journalFrame);
            C.journalFrame.beenClosed=false;
         }

Exception in thread "Thread-9" java.lang.IllegalArgumentException: This child already has a parent.
   at com.xith3d.scenegraph.GroupNode.addChild(GroupNode.java:125)
   at com.xith3d.scenegraph.Group.addChild(Group.java:69)
   at org.xith3d.ui.hud.base.WidgetAssembler.addWidget(WidgetAssembler.java:138)
   at org.xith3d.ui.hud.base.WidgetAssembler.addWidget(WidgetAssembler.java:167)
   at org.xith3d.ui.hud.widgets.Frame.init(Frame.java:532)
   at org.xith3d.ui.hud.base.WidgetBase.setContainer(WidgetBase.java:375)
   at org.xith3d.ui.hud.widgets.Frame.setContainer(Frame.java:546)
   at org.xith3d.ui.hud.HUD.addWidget(HUD.java:766)
   at org.xith3d.ui.hud.HUD.addWidget(HUD.java:845)
   at hawk.manager.GameUIManager.resolveDisplay(GameUIManager.java:755)
   at hawk.jcd.Xith3DFrame.runx(Xith3DFrame.java:770)
   at hawk.jcd.Xith3DFrame.loopIteration(Xith3DFrame.java:551)
   at org.xith3d.render.loop.RenderLoop.run(RenderLoop.java:775)
   at java.lang.Thread.run(Unknown Source)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #3 - Posted 2006-10-21 17:28:52 »

quick workaround :

1  
2  
3  
4  
5  
6  
if(C.journalFrame.beenClosed)
         {
            C.journalFrame.getGroup().detach(); // not sure of this line, @marvin : is there a getGroup() method ? is there a detach() method for widgets ? it should be so
           C.hud.addWidget(C.journalFrame);
            C.journalFrame.beenClosed=false;
         }

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #4 - Posted 2006-10-21 18:05:45 »

The bug is fixed. And there is indeed such a method. Each Widget has a getSGNode() method, that returns the Node object, that is the root of the Widget in the scenegraph. Each WidgetContainer additionally has a method getSGGroup().

Marvin
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #5 - Posted 2006-10-21 18:33:36 »

The bug is fixed. And there is indeed such a method. Each Widget has a getSGNode() method, that returns the Node object, that is the root of the Widget in the scenegraph. Each WidgetContainer additionally has a method getSGGroup().
And a detach() method, too ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #6 - Posted 2006-10-21 19:07:52 »

And a detach() method, too ?

Were you talking about a HUD detach method? I assumed you were talking about the Node.detach() method. This one is of course accessable through
1  
myWidget.getSGNode().detach();


Marvin

EDIT: A myWidget.detach() method is not needed. myWidget.getContainer().removeWidget( myWidget ) does the trick. But maybe it is convenient. I'll add it soon.
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #7 - Posted 2006-10-22 14:53:40 »

But maybe it is convenient. I'll add it soon.
Yeah that's what I meant.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #8 - Posted 2006-10-23 21:56:00 »


Done.
Offline hawkwind

Junior Member




Java games rock!


« Reply #9 - Posted 2006-10-23 22:58:25 »

cool will validate
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #10 - Posted 2006-10-26 10:45:08 »

Cool, thanks.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

E.R. Fleming (13 views)
2014-07-29 03:07:13

E.R. Fleming (4 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!