如何释放对象? [Java-GNOME]
如何释放 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于此链接: 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.