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 / GUI / May 2008

Tip: Looking for answers? Try searching our database.

Problem with Buttons

Thread view: 
Kenneth P. Turvey - 21 May 2008 03:42 GMT
I'm trying to convince Java to create a button that is exactly the same
size as the image that I'm using for it.  I've set the Insets to (0, 0,
0, 0), but this isn't working.  There is still some kind of border around
the button.  

Do I need to write my own button class to do this, or is it possible with
JButton?  

Any hints would be appreciated.  

Thanks,

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Knute Johnson - 21 May 2008 03:50 GMT
> I'm trying to convince Java to create a button that is exactly the same
> size as the image that I'm using for it.  I've set the Insets to (0, 0,
[quoted text clipped - 7 lines]
>
> Thanks,

I would imagine that the decorations on a JButton are very look and feel
dependent.  If you really need it to be a certain size, write your own.
 It is not that hard.

Why do you want it to be a specific size?

Signature

Knute Johnson
email s/knute/nospam/

Kenneth P. Turvey - 21 May 2008 04:05 GMT
> I would imagine that the decorations on a JButton are very look and feel
> dependent.  If you really need it to be a certain size, write your own.
>   It is not that hard.
>
> Why do you want it to be a specific size?

The customer specified how it would look by giving images for normal,
over, and selected.  There are a number of buttons and the only way to
get them to all look the way the customer specified, and to layout the
way the customer specified is to make them the size the customer
specified.  

This isn't really "the Java way", but that's the way I'm doing it.  In
addition, I may be using an absolute layout for the toolbar since I just
can't get it to be perfect without one.

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Kenneth P. Turvey - 21 May 2008 04:32 GMT
> I would imagine that the decorations on a JButton are very look and feel
> dependent.  If you really need it to be a certain size, write your own.
>   It is not that hard.
>
> Why do you want it to be a specific size?

After starting to write my own, then realizing that I will need one class
for regular buttons and another for toggle buttons and that the
complexity, although not high, is higher than I was ready to invest time
in, I realized that I can achieve what I want by simply setting the
border to null.  I know this isn't the recommended way of handling
borders in swing, but I couldn't think of a situation where this would be
a problem.

Signature

Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

Knute Johnson - 21 May 2008 05:21 GMT
>> I would imagine that the decorations on a JButton are very look and feel
>> dependent.  If you really need it to be a certain size, write your own.
[quoted text clipped - 9 lines]
> borders in swing, but I couldn't think of a situation where this would be
> a problem.

I don't know, sounds like it solves your problem.

Signature

Knute Johnson
email s/knute/nospam/

Paul Schwann - 21 May 2008 13:58 GMT
Hi,

> Any hints would be appreciated.  

Assuming you are using a Swing-Button (JButton), #setMargin and
eventually #setBorderPainted shall do the trick.

Regards,
Paul


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.