turn your demos into (win32) screensavers

JScreenSaver (41kb)


The little package contains a bunch of files:

A little demo:
demo/demo.jar
demo/demo.scr

And the source:
src/icon.ico (ultrasweet 80ie flavoured icon ;D)
src/jsaver.cpp
src/PlasmaFS.java


It’s pretty simple and easy to use. The doubleclickable jar and the scr need to be in the same directory and both files must have the same basename (eg moo.scr -> moo.jar or test.scr -> test.jar). So… there is no need to recompile it. Rename it and you are done :wink:

The scr does absolutly nothing except launching a jar file with the same basename as itself. It doesnt care about a preview, password, change password, configuration or exiting of your programm. Just make sure that your java application exits if any event occurs (key, mouse or mousemotion) and it will just behave like any other screensaver.


enableEvents
(
      AWTEvent.KEY_EVENT_MASK|
      AWTEvent.MOUSE_EVENT_MASK|
      AWTEvent.MOUSE_MOTION_EVENT_MASK
);
[...]
public final void processEvent(AWTEvent e)
{
      run=false; //die! die! die!
}

That usually does the trick (for Java2D stuff)… well ok and mwheelup/down doesn’t exit the programm, but I guess it’s good enough for a little demo.


The license is - do what you wanna do with it and don’t sue me :stuck_out_tongue:

That process creation part is (iirc) from jbanes, that for(;; ) snipped is from a forum and the other ugly pieces of bad C code were added by me… oh and I pixelated that icon :wink:

If you add something usefull, make it public for the community. Thanks ;D

Ahem… just did a google search… there is already a sf project called the same and it also does the same… ::slight_smile:

Well… mine is smaller and I learned something very important: C/C++ is damn ugly ;D

well C/C++ with Microsoft API’s is more ugly than your usual garden variety ugly C/C++ :wink:

Cool program I must say. It ran for me fine when I tested it (by double click on the .src) - but for some reason it wouldn’t start after 1min like the SS normally does. I tried other SS’s and they worked so I don’t know why yours wouldn’t autostart.

Also - I know you don’t have a preview, but could you just have a static image? That would make it look much cooler. Say demo.jpg?

Cheers,

Will.

but for some reason it wouldn’t start after 1min like the SS normally does.

Hmm… that’s odd. It was successfully tested under 98, 2k and XP. The starting itself is handled by the operating system… everything it actually does is calling the src (like an exe) with an “s” switch. (It’s called every time. For preview, configure, changepassword and running - each time with another switch).

However, it should just work if you choose right click -> install (screensaver configuration dialog pops up) and press then ok.

Also - I know you don’t have a preview, but could you
just have a static image? That would make it look much
cooler. Say demo.jpg?

That would be indeed pretty neat. But I would need to care about that on the C/C++ side… and I’m rather clueless. TGA loading would be much easier (already done that), but drawing into that… erm… thing looked kinda odd (couldn’t figure out how it works).

probably just a crappy windows install (it is) but I’ll try the right click thing too.

again, great stuff - the drawing thing’d be a nice feature but it’s still good without it. I wounder if there is a screensaver forum that could help?

I did a quick google - is this of any help? http://www.alexchirokov.narod.ru/HOWTOSCR.HTM#RunningFullScreenAndPreview

Cheers,

Will.

hi

I tried this and it worked, now i’m making a screensaver that shows pictures. A slideshow-screensaver.

But i’m not sure about fullscreen, should I use fullscreen or just use a Frame and maximize it?

And when it is finnished, how can it be automatically installed on a computer?

hey onyx, how did you compile the cpp file for the screensaver? I have visual c++ studio and it compiled with no errors but i didnt get a .scr screensaver file…I have cygwin, do you know how i can compile it there?

Well, you get an “exe” - it’s the same. You just have to rename it :wink:

For fullscreen you’ll need 1.4+ and a little introduction can be found here:
http://java.sun.com/docs/books/tutorial/extra/fullscreen/

For further fullscreen questions check the java2d forum :slight_smile:

Oh if you don’t want to change the resolution you can use a JWindow - it’s like a frame without borders/titlebar (also perfect for making splash screens).

hi thanks, i think ill try the JWindow.

The screensaver works when I click preview, or start it directly, but it doesnt start after 1 minute. It looks like windows tries to start it but it stops, because i can see on the cursor that the computer works for a moment…
do you have any idea why it acts like this? i tested it on two computers with windows xp on both.

Hm… it could be, that windows copies the file over to another directory. So use search to locate all *.scr files. See if you can find the scr (wich you’ve installed) twice. If so you’ll need to copy the jar over to that directory, too.

The common locations for scrs under win9x are windows and windows/system. However, under 9x no files are copied at all (maybe that’s the broken install routine I’ve heard about?).

[quote]hi thanks, i think ill try the JWindow.

The screensaver works when I click preview, or start it directly, but it doesnt start after 1 minute. It looks like windows tries to start it but it stops, because i can see on the cursor that the computer works for a moment…
do you have any idea why it acts like this? i tested it on two computers with windows xp on both.
[/quote]
This is what happened to me too :frowning:

Will.

Well, I guess xp copies the src file (if you choose rightclick->install) into another directory. Then, when the src is started, it can’t find the jar, because that file wasn’t copied.

Try to locate the directory of the src file via search function, copy the jar and test it again.

I can’t try this by myself, because I don’t have XP.

(Win9x doesn’t copy the src btw)

i know its been a few years :D, but could you re-up it?

URL updated.

The demo.jar seems to have some issues here (it complains about the display mode), other than that it works fine.

ta

There is a cross-platform way to do this, isn’t it? I don’t see why you need to use C++ to do this. In Java, the class java.awt.Robot can be used to perform a screenshot and in JOGL, the class com.sun.opengl.util.Screenshot can help too.

If you actually read this thread you’d see that nobody’s talking about taking screenshots :stuck_out_tongue:

WTF :slight_smile:

Ok… Don’t you think there is a cross-platform way to “turn your demos into screensavers”? At work, one of my colleague created a small program to record a short sequence, generate a Java archive containing both the movie and the program to read it and to send the whole by email.

[quote]Ok… Don’t you think there is a cross-platform way to “turn your demos into screensavers”?
[/quote]
No, I don’t think so.
A screensaver is a platform specific thing: A screensaver in Windows is a native program with a .scr extension, therefor you need to follow that convention if you want to create a screensaver written in java (i.e. write a native program with a .scr extension which starts java, which is exactly what oNyx created).
It probably works differently on Linux, so there you’d again need a platform specific intermediate step to use a java program as screensaver.

[quote]At work, one of my colleague created a small program to record a short sequence, generate a Java archive containing both the movie and the program to read it and to send the whole by email.
[/quote]
That’s nice, but not a screensaver :slight_smile: