Java Question java.awt.Graphics

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hello all ,
While writing a jPCT wrapper for B4J , I found display method requiring java.awt.Graphics object to draw on .
Displays the output Image onto the component with the given Graphics context. If one wants to have further control about the drawing, getOutputBuffer() can be used instead.
Parameters:
g - the Graphics context of the compontent onto which the Image should be drawn (ignored when using OpenGL only)
Can I get Graphics context of b4j form ?
If not , please tell me the best approach .
As you can see there is a getOutputBuffer() method , should that be used instead ? Should I use it in a loop to set ImageView image ?
Thanks in advance
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
B4J Form is a combination of stage, scene and a pane. java.awt.Graphics is a swing object. You need to find out how you can use it with JavaFX components.
Is it a good idea to update ImageView image in a loop ?
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I'm not sure what you are trying to do and I don't see how it is related to a Java question. I think that it is better to start a new thread in B4J forum and provide more information.
As an alternative to getting the graphics context of b4j form , I got the OutputBuffer and converted it to FXImage and set it as an imageview image
Now my question is this way OK ?
B4X:
    Do While MainForm.Showing
        buffer.clear2( fx.Colors.To32Bit(fx.Colors.Blue))
        world.renderScene(  buffer)
        world.draw(buffer)
        buffer.update
        imagebuffer.SetImage(jpct.toFXImage( buffer.GetOutputBuffer,Null))
        Sleep(10)
    Loop
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
What is the purpose of this code? To implement a frame animation?

Sleep pauses the current sub and resumes it after the specified interval.
I am drawing the jPCT outputbuffer to a B4J ImageView .
I managed to do that but I want to know if ImageView is good for such task .
imagebuffer is a B4J ImageView
 
Top