I'm making a Java Swing application where the user can run and edit JavaScript and Python code using a ScriptEngine. I want the user to be able to drag-and-drop design custom frames with standard components (buttons, text boxes, etc) and specify code to run when buttons are pressed or text is typed. I will also need a way to load and save the forms and run them inside my app. Are there any libraries I can use for this? I've tried searching around but I'm not finding much.
Related
I want to capture the keyboard and mouse click event on my window everywhere suppose I have opened browser or opened notepad or some other tools, it should not be effected. I know to do one way this with the batch file but I am trying to do this thruogh java libraries. I tried with AWT and swing but they can only capture within their frame.
Please suggest me approach for captuering keyboard and mouse event through java. Any help will be appriciated.
This is problematic the moment you want to run it on different platforms. For Windows, you would need to use Java Native Interface directly to access dll's, or use ready libraries such as this.
These listeners in general are not trivial to implement, but there are some good examples in test sections of linked gitpage.
I'm looking for a really simple widget: tree view on the left pane, folder contents on the right, switchable between icons, thumbnails, or detail view. Basically a functional (not pixel for pixel) emulation of Windows File Explorer, but within the Java app. How to do this using only built-in Java libraries? Or a very lightweight framework?
NOT A DUPLICATE
My question is different from the above and I now realize it's a little harder to explain than I initially expected. Two clarifications:
My question is not about a File Chooser. I'm asking about a File Explorer type of dialog. The difference is that a File Chooser is really focused on one task, choosing a file. A File Explorer is a little less focused, and lets the user browse around without a clear objective.
My question is not about native operating system UI / L&F emulation. At all. I'm asking about the basic capability to display the contents of the filesystem using icons and thumbnails. The style and borders etc are not part of my question.
EDIT
I'm looking for something like this
Notice how it's different from this (JFileChooser)
JFileChooser will do that if you are wanting something built in to Java.
https://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html
If you are not using Swing but SWT (like Eclipse) you can use SWT FileDialog
You could use the AWT library to customly render the entirety of Explorer. Whilst the only hard part about this is correctly using layout managers to get components exactly where you want them and adding event listeners for each button, using AWT wouldn't make it look like Explorer on different operating systems because AWT uses the native system components.
You could check if the OS is not Windows and then use Swing if it isn't. In that case, you'd have to retexture every single used component such that its look and feel is the same as your targeted Windows version. Even if you did that, you'd still have to somehow change the JFrame's look and feel, which is possible using dark magic, but quite obscur. You can do this in a very quirky way, just setUndecorated(true) and manipulate the JFrame's boundaries until it lets you draw outside the JFrame, so that you can draw the Windows' decoration around it without resizing the Window. On top of that, you'd also have to check if it's maximised, as maximized windows don't quite look the same in Windows.
To cut things short, just use JFileChooser if you just want to allow the user to select one or multiple files. There isn't really any point in recreating Explorer, but if that's what you want to do, I'm not stopping you.
Back in my, ahem, Visual Basic programming days, I remember it was very easy to create a multi-form program.
In the gui designer I could simply create as many forms as I wanted and then load them in my program where needed.
I'm having a very difficult time doing this in Java.
I started out using the Java FX Scene Builder but soon discovered there doesn't seem to be good MDI support. So, back to Swing. But, again, I don't see a simple way to design a multi form application.
I read somewhere that JDesktopPane was the way to go as it will allow you to have different internal frames, but there is no way, that I can see, to design multiple frames in the NetBeans gui designer.
You would think that you could hide an internal frame in the designer so you can layout another frame. While I can add multiple frames to my JDesktopPane, they all overlap each other making it impossible to design multiple frames.
Are there any tools available to do what I'm trying to do, or do I just need to bite the bullet and code the guis without the help of a designer?
In brief, I just want to create a simple application that displays three or four options on a home screen
Enter new customer
Search for existing customer
Quick estimate
And depending on which the user selects, opens the appropriate form. It would seem that this would be a basic requirement for almost any program and I don't understand why it seems like actually creating an application with multiple windows/forms was never thought of when developing the design/development tools. Thoughts? Suggestions?
If you're really keen on using the multi document interface (MDI) of the JDesktopPane, create each form in it's own class form. Don't drag them to the desktop. This will allow you to isolate them.
(You can double click a internal frame and it should enter "isolation" mode, basically making it the only thing you can see)
However, unless the windows are sharing information (ie you want to see the information in one window to change the information in another), I'd avoid it.
A better solution might be to use a CardLayout which will allow you to switch between each form as you need.
Again, I'd start by building your forms from something like a JPanel, individually, and when you're ready, add them to your main form.
I always encourage people who are coming into Swing anew to hand code their forms, it will give you a great appreciation for how to design forms and the power of the layout managers.
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
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.