Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2006

Tip: Looking for answers? Try searching our database.

Need help to make a button smaller

Thread view: 
joan - 16 Mar 2006 16:12 GMT
Can someone help me to make a button smaller? I am new to Java
programming. Thanks!
Rhino - 16 Mar 2006 16:39 GMT
> Can someone help me to make a button smaller? I am new to Java
> programming. Thanks!

An excellent resource for new Java programmers is the Java Tutorial. You can
see it online at this URL:
http://java.sun.com/docs/books/tutorial/index.html

The chapter (the authors call them "trails") that you want to see is
entitled "Creating a GUI with JFC/Swing". If you click on that link, then on
"Using Swing Components", then on "A Visual Index to the Swing Components",
then on the "Buttons" link in the Basic Controls section, you will get lots
of information about creating buttons.

Unfortunately, the tutorial article on buttons doesn't have much to say
about sizing of components so this might not be a great resource for your
particular problem.

If you don't find enough information on sizing buttons, do an archive search
of the java newsgroups. This will help you find all discussions of sizing
that have taken place since the discussions have started being saved, which
is sometime in 1997.

Here's a description of the initial search I would do if I had to research
button sizing:
1. Go to http://groups.google.ca/advanced_search
2. Enter the following in the "with all of the words" box: JButton size
3. Enter the following in the "Return only messages with the group at this
location: comp.lang.java.*
4. Click on "Google Search".

I got 800+ threads that discuss the issue when I did this search. You will
probably only need to read the first few of these threads to hear everything
you want to know about button sizing.

Also, don't be afraid to look in the API for JButton. If you do, you will
see methods that affect the size of the button. Please note that the methods
which control the size of a button are not part of JButton itself but are
inherited from its parent classes, specifically  JComponent, but you can
access these via links in the JButton API.

--
Rhino
Thomas Weidenfeller - 16 Mar 2006 17:01 GMT
> Also, don't be afraid to look in the API for JButton. If you do, you will
> see methods that affect the size of the button. Please note that the methods
> which control the size of a button are not part of JButton itself but are
> inherited from its parent classes, specifically  JComponent, but you can
> access these via links in the JButton API.

One final note. If you feel the need to manually manipulate the size of
a button you are probably trying to circumvent layout managers. Doing
this, however, is the wrong way. The way to enlightenment is via layout
managers.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Oliver Wong - 16 Mar 2006 17:13 GMT
> Can someone help me to make a button smaller? I am new to Java
> programming. Thanks!

   Normally, the programmer doesn't explicitly specify the size for any of
the components, because doing so usually involves making assumptions that
may not be true across all architectures. For example, perhaps a person with
visual impairement with have their OS set up so that fonts appear twice as
large as they normally would. If you hard-code a size for your button, the
button may be too small to fit the contents of its label.

   Usually, it's best if you just leave the sizing and placement of the
buttons and other components up to the layout manager.

   - Oliver
IchBin - 16 Mar 2006 17:58 GMT
> Can someone help me to make a button smaller? I am new to Java
> programming. Thanks!

Look here:

http://java.sun.com/docs/books/tutorial/reallybigindex.html
http://java.sun.com/docs/books/tutorial/uiswing/components/button.html

Examples..
http://javaalmanac.com

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.