Java Swing layout, can't arrange elements - java

I just started using Swing, because I need GUI for a program I'm trying to do, but I have a lot of difficulties in arranging things like I want. I tried to look on Oracle's site and also in some other place but I still don t understand how to do it.
The final layout that I want is something like this:
For now I don't have in mind specific dimension, just I want to look like this.
Can you help me guys giving me some tips on how to do this?

Eclipse has a really nice "WindowBuilder" feature. You can use it to generate and place components. Give it a try. I think you will like it. You can then study the generated code which will in turn, help you to increase your understanding of swing.

I would personally use MigLayout layout. It is both powerful and easy to use.

Related

Any good suggestion to animations with SWT/JFace

I'm developing a desktop application using java + SWT/JFace, which I'm not very familiar. The program need to show some pictures presenting the program's progress like this.
Sorry for my poor English, I'm not sure whether it's suitable to use the word "moving", actually I mean that the diagram is changing like Flash when an event occurs. I'm considering making some flash movies to play, but it seems difficult as I need to add third-party jars and I'm not good at flash. Is there any better way to doing work like this? I need your suggestion.
Thank you and sorry for my poor English again if I made some English mistakes that troubled you :)
You can use java2d and the awt-swt bridge or there is a framework called Timing Framework which works for swt and swing.
probably you need a gif embeded in your window. java cannot paly any animations unless you have series pictures and play them one by one very soon.

Possible ways to create console like screen in java

I am trying to create a screen like this one
Initially I was trying to port a console program to java. I have found things like jcurses and charva but there is almost no documentation on them and I really cant understand how to use them.
So I figured that I could create a console like screen that resembled the one above.
what library / framwork would I be best using. Should I use swing as it if fully portable?
what would be the best approach being that I need to be able to navigate and alter the 00 in the picture above?
Easily usable would be great but as long as it has good documentation that I can learn it from that would be fine.
(Answering as if you're looking for a hex editor.)
http://jhecomponent.sourceforge.net/
http://www.fifesoft.com/hexeditor/
http://hexedit-lib.sourceforge.net/
Played a bit with the fifesoft.com offering, kinda cool.
If you're not looking for a hex editor, can you be more specific? If you just want a cursor-addressable window you'll probably have to suck it up and figure out something like jcurses or libjcsi :)
If you prefer to create a full fledged GUI with Java you could certainly use Swing. I would prefer SWT as a matter of personal taste, the widget library of Eclipse. You will find a lot of snippets and tutorials (same for Swing). Here is the Widget Library.
Here is a discussion about SWT versus Swing.
You could use the table layout manager to create the layout shown in your screenshot. If you rewrite the application from scretch, you should be able to handle the GUI events and update the widgets according to your application needs. You will easily find articles when you search for swt and table. If you would like to keep the code base and just exchange the GUI, I 'm not sure about the best approach. Maybe, the libs jcurses and charva are the way to go.
Unless you are looking to run the app on a headless VM (where a console/tty is all you've got), I'd use Swing. Create a JTable with a custom TableModel (to provide the data) and custom renderers (to provide the hex formatting) and everything should just work. Consider deriving from the various DefaultXXX implementations to save a lot of work.

How to implement animation into a JFrame

I am used to making web pages with animation using JQuery. I am now making a Java Desktop Application using Netbeans and Netbeans' Swing and without any animation it's looking pretty plain and boring.
Are there any resources I can use for a guide to implement animation into my program?
Does anyone have suggestions on what method to use?
Edit: I am not interested in something I'd have to buy.
A good starting point would be Filthy Rich Clients. Both the principles and the framework code may be helpful to you.
If you're looking for a nice look and feel then Substance might be a good way forward. It's not over-the-top animated or anything like that, but it's got a lot of skins and some in particular look very nice.
Many thanks to stemm who pointed me in the right direction.
I decided to use JavaFX (JavaFX 2 to be exact)
Here is some resources I am using:
http://download.oracle.com/javafx/
http://download.oracle.com/javafx/2.0/swing/jfxpub-swing.htm

Guidelines to implement a minimal shape drawing tool desktop application using Java

We need to implement a Java desktop application that allows us (initially) to create / edit / resize / polygons on (initially) images. Then these polygons would be mapped to objects in our domain model.
So we basically need a toolbar with the options describe above and the possibility for the example to create a polygon on the an image and then scale it, or resize it, just that.
Do you know some library that could facilitate our work?
We've analyzed GEF, Picollo, NetBeans Visual API, Plain Swing or SWT/JFace, but none of them seems to help us to achieve our goal, which is, implement a really basic image editing tool.
I would like to mention that I'm not saying that what I want to do is not possible with the analyzed libraries, of course it can be done, but I'd like to learn from your experiences which is the correct path to take for this problem.
Any suggestion will be welcomed.
You could try to use GEF and the eclipse plataform.
this article could help you.
saluti
You might look at GraphPanel, a simple object drawing program. The control components are arranged in a JPanel, but JToolBar is a more flexible alternative.
Have you looked at imagine.dev.java.net? It is a NetBeans Platform application, which, though unfinished, might provide you with an interesting starting point.

Turn photoshop design into Java GUI

I can't seem to find anybody who has done or posted something like this; Essentially I want to design my own UI in photoshop and then slice down the images to use it in a Java application. Essentially coding in the PSD file as the GUI. Is this possible? If so, can anybody lead me in the right direction?
I'm not sure what editor to use for this sort of stuff. I am using the Eclipse IDE and I know there is a Visual Editor but, I already have the actual design for every component in a PSD file. All I want to do is to start incorporating this into the application. Thanks.
It depends on how far your design goes. If you simply want to have normal Swing components on top of your image this is easy. Convert your PSD into (for example) PNG, create a custom JPanel subclass that loads the image and overwrite the paintComponent() method to draw the image instead of the normal background. All child components can then be set to be transparent with setOpaque(false). This puts your image into the background and puts the components float on top of it.
If you want to change how individual components look, its a lot more work. You basically need to implement a new Look&Feel for Swing. I wouldn't recommend going that route, unless you really have to, we are talking about weeks of work here, and it requires a lot of testing to really make it work properly on all platforms.
Alternately, there are already tons of custom Look&Feels available, I suggest you take a look at some freely available ones (just google "java look and feel"). Many of them can be customized to some degree (how much depends on the actual implementation, so take a close look at the source/documentation for each of them).
You might want to take a look at NetBeans which has a Swing GUI Builder. You would have to redraw your components there, and then write all the code to process the events. It is sometimes good to start with that, though often times it is less frustrating to lay them out with code by hand as it can difficult to make changes in code and have the builder keep up. There is nothing I know that will let you start from a photoshop image and proceed to building a GUI. Sounds like a good project to make someone rich. :-)

Categories

Resources