Resources for GUI in Java - java

I am making an image processing application in Java. I have written all the code for the processing part, I just need to make a user interface for the same. The user interface looks like this :
It has a browse button to select an image, Once an image is selected, it is to be displayed. The user can now select multiple rectangular regions on this image using mouse (the user clicks at a point in the image and drags mouse to select the region of interest). All selected regions appear shaded. The selected regions also appear in a list, so the regions can be un-selected by deleting the corresponding entry from the list. Finally the user can click on a "process" button to perform the image processing.
I want to know what java gui technologies do i need to create such an interface, and any good resources from where i can read the same. I need resources, for example, about how to manage the layout, display images, mouse events on images etc.

Read the Java trail about Creating a GUI With JFC/Swing.
You will find better answers there than here.
Also, you can use Netbeans; it has a great GUI editor. Or you can check out Google WindowBuilder Pro and install it in your eclipse.

Related

Undo button for Image editor

I have a program that load images and let user edit images with options that I provided.
I'm working on the Undo/Redo button. So when I click on the Undo button, it should bring my image back to the last time before editing. I have ideas about UndoManager but I'm really don't know how to create a function for that.
Should I cast my image to BufferedImage?
I recommend looking into Command pattern. If you are using Swing, that means Actions.
If you do it right, you can have "unlimited" undo/redo easily. You might need to serialize your edits after some time, to avoid running out of memory.

Java dragging image and dropping on the point

I want to create interactive drag and drop. What I mean is that i have 10 slots and 5 buttons, I want to make that user can drag and drop a button on the slot he wants to. I made it with ComboBox and it works fine but I want to make it more interactive. Is it possible in an easy way or I need a hard code? If so any good help on coding would be appreciated.
//Edit. I made it with ComboBox using setLocation(); with saved every slot position
//Edit again with photo:
You can see several example of Drag and drop in Java here and decide which kind of drag and drop you would like to do:
http://docs.oracle.com/javase/tutorial/uiswing/examples/dnd/

Use of image icons in java and implementing online/offline user (view)functionality with JRadio buttons

I think the question title is quite confusing(didn't find much words for the problem), I will try to explain the problem below.
I want to include a feature similar to various chat applications. These applications have a feature to show the contacts of the user. Basically they show the profile picture(image) and online/offline status(image) and the name of the contact. When the user selects (by clicking) any of user the respective window for chat is opened (or the chat window is updated with this user information and chat history when only one chat window is used). Here is a snapshot of the element being clicked (or selected):
So it is implemented(as I think) using a combination of image + image + Text. I suppose these must be using the radio buttons (or something similar).
Now I want to do the same in Java but with java I can use only one image and text for the radio buttons. So I an wandering if there is any way to use more than one image as icon for one component in java swing. Or is there any other way to implement this feature.
JRadioButton haven't Icon
there is drawIcon() only
JToggleButton is parent for JRadioButton
in this case then better could be to use set(Xxx)Icon() for JToggleButton

Drag and drop widgets in Java 2D

Is there any material/tutorials available that can shed some light on creating drap and drop widgets with Java 2D? I am not talking about drag and drop data transfer like here. What I want to do is have a visual pane in my application, where users can create widgets, connect them to each other etc. Something like a creating a graph, but with widgets that have properties.
Thanks.
This is generally works like this:
When a user presses the mouse button your application goes to a "drag" mode
When repaint() method is called while you're in drag mode you move your widget position to the coordinates of the cursor
When mouse button is released you fixate the ultimate position of the windget.
The simple illustration for this might be a program I was writing in my youth - interactive chess board. Here is relevant class that includes pieces dragging capabilities http://jinyan.svn.sourceforge.net/viewvc/jinyan/trunk/jinyan/client/src/net/sfficslecview/lvboard/EditableChessBoard.java?revision=77&view=markup
I have found the perfect solution. I can make use of the Netbeans Visual Library by extracting jar from the Netbeans Platform.

OfficeBean won't display after moving containing Swing Panel from one Container to another

I'm developing a Java 6 applet which allows users to view OO (v.3.2) documents (read only), and if they choose, click a button which launches a new JDialog window, with the document displayed in it which allows the user to and mark and redact it as they wish. Once they are done, they can close the JDialog, which saves the document to a server and redisplay the updated document (read-only again) in the original applet window
I guessed that I could do this with a single instance of an OfficeBean, embedded in a Swing Panel. However, I cannot seem to successfully move my Panel (containing the OfficeBean) from the applet to the JDialog when the "Redact" button is clicked. All I get is a blank area in the JDialog where the document should be. I get no errors.
I have currently managed to get round this by creating new instances of the OfficeBean every time I need to display the document (once when the applet is loaded, again when the user chooses to redact and it is opened in a JDialog, and finally when they click "Save" in the dialog and the redacted result is displayed in the applet again.) However this means three trips to and from the server where the documents originate. That seems mad to me.
I'm in no way a Swing expert and may well be making a silly mistake. However, I've done a lot of fiddling around, debugging and googling and can't seem to get this to work. Can anyone help me in this? Am I trying to do something which is fundamentally impossible? I hope not.
One rule in Swing is that a component can only be displayed / attached to one part of the gui "tree" at a time. When you "move" your component to the dialog, are you first removing it from the applet?

Categories