views:

72

answers:

2

Hello, first of all, this is more or less my first GUI and ive learned Java for not more then a week, so it might contain some serious programming errors.

What i have right now is: Buttons and labels are part of OptionPanel and are on the left, DrawingPanel is about 5x5 px in size and is on the right.

What I am trying to do is a simple test, to get me more familiar with the GUI. The rectangle should be movable and re-sizeable by the user when clicking the respective buttons: http://www.upload.ee/image/612005/JFrame2.jpg

Right now i have:

JFrame MainFrame - Makes JFrame (Not using the setSize function. using .pack() instead. not sure about it)

JPanel MergedPanel - FlowLayout - Adds JPanel OptionsPanel and JPanel DrawingPanel together and gets injected to JFrame MainFrame

JPanel DrawPanel - This JPanel is responsible of drawing the rectangle. JPanel OptionPanel - FlowLayout - This JPanel is responsible of the buttons.

Help please.

+2  A: 

Check out MiG Layout : one can make pretty easily java layouts with that.

Touko
+2  A: 

You should never call setSize() in your code. In Java, you use layout managers to do the layout (read that tutorial).

Subclassing JPanel to implement different parts of which the UI is composed is a good practice, but should not be overdone (it's fine to have an UI class that adds 3 other plain JPanel instances to itself for layout purposes).

Michael Borgwardt