Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Best way to force a JComponent to repaint itself

Reply
Thread Tools

Best way to force a JComponent to repaint itself

 
 
Ben Phillips
Guest
Posts: n/a
 
      08-15-2008
zerg wrote:
> Peter Duniho wrote:
>> You know...I would've just let it go. But I so enjoy flauting your
>> authority (such as it is ).

>
> Congratulations. Now EVERYONE here can feel free to killfile you, secure
> in the knowledge that they won't be missing much by doing so.


FWIW, I've just killfiled the both of you. Merry ****ing Christmas!
 
Reply With Quote
 
 
 
 
zerg
Guest
Posts: n/a
 
      08-15-2008
Peter Duniho wrote:

(Peter had nothing truthful to say at all; merely wasted a post calling
me a liar when he's the liar here.)
 
Reply With Quote
 
 
 
 
zerg
Guest
Posts: n/a
 
      08-15-2008
Peter Duniho wrote:
> On Thu, 14 Aug 2008 23:18:47 -0700, zerg <(E-Mail Removed)> wrote:
>> Then you must get an awful lot of punches in the nose.


(Peter had nothing meaningful or worthwhile to say in response to this.
All he did was idly speculate about my mental health in a vacuum of any
actual information or expertise on the topic.)

>> You need to look deeply into your own motives here, methinks. You
>> obviously aren't here to help people. Why do you find some people not
>> worth your while to spend five minutes helping, but nonetheless worth
>> your while to spend five hours publicly denouncing and berating?


(Peter had nothing meaningful or worthwhile to say in response to this,
either, just vehement and empty denials of having done what anyone can
see he did just by browsing this thread.)
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      08-15-2008
zerg wrote:
> Peter Duniho wrote:
>> On Thu, 14 Aug 2008 00:53:20 -0700, zerg <(E-Mail Removed)> wrote:
>>> Peter Duniho wrote:
>>>> I count FIVE overloads of repaint().
>>>
>>> In the classes themselves, yes. In the JComponent method listing in
>>> the API documentation, there are two. It is the JComponent method
>>> listing in the API documentation that I was consulting, for obvious
>>> reasons.

>>
>> And what reasons are those?

>
> Because that's what leaps out at you when browsing the documentation
> looking for promising method names in the alphabetized list?


You're looking for a method to get a JComponent to repaint. I don't know
about you, but I consider repainting to be a core widget action. That
means I will look first at the root of the widget hierarchy, which is
obviously Component (JComponent is only the root of the lightweight
hierarchy). Ergo, JComponent is only a red herring in the method search.

Also, if you examine the basic structure of the AWT and Swing methods,
you will find LARGE numbers of overloads, and especially methods that do
fair amount of method wrapping (i.e. A is really a wrapper around B with
a bit more magic involved). So although JComponent sets stuff up so that
creating new widgets is simple, it does so by only modifying the roots
of these wraps.

Looking for methods only in a leaf class is not going to be complete.

> Yes, there is, and his name is Peter Duniho. Cursing: "RTFM", at least
> twice.


Actually, some people interpret "RTFM" as "Read The Fine Manual", i.e.,
look at the nuances deep in the text.

> The sets of people that they've called rude have a fair degree of
> overlap, too, particularly tending to include Andreas, Andrew, Arne, and
> Lew.


Account for the fact that Andrew and Lew are in what I would consider
the top tier of posters (the other two being Roedy and Patricia); the
others are in the second tier. For comparison, I would place myself no
higher than the third tier of posters, and even that is a stretch for
me. Those who respond the most tend to be those who get the most mud
flung at them. Posters of... controversy probably get more, though
(think XahLee, Twisted, or JSH).

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
 
Reply With Quote
 
Martien Verbruggen
Guest
Posts: n/a
 
      08-16-2008
On Thu, 14 Aug 2008 01:30:57 -0400,
zerg <(E-Mail Removed)> wrote:
> Knute Johnson wrote:
>> If you had looked at the docs you would have seen that the no-arg
>> repaint() belongs to Component.

>
> I DID look at the docs -- the JList and JComponent docs. Why would I be
> poking around in the AWT docs? I'm obviously using Swing.


In the Java documentation, just after the alphabetical list of methods
under the heading 'Method Summary', there are lists of all methods that
are inherited from each of the superclasses. the no-argument repaint()
is in one of those lists, and the link takes you straight to the
description in the superclass where it's defined. You don't need to
search any other class documentation but the class you're directly
interested in, but you should check all the possible lists of methods in
that documentation.

Regards,
Martien
--
|
Martien Verbruggen | It's not what we don't know that hurts us,
| it's what we know for certain that just ain't
| so. -- Mark Twain
 
Reply With Quote
 
Mark Space
Guest
Posts: n/a
 
      08-16-2008
Martien Verbruggen wrote:

> In the Java documentation, just after the alphabetical list of methods
> under the heading 'Method Summary', there are lists of all methods that
> are inherited from each of the superclasses. the no-argument repaint()


Those lists of inherited methods are a pain to read, imo. They're
mostly useful for searching (Control-F in most browsers).

I think it's easier to click on the link at the top to the superclass,
and read the nicely formatted method summary. Then keep clicking and
reading until you hit Object.
 
Reply With Quote
 
Arne Vajhj
Guest
Posts: n/a
 
      08-16-2008
Mark Space wrote:
> Martien Verbruggen wrote:
>> In the Java documentation, just after the alphabetical list of methods
>> under the heading 'Method Summary', there are lists of all methods that
>> are inherited from each of the superclasses. the no-argument repaint()

>
> Those lists of inherited methods are a pain to read, imo. They're
> mostly useful for searching (Control-F in most browsers).
>
> I think it's easier to click on the link at the top to the superclass,
> and read the nicely formatted method summary. Then keep clicking and
> reading until you hit Object.


It is usually not a problem to read everything at the first
page.

But Swing classes do tend to be a bit heavy in methods.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      08-16-2008
zerg wrote:
> Peter Duniho wrote:
>> On Wed, 13 Aug 2008 21:35:50 -0700, zerg <(E-Mail Removed)> wrote:
>>> I begin to suspect that there's some sort of unwritten code here that
>>> forbids the giving of a straight answer.

>>
>> Forgive us if we suspect that there's some sort of unwritten code
>> among questioners that forbids the inspection of the relevant
>> documentation before asking a question.

>
> Suspect what you will, but I did indeed examine the JComponent API docs,
> and there were three public methods associated with repainting -- not
> counting that repaint() had two overloads.
>
> I may have been somewhat biased by what I was specifically searching
> for, namely a no-argument method for "repaint the whole component". It
> looks like maybe that is simply lacking.


It is in the documentation.

You just need to read it.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      08-16-2008
zerg wrote:
> Knute Johnson wrote:
>> You can get as mad as you want but people are really trying to help you.

>
> That's not what bothers me. It's that they are often remarkably
> unsuccessful at SUCCEEDING that bothers me, and in fairly silly ways.
> For example, if you know, for sure, the exact answer to the question,
> and you don't include it in your response, well, that's just plain silly!


In this group people have some expectations about the posters
of questions.

Those begging to learn Java or learn programming should find
groups better suited for that.

>> And having been around here for a while, when someone asks "What
>> method do I use to repaint() a JComponent," we get sort of suspicious
>> because repainting is rarely the solution to anything.

>
> That's for the programmer to decide, not you. I know my code far better
> than you do, and I don't see why you need to know jack about it in order
> to provide a simple, straight answer for a simple question. If I had a
> design-related conundrum I would ask a design-related question. When I
> have a "how to do X very specific thing with Y" type of question, and
> ask it, I want an equally specific answer, not some kind of inquest
> based on some suspicion, based on very little evidence, that there's
> some sort of problem with my design. I ask for what I want, but you
> reply not with what I want but with your own mixture of suspicions, idle
> questions, and sometimes outright insults.


That is a typical mistake among new programmers.

You really don't want to learn how to do something stupid - you
want to know how to do the right thing.

That sometimes require taking a step back and focus on what
instead of how.

This is a forum where you get the best advice whether you want
it or not.

The smart people learn - other don't.

> JComponent has no no-arg repaint() method save, according to another
> post to this thread, one it inherits from java.awt.Component. Of course,
> since I was not looking at the AWT docs, only JList and JComponent, and
> expecting anything generally useful for Swing components to be in the
> latter in particular, I didn't know about it earlier.


It is on the JComponent document page as well.

There is this thing called a vertical scroll bar out
when you browse the docs. Use it ! Or be really advanced
and use the search function !!

>> 1) Are you updating your ListModel on the EDT?
>>
>> 2) Are you doing long running tasks on the EDT (in a listener for
>> example)?
>>
>> 3) Are you adding or removing components to your JList?

>
> Perhaps I didn't make it clear enough in my previous post to this
> thread. I have not finished the component and begun testing it yet. When
> I do, I will of course observe normal Swing thread-safety procedures and
> avoid doing long tasks on the EDT.


I suggest you do it right the first time.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      08-16-2008
zerg wrote:
> Peter Duniho wrote:
>> there is in fact a "no parameter" overload of the method (see below).

>
> In an AWT class, apparently, where I of course didn't go looking for it
> since I'm working with Swing.


It is is on the doc page for the class you are using also - all you
need to do is scroll.

> If you'd prefer not to answer a question, for some particular reason,
> you could always not post any kind of response to it at all. One thing I
> will certainly not tolerate, however, is any sort of response that
> implies, in front of a worldwide audience no less, that you think I'm in
> some way incompetent. Stop doing that!


Do you think anyone will stop doing anything just because you say so ????

> In a place where I didn't look, and where I had no reason to look, since
> it's in a completely different section of the API documentation.


Same page.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM
JComponent repaint nightmare Roger Davis Java 3 12-11-2003 12:31 PM



Advertisments