aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes FlowLayout Alignment, anyone? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "FlowLayout Alignment, anyone?" Watch "FlowLayout Alignment, anyone?" New topic
Author

FlowLayout Alignment, anyone?

Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Hello There !

How are you today ranchers ?
Well, I'm confused about how does FlowLayout layouts my components in a JPanel. it's as simple as this; I'm using:

//bottomPanel is an instance of JPanel


And I start to add components to it, but they don't start to occupy space from the Right margin, instead... The components start filling the panel from the middle, and then start moving to the right as more components are added.

Is there something additional I can do to get it to look just like I need it ?

Thank you very much in advance,

Best Regards,

Jose



[Thumbnail for desired_frame.jpg]


[Thumbnail for Frame_now.jpg]

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2091
    
    7
Orientation is used for languages where people read from right-to-left, instead of the way we use left-to-right. As your topic title says, you are concerned with "alignment" of components.

Read the API or tutorial for the correct method to use.

Also, posting pictures is not the best way to ask a question because we can't see your actual code that is causing the problem.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
For the Sake of Message Length, I avoided posting any additional code, Probably I'm making the wrong assumptions as to where the problem lies, so... Here's the rest of it:



I'm still not posting everything there, but that's all that has to do with GUI-creation. Oh, and by the way, I have reviewed the Layout tutorials, and unless I understood incorrectly that's how I think I'm supposed to do it to get the components to place themselves there (Right Margin). If I'm wrong please tell me, I'm an Just a student, and you are the master.

Thank you again Rob.

Sincerely,

Jose.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2091
    
    7
That is NOT a SSCCE.

You questions is about alignment of components to a panel. To create a SSCCE you ignore your existing code and start from scratch:

a) you create a panel
b) you add a couple of components to it
c) you add the panel to your frame
d) you make the frame visible

It should be about 10-15 lines of code in this case. That is NOT too much to post and is extremely easy for us to read.

Did I not suggest "orientation" is wrong and "alignment" is correct. So why did you post old code when I already gave you the answer to your question. Read the API, the word "align" is used multiple times in the API. I will not spoon feed you the answer, you need to learn how to read the API. This is the last time I repeat myself when I give an answer.
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
I must apologize for the unnecessary code. it is my fault not to pay attention to your instructions. I should be more careful.
I hope you're not completely upset towards me about it. Sometimes I'm just too eager to get help.
I solved the problem with the hint you provided me, and for that I give you thanks...

I'm deeply sorry for all the inconveniences.

Sincerely,

Jose.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FlowLayout Alignment, anyone?
 
Similar Threads
Add Drag and Drop functionality to JPanel?
Swing: Adding components to containers
Swing - valign
complex dialog layout?
Does FlowLayout honor the preferred size of a JPanel?