Help - Search - Members - Calendar
Full Version: InternalFrameListener
BatMUD > BatMUD forums > Batclient
Fitsio
InternalFrameListener seems to work only for internalFrameActivated and internalFrameDeactivated events.

I would upload the testscript, but the forum doesn't allow it. "Error Upload failed. Please ask the administrator to ensure the uploads directory is available".

I will paste it:

CODE

SCRIPT_NAME = "internalFrameListenerTester";
SCRIPT_ON = true;


class BatWindowCloseListener implements InternalFrameListener {

public BatWindowCloseListener() {
clientGUI.printText("generic", SCRIPT_NAME + " CloseListener constructed.\n");
}

public void internalFrameActivated(InternalFrameEvent e) {
clientGUI.printText("generic", SCRIPT_NAME + " window activated.\n");
}

public void internalFrameClosed(InternalFrameEvent e) {
clientGUI.printText("generic", SCRIPT_NAME + " window closed.\n");
}

public void internalFrameClosing(InternalFrameEvent e) {
clientGUI.printText("generic", SCRIPT_NAME + " window closing.\n");
}

public void internalFrameDeiconified(InternalFrameEvent e) { }
public void internalFrameIconified(InternalFrameEvent e) { }

public void internalFrameDeactivated(InternalFrameEvent e) {
clientGUI.printText("generic", SCRIPT_NAME + " window deactivated.\n");
}

public void internalFrameOpened(InternalFrameEvent e) {
clientGUI.printText("generic", SCRIPT_NAME + " window opened.\n");
}
}

void run() {

clientGUI.printText("generic", "Loading: "+ SCRIPT_NAME +"\n");

testWindow = clientGUI.createBatWindow(
"test",
100,100,100,100
);

testWindow.setVisible(true);

testWindow.addInternalFrameListener(new BatWindowCloseListener());

}

Amarth
Would this help any?

http://java.sun.com/javase/6/docs/api/java...meListener.html
Fitsio
No, it doesn't help.

Thanks for the link though, previously it was a real pain to use interfaces as I had to try the scripts to see the error messages in case I didn't remember all the methods required....

Instead of being arrogant you could have told whether or not the other methods work (for you/someone who tests these). And if you were really nice, you would have told why/why not.

If you are tired at the amount of bug reports & whining, and haven't got anything reasonable to say, then it's better to just be quiet. Annoying others won't make anyones life easier.

Amarth
Err...Whaaat?? :-D

I'm at loss here. I'm not a Java-coder myself. (I know absolutely nothing about these internalFrames, except for what one might guess from the principles.)

It's a given fact that we're short on documentation on the client internals, which is why any communication/co-operation within the community is important. But, I'm really clueless on the reasons behind the outburst.

I don't know anyone else who has tested or worked with this.. except you. Though, I did point you towards Glaurung who might have an idea how to do this from his overall experience on Batclient-plugins. Maybe he could help you onwards.

Fitsio
Whoops :D

I took your post as RTFM (and a very rude one since the code contained exactly the contents of your post), when you actually were trying to help. So I misunderstood you, sorry. Be so kind and disregard my earlier posting.

So Glaurung is also coding batclient/has access to source? or is he just like any of us mortals and just codes plugins/scripts?

My hunch is that the windowclosing event is not being fired because batwindows have some custom way of closing which doesn't notify the listener.


I also got an idea now that the fancy ParsedResult is in use. Would it be possible to add custom attributes for, say, items etc. That way it would be quite easy to parse item names in chests, inventory, ground etc. Would help making a GUI for wear and wield. :)

Hephos
Fit, looks like the listener you wrote should work. There is a bug though in the client that is fixed in next update and will actually trigger on the closing events. If you try the open event it should work in older versions. The closing will work similar.Here is another example that works in next update:
CODE
import java.awt.*;
import com.mythicscape.batclient.interfaces.*;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameAdapter;

SCRIPT_NAME = "testWin";

void run(){

    BatWindow win = clientGUI.createBatWindow(
        "test",
        100,
        100,
        750,
        265
    );
    
    win.removeTabAt(0);
    
    win.newTab(
        "TestPanel",
        new ImagePanel(
            new URL("http://www.bat.org/images/batclient_illustration.png")));
    
    FrameListener listener = new FrameListener();
    win.addInternalFrameListener(listener);
    
    win.setSize(750,265);
    win.setVisible(true);
    
    
}

public class FrameListener extends InternalFrameAdapter{
    
    public FrameListener(){
        super();
    
    }
    public void internalFrameActivated(InternalFrameEvent arg0) {
        // TODO Auto-generated method stub
    }
    public void internalFrameClosed(InternalFrameEvent arg0) {
        clientGUI.printText("generic", "testWin CLOSED\n");
    }
    public void internalFrameClosing(InternalFrameEvent arg0) {
        clientGUI.printText("generic", "testWin CLOSING\n");
    }
    public void internalFrameDeactivated(InternalFrameEvent arg0) {
        // TODO Auto-generated method stub
    }
    public void internalFrameDeiconified(InternalFrameEvent arg0) {
        // TODO Auto-generated method stub
    }
    public void internalFrameIconified(InternalFrameEvent arg0) {
        // TODO Auto-generated method stub
    }
    public void internalFrameOpened(InternalFrameEvent arg0) {
        clientGUI.printText("generic", "testWin OPENED\n");
    }
}


public class ImagePanel extends JPanel{
    Image image = null;
    
    public void ImagePanel(URL url){
        super();
        image = Toolkit.getDefaultToolkit().getImage(url);
        repaint();
        this.setBackground(Color.BLACK);
    }
    
    public void paintComponent(Graphics g){
        if (image != null && image.getWidth(this) > 10){
            g.drawImage(
                image,
                0,
                0,
                this.getWidth(),
                this.getHeight(),
                this);
        }
        else{
            g.setColor(Color.WHITE);
            g.drawString("Loading...", 50, 100);
        }
    }
}
Fitsio
Okay, thank you.

Keep up the good work. :)

Fitsio
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.