• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FlowLayout Alignment, anyone?

 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
desired_frame.jpg
[Thumbnail for desired_frame.jpg]
This is what I want to do.
Frame_now.jpg
[Thumbnail for Frame_now.jpg]
This is the current state, components are added and appear starting in the middle
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Police line, do not cross. Well, this tiny ad can go through:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic