I'm working on a project using Java in an embedded system. I have drivers for the screen and touch input, and a virtual keyboard for text input. My screen driver has a Graphics2D
object you can draw into and a repaint(Rectangle)
method for updating. Similarly, the touch driver is capable of generating MouseEvents
for listeners.
Right now I'm working with drawing directly to the screen. This is fine, but what I really want is to allow the user of my library to create a JFrame and use normal Swing elements. However, the default GraphicsEnvironment is headless, since Java doesn't see my EInkDriver
class or my TouchDriver
class.
I'm aware that there are ways to call a component's paint
method to get the image; however this has problems when you're painting a Container
, and I'd also like to present the user with a GraphicsConfiguration
so they can write something like JFrame frame = new JFrame(getEInkGraphicsConfiguration());
and carry on as if they were writing a desktop Swing app.
Given these capabilities that I already have, how would I go about creating a GraphicsDevice
or GraphicsEnvironment
that would allow me to use Swing in my project?