Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30403
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Could this be done better |
| Organization | Decebal Computing |
| References | <87zjbg97c5.fsf@Equus.decebal.nl> <m4vf1f$j03$1@dont-email.me> <m4vpb5$9ue$1@dont-email.me> |
| Date | 2014-11-25 00:11 +0100 |
| Message-ID | <87bnnw6vo1.fsf@Equus.decebal.nl> (permalink) |
Op Monday 24 Nov 2014 18:19 CET schreef Knute Johnson:
> Eric gave you all the biggies, I'll nit-pick a little.
>
> From the docs, JFrame:
>
> "As a convenience, the add, remove, and setLayout methods of this
> class are overridden, so that they delegate calls to the
> corresponding methods of the ContentPane. For example, you can add a
> child component to a frame as follows:
>
> frame.add(child);"
>
> so you can skip the call to getContentPane().
As I understood it, this was the only way to change the background
colour of the frame. (I want it to be the same as from the label.)
> You first call pack() and the call setSize() on your frame. Only one
> is really necessary.
I want a line above and below the label. This was in my opinion the
easiest way to accomplish that.
> tricky. Using GridBagLayout as you did, causes the component to be
> sized to its preferredSize and then put in the middle of the frame.
> Using BorderLayout, the default, will cause the content to fill the
> area of the frame that is available.
I think that in this case it was the good thing to do, but I'll look
into your suggestion.
> Very small nit: The frame title is a parameter of the constructor.
> You could have used:
>
> super(description) as the first line.
When I try that I get:
ColourCycling.java:10: error: cannot reference description before supertype constructor has been called
super(description);
> In updateColour() you call label.setText(""), then change the color
> and then set the text again. What you were seeing with the text
> changing and then the color changing were very likely artifacts from
> updating the JLabel from other than the event dispatch thread.
In the latest version I was not doing that anymore. I am using the EDT
there.
> Another very small nit: you used the older versions of color
> constants with the lower case field names. In 1.4 new constants were
> added with upper case names to match current convention.
Every where I looked both where defined and most often the lowercase
used, but I'll change it.
> Here is a JLabel that displays the current time. Looks very similar
> to your example. I added an empty border to give you an example of
> how to do that too.
I'll look into it. Thanks.
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 12:16 +0100
Re: Could this be done better "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-11-24 22:49 +1100
Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 17:54 +0100
Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 09:37 -0800
Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 19:27 +0100
Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-24 09:23 -0500
Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-24 17:45 +0100
Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-24 13:42 -0500
Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-25 00:12 +0100
Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 09:19 -0800
Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 09:41 -0800
Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-25 00:55 +0100
Re: Could this be done better Cecil Westerhof <Cecil@decebal.nl> - 2014-11-25 00:11 +0100
Re: Could this be done better Knute Johnson <eternal@knutejohnson.com> - 2014-11-24 16:26 -0800
Re: Could this be done better Brixomatic <brixomatic@yahoo.com> - 2014-11-25 19:58 +0100
Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-25 14:36 -0500
Re: Could this be done better Brixomatic <brixomatic@yahoo.com> - 2014-11-26 01:58 +0100
Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-26 08:48 -0500
Re: Could this be done better Brixomatic <brixomatic@yahoo.com> - 2014-11-29 19:43 +0100
Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-29 15:44 -0500
Re: Could this be done better Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-11-29 15:47 -0500
csiph-web