• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Draw to screen directly / transparent fullscreen overlay: Which framework to use?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I want to write a "software laser pointer" - that is, an application that shows a red dot on top of any running applications which moves around based on touchscreen input on a bluetooth-connected smartphone. My current approach (for the red dot overlay part) is to use an undecorated fullscreen JavaFX stage with setAlwaysOnTop(true), but I think there could be better solutions, I'm also having trouble getting that stage to repaint when another application is focused.
Basically what I'm looking for is a way to draw on top of everything without creating a fullscreen window, because mouse and keyboard events should still be received by whichever application has the focus. Since I'm not very skilled with C languages, I'd like to use pure Java as far as possible (one platform-independent piece of code would be nice, too). Are there any frameworks suited for this? I started looking into fullscreen exclusive mode stuff, but the examples I found always used a JFrame, which would then consume all input events (I think?)...

Thanks in advance,
Joe
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Does Java FX run on smart phones?

I want to write a "software laser pointer" - that is, an application that shows a red dot on top of any running applications which moves around based on touchscreen input on a bluetooth-connected smartphone


I do not think this is possible with the approach you have in mind. Effectively what you are trying to do, is superimpose your app on top of some other app. There might be some 'native' approach on smart phone, but I doubt, it is possible with JavaFx or Swing or any other 'Java' framework.
 
Joseph Bloesinski
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answer!

The laser pointer part is a program running on a pc, maybe I shouldn't have used the word application in the same context as smartphone, sorry.
So the whole setup right now is as follows:
- A bluetooth client app running on an Android smartphone, which converts gestures to a series of coordinates sent to...
- a bluetooth "server" program running on a Windows 10 laptop (where the JavaFX stuff takes place at the moment)

I have two more specific questions regarding my problem:
1.) Is there a way to make a fullscreen exclusive mode application with for example an undecorated Swing JFrame transparent for mouse events?
2.) Is it maybe a better idea to have a tiny undecorated transparent window just big enough to display the laser pointer dot and move that whole window (instead of moving the dot inside a transparent fullscreen window) ?

Thanks again,
Joe
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah. Now I understand better.

Don't know about JavaFX, but in swing you can use the glass pane. Check out https://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html
Another (recent, JDK 7 option) is JLayout. More on it here http://docs.oracle.com/javase/tutorial/uiswing/misc/jlayer.html

PS. I haven't worked on JavaFX but I think it is possible to use Swing components in JavaFX
 
Joseph Bloesinski
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again for your time, the problem is resolved.

I stumbled upon this stackoverflow answer which does what I need.
The solution for me was to use a transparent fullscreen-sized undecorated always-on-top JFrame with a JPanel content pane using an active rendering loop to call the content pane's overridden paintComponent() via contentPane.repaint().
reply
    Bookmark Topic Watch Topic
  • New Topic