Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4445

Re: Looking for a simple

From "Simo Melenius" <simo.melenius@THRWHITE.remove-dii-this>
Subject Re: Looking for a simple
Message-ID <b17d4355-723c-4f8e-a3de-f7ab4c8c80f9@f37g2000pri.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <painting-20081107164213@ram.dialup.fu-berli
Date 2011-04-27 15:50 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
On Nov 7, 5:46=A0pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> Simo Melenius <simo.melen...@gmail.com> writes:
> >What I seem to need most often is a simple API/library to open
> >a window and draw some graphics to its bitmap. Aside from AWT
> >and Java2D, are there any de facto libraries that Java
> >programmers frequently use for such purpose?
>
> =A0 Because of the structure of Java, one would need a framework
> =A0 (not a library) for this. (You call a library, while a
> =A0 framework calls you.)

Thank you for your comments; I realized I think I want to revise my
question.

Is this structure of preferring frameworks as opposed to libraries
somehow inherent to Java -- in other words, is the top-level event
loop or program main loop always internal and inaccessible in Java?

 * * *

Why this is important is that I need my program to work both from the
REPL and from the command line. So basically I'm after a single main
function that I can run repeatedly without exiting the JVM. Exiting
the main function should leave nothing alive (sans letting GC reap the
unused objects at some point).

On the other hand when running from command-line, I would just call
that main function once in the end of the program, thus running the
main function once and then exiting.

I first tried to set my JFrame to DISPOSE_ON_CLOSE but since I wasn't
in control of the event loop, the function that created the frame and
runtime environment for my program of course exited immediately,
leaving the frame "alive" by itself thanks to the automagical event
loop somewhere.

And naturally, when I closed the window any Timer objects I had
started just happily continued to run on the background. As my this
frame-creator function of mine had already exited, there was no place
to stop the timers. Also, when run from command line, the timers
prevent the program from exiting as opposed to setting the frame to
EXIT_ON_CLOSE.

Then I realized that I would have to listen to the window close event,
manually shut down anything I've started and then dispose the window.
And this is when I started to lose the grip on simplicity... I want to
focus on my algorithm and visualisation, not the graphics stack and
event system.

It would be great if there was a way to do something like you
described:

(with-open-canvas width height
  (consume-events until window closed
    (paint ...)))

I'm too used SDL via PyGame to not love it, but Clojure is much more
powerful. I just wouldn't want to start by writing workarounds.

br,
Simo

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar


Thread

Re: Looking for a simple "Simo Melenius" <simo.melenius@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000

csiph-web