• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me make my submit button smaller

 
Kaspersky Ukshini
Ranch Hand
Posts: 122
C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, can you please help me make this button:


look more like this one:


I'm using GridLayout for my main JFrame.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API docs for GridLayout
The GridLayout class is a layout manager that lays out a container's components in a rectangular grid. The container is divided into equal-sized rectangles....

Solution
1) Use GridBagLayout
or
2)Use nested layouts.
or
3) Use MigLayout
 
Kaspersky Ukshini
Ranch Hand
Posts: 122
C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried nested, not very lucky..
If I use GridBagLayout ,which possition should I assign my button when addint it to the panel? SOUTH or anything that I should be aware of?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kaspersky Ukshini wrote:Tried nested, not very lucky..

Create a panel (defaults to FlowLayout, do not explicitly set any other layout to it)
Add the button to the panel (Using FlowLayout.CENTER if you wish so)
Add the panel to the main panel (with the gridlayout)

 
Kaspersky Ukshini
Ranch Hand
Posts: 122
C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:
Kaspersky Ukshini wrote:Tried nested, not very lucky..

Create a panel (defaults to FlowLayout, do not explicitly set any other layout to it)
Add the button to the panel (Using FlowLayout.CENTER if you wish so)
Add the panel to the main panel (with the gridlayout)



This is how I declare my JPanel:


this is how I add the submit button to it:



and it gives me the following error:
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do not pass the FlowLayout.CENTER when you add the button, but when you declare the layout
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!