如何释放对象? [Java-GNOME]

发布于 2024-10-27 03:37:07 字数 1010 浏览 1 评论 0原文

如何释放 java-gnome 库中的对象? 首先,我举一个例子...

package gui;

import org.gnome.gdk.Event;
import org.gnome.gtk.Button;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;

public class A extends Window implements Window.DeleteEvent
{
    private Button b;

    public A()
    {
        this.b = new Button();
    }

    public boolean onDeleteEvent(Widget w, Event e)
    {
        this.b.destroy();
        this.destroy();
        this.release();
        return false;
    }
}

我应该像在这段代码中那样使用销毁和释放函数吗? 我如何最终释放对象?

java-gnome api 网站: http://java -gnome.sourceforge.net/4.0/doc/api/index.html?org/gnome/pango/package-summary.html

它的免费开源,如果你可以帮我检查一下: http://ftp.gnome.org/pub/gnome/sources/ java-gnome/4.0/

下载文件:“java-gnome-4.0.19.tar.gz” 感谢您的帮助:)

how do i release objects in java-gnome library?
first, i give an example...

package gui;

import org.gnome.gdk.Event;
import org.gnome.gtk.Button;
import org.gnome.gtk.Widget;
import org.gnome.gtk.Window;

public class A extends Window implements Window.DeleteEvent
{
    private Button b;

    public A()
    {
        this.b = new Button();
    }

    public boolean onDeleteEvent(Widget w, Event e)
    {
        this.b.destroy();
        this.destroy();
        this.release();
        return false;
    }
}

should i use destroy and release functions like i do at this code?
how to i finally release the objects?

java-gnome api website:
http://java-gnome.sourceforge.net/4.0/doc/api/index.html?org/gnome/pango/package-summary.html

its free open source, if u can check it for me:
http://ftp.gnome.org/pub/gnome/sources/java-gnome/4.0/

download the file: "java-gnome-4.0.19.tar.gz"
thanks for help :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悍妇囚夫 2024-11-03 03:37:07

基于此链接: http://java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Widget.html#destroy%28%29

看来会的。当然,就像斜体文本所说的那样,它可能不会仅删除 GObject 系统中对 java 中对象的所有引用。但除此之外,这看起来是正确的。一旦您对此的引用超出范围,就应该完全取消引用它,以及您可能跳过的所有子项。

我还建议,如果您要销毁一个有很多子窗口的窗口,并且您计划销毁其中的每一个窗口,请调用 this.hide() 作为 onDeleteEvent 中的第一步。
请参阅: http://java-gnome.sourceforge .net/doc/api/4.1/org/gnome/gtk/Window.html

在阅读了寻找 release() 的文档后,我找不到它在任何地方列出,除了org.gnome.glib.Object,但没有任何来自 Object 的实际直接方法。我建议不要使用它。

Based on this link: http://java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Widget.html#destroy%28%29

It seems it will. Of course, like the text in italics says, it may not remove all references to the object in java just the GObject system. But otherwise, this looks correct. Once your reference to this goes out of scope, it should be completely dereferenced, along with all children you may have skipped.

I would also recommend if you are destroying a window with lots of children, and you plan on destroying every single one of them, call this.hide() as your first step in the onDeleteEvent.
See: http://java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Window.html

After reading through the docs looking for release(), I couldn't find it listed anywhere but in org.gnome.glib.Object, but there are not any actual direct methods from Object. I would recommend against using it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文