Creating a custom device for Swing/AWT to draw to - java

I am working on an embedded linux device that requires custom java code to draw to the screen. I was wondering if there was any way to create a custom adapter that can update the display based off our drawing code. I have done some digging and haven't found any information as to how Devices are implemented or plugged into Swing/AWT. Any information is greatly appreciated.
Thanks.

I think you need to go beyond what Swing/AWT would typically call an adapter and create the bridge yourself to the graphics device using JNI (Java Native Interface). Have a look at this wiki page which describes the JNI aspects of Javas AWT layer - there are links in that page to details of JNI and Swing which are fairly low-level. Hopefully this will put you on the right track.

Related

3d effects in android and Iphone

We have a lot of days of research but can't find a solution for the following project. We need to convert a flux project to IOS and android native app. But as flux supports flash scripting it has easily implementing some 3d effects like shadow, emboss gradient etc. Please check the link here for seeing the swf file we have. We need to convert all this features into a native IOS and android app. We have research some area and found that most of the item we can implement except one icon here. The fourth icon have some 3d effects, shadow effects, border, emboss, contour and gradient etc. Can anybody check on this and guide us whether this can be implemented in IOS and android. I am pasting the entire url here again http://projects.zoondia.org/signfabcreator/signCreator.swf. Please check and let me know if this is possible. Let me if this is possible or not. If yes it will be helpful for me if anybody can give me a clue about implementing those in both android and ios
Very interesting! But I'm afraid you have to reimplement all this functionality by yourself. Don't be upset. There are good news for you - OpenGL ES and GLSL are extremely portable. So you can reuse 100% of your shaders. What is even better now you can share the other code too and stay native. Not long ago Intel announced the Multi-OS Engine. It enables you to develop native mobile applications for iOS and Android with Java. There are a bunch of tutorials inside installation package. One of them is especially dedicated to cross-platform OpenGL capabilities. Please check out my OpenGLBox sample.

Making label creators in Java

I want to create a tool in java that can be used to create labels for consumer products. This is similar to CD label creators. What are the techniques available for doing this and guide me in a good direction so that i can walk through perfectly. If you just give me some tips i will start coding on it.
Here are some tutorials that should get you started, using AWT Print and Graphics2D:
Swing Tutorial - High-Quality Java Printing
Printing - Java Tutorials by Sun/Oracle
Using the 2D graphics API means you'll be able to render the result on-screen as well as print it. This will be significantly easier if you already know something about AWT or Swing.

Need help regarding lwuit

I have project, already developed using canvas and lib used is LCDUI.
It's for nokia keyboard supported devices.
Now I want to incorporate same application for touch devices.
I have used touch methods like pointerpressed, etc.
For normal functionality that worked pretty well.
But it creates problem in commands.
My application is in fullscreen mode. Commands I have created using user defined menu list.
Probles is that I can not directly identify that which command has been clicked.
Setting coordinates for every command is not thr feasible solution for me.
I come across the new lib LWUIT, but i found out that it supports only forms(Can't we use on canvas?).
and integrating LCDUI and LWUIT is also not possible(please give suggestion that can we use both in same application?).
Is it possible to create form under canvas itself?
Any other lib support available?
thank you.
If you want to use LWUIT, then it has a Painter mechanism for custom background painting. I assume you can have a Form with its background painted as you like using Painter.
Some help can be found here:
Using Styles, Themes and Painters with LWUIT
LWUIT is made to override every component. You also have a basic painter class to draw lines and basic geomotry in all sorts of colors you desire. So if you combine those two, you can do some very nice stuff.
So if you override your component with an actionlistener it should generate events, which you can then catch in a parent component who has an actionperformed function.
hope this helps.

Design a GUI for a J2ME app

How do I create a J2ME app for cellphones with a GUI similar to the menus you see in Java games? I've tried MIDlets with Netbeans but they only show you one GUI element at a time. (textbox, choice, login, etc)
And which Java IDE would you typically design these GUIs in? Netbeans or Eclipse? and is IntelliJ IDEA usable for this aswell?
Do I have to write/get a library that draws GUI controls to screen via bitmap functions .. and keeps track of the keys pressed for focus?
Try to use LWUIT - nice UI toolkit for j2me:
https://lwuit.dev.java.net/
http://lwuit.blogspot.com/
You can also use minime: http://code.google.com/p/minime/
It's an open source GUI library for j2me. miniME works on canvas level (lowest level in j2me) to draw every control so your UI will look exactly the same whatever the handset it'll be running on. Other advantage are:
- miniME uses its own event loop to manage user controlled event (botton pressed, softbar, ..), so you Application will "behave" the same whatever the handset.
- miniME support the concept of Views and stack of view, in order to make navigation between different view/screens very easy.
Here is an example: A View is what you have on the screen at a given moment (for example the main menu screen), then to go to a sub menu, you create a new view, and by calling a simple API, you push it in the stack of Views. The previous view (the main menu) is still existing, but inactive. When the sub menu view complete his work (for example, user press back, or do a selection), you can just go back to the previous view by calling a pop api.
Your question is a bit vague to give a specific aswer, but you might want to check out LWUIT or Polish, you can develop both with either Eclipse or Netbeans.
As far as designing GUIs go, neither IDE will help from a visual perspective. J2ME UI development is all done in code, beyond creating any initial graphics in a proper graphics editor you don't get to see your output until you test.
Read up on the LCDUI package documentation which explains how the UI classes work and the differences between the 'High-level' and 'low-level' APIs.
I can't comment on which IDE to use - but I do know that to create custom UI (like the ones you see in J2ME games), you have to explicitly draw the GUI controls.
Beware that you may need to customize the GUI depending on the target phones. You have to cater for different screen sizes, key pad configurations, default theme etc. This would probably mean that you need different builds for things like different screen sizes which would drive up your Java Verified certification costs (if you need it).
You may be able to find a set of nice looking UI controls that you can buy online and use (try J2ME Polish). The easy way out of course, is to use default J2ME controls :)
Links to many j2me GUI libraries: link1, link2
I know that kuix is not bad and free - watch demo.
But i prefer to make my own gui elements - this is much more flexible (but takes some time).
As for IDE - you may want to make some kind of gui-editor tool, construct interface in it, save result to some file, and read it from your app.
It's way too cumbersome to write your own GUI, especially since there are so many available these days. If you're familiar with desktop development in VB.Net and C#, you might find "J2ME GUI" easy to use. You can download it from http://www.garcer.com/. It has a similar feel and makes it easy to learn. This is the kind of GUI that I expected to come standard with MIDP2 when I started mobile development. Would have solved a lot of issues.
If you are familiar with web stuffs then you can use KUIX (kalmeo.org/home/index) framework having xml and css supports. In place of It you can use also Polish framework (www.j2mepolish.org) it's also uses the xml in easy way rather than kalmeo kuix framework.

How can I create a frame which includes animation?

I have a frame and I want to show some white sphere in the different location in my frame,I have researched a lot but I found some codes for using applets but i don't want to use applets.
please help me with some code or references.
Thanks.
Sun has published a large list of Java 2D examples, many of which include animation. You should be able to copy the techniques used there. Take a look!
Note: "Java 2D" sounds like some API that you'd need to download a new library for. This is not the case: Java 2D is part of the "normal" JDK/JRE libraries.
Another note: There's not too much difference between an Applet showing graphics and a desktop application. To convert a Swing Applet to a desktop application, most of the effort is replacing JApplet with JFrame, and moving the applet's init code into the JFrame's constructor. So if you see example code for applets, don't throw it out the window as it can still be useful to you.
You may also like this Java 2D games tutorial that discusses several animation techniques.

Categories