i’m working on GUI in java and got stuck with move the object.
Please visit this youtube video i made a short demo for you guys to see what i was trying to do. I’m so new to the GUI thing as i’ve never been taught of doing GUI.
Here is the link: http://www.youtube.com/watch?v=up1LV5r-NSg
I see you’re using a GUI designer. I highly recommend building your GUI “by hand” instead in which case your code is IMO much clearer (I’m not saying all GUI designers produce bad code, but it is almost always harder to read, and editing it will be hard without using the exact same GUI designer). Once you’re comfortable with GUI designing by hand, then try a GUI designer and see what makes you more comfortable.
See: http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html
In your case, you might create a BorderLayout, and in the “south” of your panel/frame you can place a panel with a FlowLayout aligning it’s components to the left. Then add your button to the panel with the FlowLayout.
A little demo:
produces:
alt text http://img689.imageshack.us/img689/5874/guiq.png
EDIT
And to move the button a bit more up, use the constructor
new FlowLayout(FlowLayout.LEFT, int hgap, int vgap)where
hgapis the gap (in pixels) between the left and right components andvgapis the gap (in pixels) between the upper and lower components.Try:
Note that the space between the button and text area also increases slightly!