*> get screen data
MOVE J-GETSCREENWIDTH() TO WS-SCR-WIDTH
MOVE J-GETSCREENHEIGHT() TO WS-SCR-HEIGHT
*> set frame size
MOVE 800 TO WS-WIDTH
MOVE 600 TO WS-HEIGHT
MOVE J-SETSIZE(WS-FRAME, WS-WIDTH, WS-HEIGHT) TO WS-RET
*> the frame position is in the middle of the screen
COMPUTE WS-XPOS = (WS-SCR-WIDTH - WS-WIDTH) / 2
COMPUTE WS-YPOS = (WS-SCR-HEIGHT - WS-HEIGHT) / 2
MOVE J-SETPOS(WS-FRAME, WS-XPOS, WS-YPOS) TO WS-RET
No, I meant that when I have several open screens on my desktop. When I start my cobjapi program, I want it to be showing on my desktop. I would rather not have to click on it to show on my desktop.
Rich Di Iulio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I checked this. There is on Java side a "toFront" method for Frames, but it is not implemented yet in COBJAPI. If I have time at Christmas, then I will do it.
László
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I added the new function J-TOFRONT to COBJAPI. In some cases a new Frame was not shown in the foreground on the screen. The user had to click on the taskbar icon to see the Frame. The new function could help, but this is also depends on operating system.
This function is only for Frames, here is an example on how it can be used:
MOVE J-SHOW(WS-FRAME) TO WS-RET
MOVE J-TOFRONT(WS-FRAME) TO WS-RET
Regards, László
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was able to update my Windows and Linux (Linux Mint) system with latest Cobjapi and updated my application. I tried it and it worked on Windows! However, when I tried on Linux, it crashed, giving my an error 2125.
Thank you for your work László.
Regards,
Rich Di Iulio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
2125 is the internal number of the new function. It can be that your update on linux was not correct and the new function was not found on java side. You should stop all java processes and runtime at update.
László
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I re-installed Japi and built the Examples Simple. I found that the tabbedpane.cob had the new function j-tofront in. When I run the program nothing happens. I then modified the program and commented out that line of code. Compiled the code and it works just fine. I should I do next.
Rich Di Iulio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All!
I am trying to center a label on a screen using Cobjapi. Has anyone done something like this with Cobjapi?
Rich Di Iulio
Hi,
maybe so:
*> get screen data
MOVE J-GETSCREENWIDTH() TO WS-SCR-WIDTH
MOVE J-GETSCREENHEIGHT() TO WS-SCR-HEIGHT
*> set frame size
MOVE 800 TO WS-WIDTH
MOVE 600 TO WS-HEIGHT
MOVE J-SETSIZE(WS-FRAME, WS-WIDTH, WS-HEIGHT) TO WS-RET
*> the frame position is in the middle of the screen
COMPUTE WS-XPOS = (WS-SCR-WIDTH - WS-WIDTH) / 2
COMPUTE WS-YPOS = (WS-SCR-HEIGHT - WS-HEIGHT) / 2
MOVE J-SETPOS(WS-FRAME, WS-XPOS, WS-YPOS) TO WS-RET
This is in https://sourceforge.net/p/gnucobol/contrib/HEAD/tree/trunk/tools/cobjapi/SWING/examples/tree_internal_frames/tree_internal_frames.cob#l197
László
László thank you for your response. I created a test program is attached. The text is not centering on the frame. It is just puzzling...
Rich Di Iulio
Hi,
first you have to define some values for the label with J-SETSIZE.
You can check the example: label.cob
Extend your example with J-SETSIZE:
*> set label
MOVE J-LABEL(WS-FRAME, WS-TEXT) TO WS-LABEL.
MOVE 500 TO WS-L-WIDTH
MOVE 300 TO WS-L-HEIGHT
MOVE J-SETSIZE(WS-LABEL, WS-L-WIDTH, WS-L-HEIGHT) TO WS-RET
MOVE J-SETFONT(WS-LABEL, WS-FONT, WS-FONTSTYLE, WS-FONTSIZE)
László
László,
That worked; however it is not true center, so I added 10 to WS-XPOS. I have attached the updated program.
I have a question, how do I get the frame I just created to be the top on the PC Desktop?
Again thanks,
Rich Di Iulio
"top on the PC Desktop" means foreground?
No, I meant that when I have several open screens on my desktop. When I start my cobjapi program, I want it to be showing on my desktop. I would rather not have to click on it to show on my desktop.
Rich Di Iulio
Hi,
I checked this. There is on Java side a "toFront" method for Frames, but it is not implemented yet in COBJAPI. If I have time at Christmas, then I will do it.
László
Great! Thank you.
Rich Di Iulio
Hi,
I added the new function J-TOFRONT to COBJAPI. In some cases a new Frame was not shown in the foreground on the screen. The user had to click on the taskbar icon to see the Frame. The new function could help, but this is also depends on operating system.
This function is only for Frames, here is an example on how it can be used:
MOVE J-SHOW(WS-FRAME) TO WS-RET
MOVE J-TOFRONT(WS-FRAME) TO WS-RET
Regards, László
Hi
I was able to update my Windows and Linux (Linux Mint) system with latest Cobjapi and updated my application. I tried it and it worked on Windows! However, when I tried on Linux, it crashed, giving my an error 2125.
Thank you for your work László.
Regards,
Rich Di Iulio
Hi,
2125 is the internal number of the new function. It can be that your update on linux was not correct and the new function was not found on java side. You should stop all java processes and runtime at update.
László
László
I re-installed Japi and built the Examples Simple. I found that the
tabbedpane.cob
had the new functionj-tofront
in. When I run the program nothing happens. I then modified the program and commented out that line of code. Compiled the code and it works just fine. I should I do next.Rich Di Iulio
I forgot, this was Linux Mint.