Is there a way to add AWT listener to a SWT component?
I previously made an app running mostly in AWT and Swing components. Now, I have hotkeys function which is dependent on a custom-made library that listens to global key events and returns its corresponding AWT key code.
My problem arises when I shifted the whole app and used SWT components instead. As we know some of the keys returns a different key code now, which messes up the whole hotkeys function.
The initial solutions I've thought of are:
A. Use javax.swing.jtextfield as mycomponent listener instead of swt.widget.text
B. Add AWT listener to SWT component (if possible)
C. Create a class which re-maps all AWT keycodes to SWT and vice-versa.
I believe these are feasible solutions. I just want to check out with you guys if you have a brilliant idea on which I could work with. I'm only new to java and I could use some professional insights on this.
(besides, I think A is cheating. B I could not find a way to do yet. And C is a hassle job to do)
Cheers.
After some googling I've found class from JBoss Tools which might help you with mapping from AWT keycodes to SWT one's..
See KeyboardHelper class from JaCoCo project.
Related
I just wanted to know if there are Java libraries that allow for smooth transitions between Java Swing Containers.
Suppose I have a Java GUI application with a single JFrame. Based upon user actions I would like to change the JPanel contained in my JFrame. Now, this I can do. However this change is instantaneous. What I would like to do is have a slow transition/animation so that it is not too hard on the users cognition.
Concrete Example:
Say the JFrame I have isframe having 2 buttons and I have two JPanel, panel1 and panel2. Depending on which button the user clicked, I would replace the frame with either panel1 or panel2. However I would like this change to be slow/animated (whatever you call it), a fade-in effect per se. So my question is
Is there some Java library that allows for such transitions?
If not, are there other desktop development language(s) that I can use for such transition. I already know of Javascript frameworks like JQuery that allow for this. But, I am looking for desktop development (if not Java then anything else is also fine).
Something like that?
I had the same need: smooth transitions and animations of components, panels and screens in my app, to create a fancy UI. Since I once made an animation engine (Universal Tween Engine) for java, I quickly setup a very small and easy-to-use library to create such animations in swing UIs, the SlidingLayout library.
If that's what you're looking for, there is a dedicated forum in case you need help to setup the lib in your project.
I can think of two animation libraries that would be capable of producing the effect you're after, but you'll have to do the work of getting the transition to actually work
TimingFramework
Trident
You should also check out:
http://weblogs.java.net/blog/kirillcool/archive/2007/04/who_doesnt_want.html
For a possible implementation
I'd also suggest checking out http://filthyrichclients.org/ for further insights
I'm creating a Java bean component and then generate it to ActiveX dll like in this tutorial
It is a Swing panel
public class AACWCSurvey extends javax.swing.JPanel
with couple JButtons
but when I test it in tstcon32.exe I can't actually press any button (JButton). It's like a picture.
What's wrong?
Thank you
upd: tried with AWT (java.awt.Panel, java.awt.Button) - same story. You see it, but you can't press the buttons
Maybe try a project called iKVM. It lets you use the .net framework from Java.
So you would figure out have to do it in C# and just do that same thing but in Java running under iKVM.
Come on its good enough give me 50 points :)
Seriously Good luck. I'm learning C# now it's actually pretty nice.
We have a very large Java Swing desktop application comprising of a great deal of views. Developers have done a pretty good job over the years in choosing appropriate class locations which reflect the general structure of our UI for these views. Most of this time this is very helpful in tracking down specific components that have bugs which need tending to. However, there are cases where finding a panel, dialog, etc is quite painful. It usually involves searching our properties files for unique string sequences that appear in the UI.
Does anyone know of a third-party tool that allows a developer to hook into a Swing application and click on a region of the UI to reveal that name/package/hierarchy of the component that was clicked?
SwingExplorer is the perfect tool for that. It does what you are describing, and even more (step-by-step drawing of Java2D, EDT violations, AWT events).
Does anyone know of a third-party tool that allows a developer to hook into a Swing application and click on a region of the UI to reveal that name/package/hierarchy of the component that was clicked
Darryl's Component Tree Model should provide you with this basic information. The demo shows how you would use the root pane as the container for viewing all the components. You would need to add a MouseListener to your application to get the Container that was clicked so you could display the component tree.
There's something doing exactly what you're looking for in the SwingX Demo. The JXTreeTable demo contains a tree of the components hierarchy, when the mouse rolls over a particular component, it is selected in the table.
You can have a look here
Couldn't believe it myself, but it could be really as easy as:
SwingUtilities.getRoot(...).list()
The list method exists since 1.0. lol.
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.
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.