Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make a custom JButton

2 views
Skip to first unread message

John Taylor

unread,
Mar 23, 2003, 10:25:52 PM3/23/03
to
I would like to make a JButton that looks like this:

---------------------------
| |
| |
| LOG-OUT |
| |
| close this application |
| |
---------------------------

"LOG-OUT" and "close this application" might not be the same Font,
Color, or Size. I want both items to be centered.

Can some one please get me started and/or point me in the right
direction?

Thanks,
John Taylor

Luke Webber

unread,
Mar 23, 2003, 10:40:09 PM3/23/03
to
"John Taylor" <john_tay...@yahoo.com> wrote in message
news:fc30bff.03032...@posting.google.com...

Try this...

JButton myButton = new JButton("<html>LOG-OUT<br><font color='red'
size='8'>close this application</font></html>");


Andrew Thompson

unread,
Mar 23, 2003, 10:46:04 PM3/23/03
to
"John Taylor" <john_tay...@yahoo.com> wrote in message
news:fc30bff.03032...@posting.google.com...
> I would like to make a JButton that looks like this:

Swing components, including JButtons, can accept
html as the component's text.

It would not give the same level of control as
setting the font size yourself, but it is quite
handy..

--
Andrew Thompson
http://physci.org/ - The Physical Sciences project
& host of 1.1C - Sci/Tech site


disc golfer

unread,
Mar 23, 2003, 11:43:12 PM3/23/03
to
It is very handy to use HTML in your components when it becomes necessary.
Do be aware however that it will add 2-3 MB to the footprint of your
application though. It loads a huuuuge of library (or libraries) just to do
the first html tag.

"Andrew Thompson" <anr...@bigNOSPAMpond.net.au> wrote in message
news:0cvfa.3509$Ov1....@news-server.bigpond.net.au...

Andrew Thompson

unread,
Mar 23, 2003, 11:59:52 PM3/23/03
to
"disc golfer" <adisc...@cox.yourclothes.net> wrote in message
news:A1wfa.160164$r26....@news1.central.cox.net...

> It is very handy to use HTML in your components when it becomes necessary.
> Do be aware however that it will add 2-3 MB to the footprint of your
> application though.

I had not realised it was that much..

> It loads a huuuuge of library (or libraries) just to do
> the first html tag.

aah. (shrugs) if the app is shy of 3 meg in the 64(?)
available, it's in trouble anyway. But definitely
something to remember.

Thanks for the tip.. :-)

Matt Schalit

unread,
Mar 24, 2003, 1:25:37 PM3/24/03
to

disc golfer wrote:
> It is very handy to use HTML in your components when it becomes necessary.
> Do be aware however that it will add 2-3 MB to the footprint of your
> application though. It loads a huuuuge of library (or libraries) just to do
> the first html tag.

I removed the xpost to cljp, and I was wondering if
we could discuss this a bit more.

Let's say I want to launch a thread that

1) displays a JWindow splash screen
2) starts loading the HTML libraries.

before my main gui appears. I think this is the standard
way of doing things.

My question is, what would the snippet of code for (2)
look like? Would I maybe do this in the splash thread:

myButton = new JButton("<HTML>Help</HTML>");

Though I've never done this, I'm trying to plan it out
in advance.

Thanks,
Matt

0 new messages