Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set two buttons on the center of JPanel  RSS feed

 
Shen Lin
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to creat a interface with two buttons on the center of JPanel buttonPane. I tried FlowLayout. But it only can put thoes two buttons near the top-side edge of the buttonPane. Can anyone tell me how to set buttons on the center?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Shen Lin!
Take a look at GridLayout and think about using "blank" components to fill those empty cells. Or, if you really want to get sophisticated, take a look at GridBagLayout.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and in your spare time, you might want to read The Laying Out Components Within a Container Lesson of The Creating a GUI with JFC/Swing Trail of Sun's Java Tutorial.
Good luck and feel free to post example code of what you've been working on when asking further questions.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!