• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

adding JLabel just bellow after one another

 
Mohammad Shams Tabrez
Greenhorn
Posts: 4
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to add some jlabel components into the jpanel but it is being added on one line not bellow the previous added label..so how can i locate the new jlabel just bellow the previous jlabel on a panel ???
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mohammad and welcome to the Ranch! You need to use an appropriate Layout Manager.
 
Mohammad Shams Tabrez
Greenhorn
Posts: 4
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have tried one, flowlayout....gridlayout makes me puzzld.here is my code...

 
Mohammad Shams Tabrez
Greenhorn
Posts: 4
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh and thank you for worm welcome
 
Campbell Ritchie
Sheriff
Posts: 51332
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FlowLayout won't reliably arrange the two labels above and below. You will have to use a different layout. You can read about them in the Java Tutorials. Grid layout is very easy to use.
 
Campbell Ritchie
Sheriff
Posts: 51332
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't add components in a method like actionPerformed. That will make the GUI unstable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic