Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help me make my submit button smaller

 
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.
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • 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
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic