Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: JInternalFrame and a RenderWindow?  (Read 10177 times)

0 Members and 2 Guests are viewing this topic.

exonaut

  • Newbie
  • *
  • Posts: 3
    • View Profile
JInternalFrame and a RenderWindow?
« on: March 01, 2014, 07:06:13 am »
I'm working on a Swing editor that needs to display a RenderWindow in a JInternalFrame and I'm not really sure how to go about that. I don't need event polling I just need all of the sprites/primitives that I add from the Swing editor to appear in the RenderWindow and in-turn the JInternalFrame. Does anyone know how to do this? Thanks in advance.
« Last Edit: March 01, 2014, 07:35:18 am by exonaut »

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: JInternalFrame and a RenderWindow?
« Reply #1 on: March 03, 2014, 02:05:43 pm »
Hey,
integration of JSFML RenderWindows into Swing GUIs exists (it's called "RenderCanvas"), but it's unreleased so far. It works fine for Windows as far as I can tell and I think it does on Linux, however, there is no Mac code at all yet, since I don't have one.

So at the time being, there is no way for you to do this.

Looking at things now, I might as well merge that "render-canvas" branch into the master branch, so it'd be available for Windows and Linux at least. I hope I can find some time for this in March.
JSFML - The Java binding to SFML.

exonaut

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: JInternalFrame and a RenderWindow?
« Reply #2 on: March 04, 2014, 08:12:30 pm »
I was looking at some methods and I saw that there was a capture method in RenderWindow? Then you can convert the JSFML Image to an BufferedImage so would that work? To capture the image every frame and then draw it onto the frame?

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: JInternalFrame and a RenderWindow?
« Reply #3 on: March 05, 2014, 11:23:04 am »
That will be WAY too performance-heavy and slow. Forget it.
As said, there is a branch that does exactly what you want, but I have no built version of it released. You'll have to be patient a little.  :-\
JSFML - The Java binding to SFML.

baxet

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: JInternalFrame and a RenderWindow?
« Reply #4 on: June 06, 2014, 10:25:49 pm »
Is it still not implemented? Or can i build it myself, if it is included in some branch?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: JInternalFrame and a RenderWindow?
« Reply #5 on: June 07, 2014, 03:27:23 am »
if it is included in some branch?

Isn't this what pdinklag said?

there is a branch that does exactly what you want


And after 10 seconds in google I found the repository and after another 5 seconds of selecting a different branch in the drop down list I found this. So the answer to other other question is yes, you need to build it yourself.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

baxet

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: JInternalFrame and a RenderWindow?
« Reply #6 on: June 07, 2014, 04:18:05 pm »
After hours of trying I have managed to compile JSFML render_canvas branch for win32. If someone is looking for it, i send it here - https://dl.dropboxusercontent.com/u/61073116/jsfml.jar (it is too large for attachment). I did test it only with the basic window however, so be careful.

baxet

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: JInternalFrame and a RenderWindow?
« Reply #7 on: June 07, 2014, 05:10:08 pm »
But can someone show me how to use it? I've managed to put RenderCanvas on JPanel, but how to proceed forward? Just show me for example how to render some color in RenderCanvas or point me to some documentation, cause I can't understand nothing from JavaFrame Example :(

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: JInternalFrame and a RenderWindow?
« Reply #8 on: June 10, 2014, 06:26:25 am »
What don't you understand about the JavaFrame example, anything specifically? Your question is pretty generic and since there is a working example, I'm not sure how exactly to help you now.

I think the RenderCanvas' JavaDoc explains it well enough.
You need to pass a runner to the RenderCanvas when creating it. This runner is supposed to be your main loop. You shouldn't have your main loop in your normal program flow, because in Swing UIs, you are dealing with multiple threads.

By the way, the render-canvas branch might be discontinued in the future. I am not quite sure about its state yet, but Oracle is going to deprecate Swing and will push JavaFX, starting with Java 8. Therefore, I'm not sure how much effort I'm willing to put into completing this branch.
JSFML - The Java binding to SFML.