comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Create dummy oracle.sql.STRUCT - How? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/20cd6093705d3ee3
* Thread-question - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
* Custom paint in JScrollPane - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee45b5808b7ee9ef
* Need as much help as possible - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c8e64b34d7154d8
* How to exclude a string using regexp pattern? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e2c5860c47dc5d15
* Java client connected to non-Java server problems - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9dcb548fa77a4b46
* jain-sip api - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/918018aa473fe074
* Property editor - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/900d4aeb52446c2e
* How to paint in Component Graphics? - 6 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c10fbaedc6c93664
* Swing - Detect how focus was moved? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/844c965c9aa3c8c1
* who uses algorithms learned in cs studies? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf
* RegEx partial matching - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/14069fafc93c4493
  
==========================================================================
TOPIC: Create dummy oracle.sql.STRUCT - How?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/20cd6093705d3ee3
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 12 2004 2:16 am
From: "Andy" <[EMAIL PROTECTED]> 

I'm using Java in PL/SQL Developer to make small database app. However,
there is no debugging possibilities, thus I moved the code to IntelliJ. In
order to run and test the program I must be able to create a dummy
oracle.sql.STRUCT instance:

java.sql.Connection conn =
java.sql.DriverManager.getConnection(connectionString, user, password);
StructDescriptor structDesc = StructDescriptor.createDescriptor("EMP_TYPE",
conn);
oracle.sql.STRUCT searchAttributesAsSqlSTRUCT  = new
oracle.sql.STRUCT(structDesc, conn, searchAttributes.toArray());

However, there is a lot mumbo jumbo about the connection cannot be created
because there are no suitable drivers. However, I'm not interested in
creating a connection at all, I just want a dummy STRUCT. In fact, I could
replace the STRUCT with a List instead, but I want to have the STRUCT in
order to be able to cut and paste the code in PL/SQL Developer. How do I
create a dummy oracle.sql.STRUCT?






==========================================================================
TOPIC: Thread-question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
==========================================================================

== 1 of 3 ==
Date:   Fri,   Nov 12 2004 2:18 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Carl Howells wrote:

> Observed behavior.  I just wrote up this test:

An interesting example, thanks.


> So, there's definately a bias against objects with finalizers in those
> JVMs.  The bias becomes less extreme as more and more objects are
> collected, but it's still present.

I think that you are seeing the effect of objects having to wait on the
finaliser thread's queue (see my reply to John Bollinger).  Unless your test
was running on a multi-processor machine (and possibly even if it was) then the
finaliser will have been contending for CPU time with your executing loops, and
so it won't have been able to run as often as it would "like to".  If that
surmise is correct, then adding a small delay to your loop should give it a
chance to run and clean up.

Notice, by the way, that your use of reference queues is essentially the same
as how the system (I think) implements finalisation.  The GC sees that an
object is "special" and instead of just wiping it, it places it on a queue for
some other thread (or other processing) to deal with.  In the case of your
example, it is placing the reference object onto the queue rather than the dead
object itself, but the logic is similar to finalisation (though I'd guess that
it's marginally more expensive to execute).  The bit that corresponds to the
finaliser thread's activity is your loop where you poll() the queue.

>From the look of the results you quoted, your own loop has a slight advantage
over the finaliser thread's loop, but I don't know whether that is simply
reflecting an "unfair" advantage due to being scheduled more often, or is
because of some other aspect of the implementation.  At the minimum, there's an
"unfair" advantage to your loop in that the results are reported when /it/ has
finished, but without also waiting for the finaliser to finish.  In a sense,
your loop gets to decide when the "race" is over, so even if it and the
finaliser were working at the same speed on average, we'd never see the
finaliser "beat" your loop, we could only ever see it "draw" or "loose".

    -- chris





== 2 of 3 ==
Date:   Fri,   Nov 12 2004 1:50 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

John C. Bollinger wrote:

> > > Bad idea. On most modern JVMs, finalizers seriously mess up garbage
> > > collection.
> >
> >
> > I have to say that I find this implausible.  Obviously finalisation adds
> > overhead to the GC operation, but that's because it's doing extra work
> > -- /useful/ extra work -- but it sounds as if you mean something more
> > than that. Do you have any references ?
>
> I haven't looked up references (yet) but my understanding is that Carl
> is correct, if perhaps overly emphatic.  Based only on the API docs and
> JLS, [...discussion snipped...]

I agree that it will make the GC system do more work, but I don't see that it's
"messing up" the GC, just that finalisation interacts with GC.

The "obvious" way to implement it (actually, I can't think of a better way, but
I suspect there almost certainly /are/ better ways) would go something like
this:

When an object with a non-empty finalize() method is created, a flag is set in
its header -- meaning "must finalise".  When GC discovers an object to be
"unreachable" it checks the flag, if that flag is not set then it <does
whatever it would normally>, otherwise it adds it to a queue serviced by a
finaliser thread (so the object has now become reachable again), and moves on.
The finaliser thread sits waiting on the queue; when something appears, it
takes it off the queue, clears the "must finalise" flag, and executes the
object's finalize() method (trapping and ignoring all exceptions).  It then
moves on to the rest of the queue.  If the object has not become reachable
again then when the GC next re-visits it, it will be reclaimed.

Now if a real implementation is anything like the above, then I don't think its
helpful to describe finalisation as "messing up" the GC.  The system as a whole
has to do a little more work for each finalisable object -- but that's fair, we
/want/ it to do more work otherwise the finaliser wouldn't get run.  But the GC
itself is just doing its normal job and is not impeded by the presence of
finalisable objects.  (Of course it could run faster if the spec didn't allow
finalisation at all, in which case there would be no need to check any flags).

Notice how the finalisable object's finalise method can get called almost
arbitrarily later than when it was first discovered to be unreachable.  Notice
also that its eventual reaping is also postponed, happening at least one GC
cycle later than when it was first "noticed" by the GC, even if the finaliser
thread is keeping up with the rate that objects are put on its queue.  But
those delays are not symptomatic of the system being prevented from working
properly, they are just the expected result of the design.


> > It's perfectly at liberty not to collect anything.  But again you seem
> > to be going beyond that and stating that it (they) will discriminate
> > against objects with finalisers.  Again, this sounds implausible.  Do
> > you have a reference for it ?
>
> That would be an implementation question, but I suspect that many Java
> GC implementations indeed do exactly as Carl describes.  It really is a
> much bigger deal to collect an object with a non-default finalizer than
> to collect other objects.

I don't think that's the right way to look at it.  It is no bigger deal to GC a
finalisable object than any other (except, of course, that it has to be GCed
twice).  The lifetime of a finalisable object is more complicated than other
objects -- naturally -- and the system does more work as the object dies than
it would otherwise need to, but that's just natural.   It's sort of like saying
"don't make objects serialisable since the system will have to do more work
when it serialises them" ;-)  That's not to say that finalisation's /free/, or
even that it's /cheap/ -- it has costs, just like anything else.

For comparison: it /would/ be fair to describe it as "messing up" GC if the
actual use of finalisation made other objects harder to re-claim.  For instance
if the implementation of reference queues were such that every reclaimed object
had to be checked against all the existing queues (impossible to believe the
implementation /is/ like that!), then each new queue would add extra load to
the /whole/ system.  In such a case it would be very correct to say that
reference queues mess up GC.


> It might be a little too strong to say that Java's finalization
> mechanism is broken,

Unless, of course, it actually /is/ broken -- that's an implementation
question.  I haven't heard of any problems with the Sun implementation myself,
but there could easily (-ish) /be/ such problems that Carl has heard of but I
had not.  Which is why I asked.


> but I have never personally run into any task to
> which it is suited.  It is definitely a trap, because people --
> especially those with experience in some other OO languages, such as C++
> -- tend to make incorrect assumptions about how finalization works.  It
> has been said here before and it will be repeated again: a Java
> finalizer is not at all the same thing as a C++ destructor.

It can certainly mislead C++ programmers -- we see it here often (I'm sure
you're as sick of it as me).  It can also be abused, especially if people think
they can use it to clean up and reclaim system resources that are significantly
more scarce than normal object memory.  (The incredibly stupid example of NIO
system buffers leaps to mind).  But I think it has its uses.  As I've said
before, finalisation is (IMO) best viewed as a kind of reflection -- reflecting
on an object's lifetime -- and like all reflection it's not something you are
going to need every day.  Depending on what kind of programming you do, you can
go a lifetime and never use it.  But if you do need it, then /boy/ do you need
it...

    -- chris





== 3 of 3 ==
Date:   Fri,   Nov 12 2004 2:49 am
From: Gordon Beaton <[EMAIL PROTECTED]> 

On Wed, 10 Nov 2004 09:16:02 -0000, Chris Uppal wrote:
> Carl Howells wrote:
>> Bad idea. On most modern JVMs, finalizers seriously mess up garbage
>> collection.
> 
> I have to say that I find this implausible. Obviously finalisation
> adds overhead to the GC operation, but that's because it's doing
> extra work -- /useful/ extra work -- but it sounds as if you mean
> something more than that.

The extra work done by finalization may be useful, but there is no
added value if you could have done it yourself with a suitable
dispose() method. However the cost is there regardless.

> Do you have any references ?

Here's one:
  http://servlet.java.sun.com/javaone/javaone2000/event.jsp?eventId=1172

(In particular, pages (approx) 30-36 of the slides)

Although this was presented 4 years ago and some implementation
details have likely changed since then, several of the arguments he
presents against finalization (e.g. average age of objects and the
resulting effect on process size) certainly hold regardless of
implementation.

In particular, one aspect he mentions that seems to be missing from
this discussion, is the tree of objects that are artificially kept
alive because of references from (other) objects waiting for
finalization. Longer average object life leads to more live objects at
any given time, and consequently more work for the garbage collector.

If I've understood correctly, objects that use finalization must be
queued for gc a second time, after finalization has run.

Similar comments can be found in appendix A "The truth about garbage
collection, in "Java platform performace":
  http://java.sun.com/developer/Books/performance/

Here's another:
  http://www-106.ibm.com/developerworks/java/library/j-jtctips/j-jtc0319a.html

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




==========================================================================
TOPIC: Custom paint in JScrollPane
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee45b5808b7ee9ef
==========================================================================

== 1 of 3 ==
Date:   Fri,   Nov 12 2004 2:35 am
From: Thomas Richter <[EMAIL PROTECTED]> 

Hi folks,

is there a certain rule for making up components when overloading the
"paint" method of a JPanel? I've having here a class that does this:

class ImgPanel extends JPanel {
        ...   
        public ImgPanel(Tree t) // no matter what this is right now
        { 
            super(false);
            int w,h;
            tree = t;
            w    = tree.getWidth();
            h    = tree.getHeight();
            dim  = new Dimension(w,h);
            setSize(w,h);
            setPreferredSize(dim);
            setOpaque(false);
        }

        public void paintComponent(Graphics g)
        {
            tree.draw(g,0,0,this);
        }
}

Now, everything is fine as long as I add this to the top level content
pane of a JFrame - it's rendered correctly. However, as soon as I add
this into a JScrollPane, trouble begins. The image gets rendered, but
something then erases the image again with the default grey background,
writing on top of my rendered image. I've already tried to set the
JScrollPane to non-opaque, but no go. Any idea what's going on here?

So long,
        Thomas





== 2 of 3 ==
Date:   Fri,   Nov 12 2004 2:53 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 12 Nov 2004 10:35:12 GMT, Thomas Richter wrote:

> class ImgPanel extends JPanel {
>       ...   
>       public ImgPanel(Tree t) // no matter what this is right now

What is a 'Tree'?  (And why are you so sure it is 'right now'?)

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 3 of 3 ==
Date:   Fri,   Nov 12 2004 3:31 am
From: Babu Kalakrishnan <[EMAIL PROTECTED]> 

Thomas Richter wrote:
> Hi folks,
> 
> is there a certain rule for making up components when overloading the
> "paint" method of a JPanel? I've having here a class that does this:
> 
> class ImgPanel extends JPanel {
>       ...   
>       public ImgPanel(Tree t) // no matter what this is right now
>         { 
>             super(false);
>             int w,h;
>             tree = t;
>             w    = tree.getWidth();
>             h    = tree.getHeight();
>             dim  = new Dimension(w,h);
>             setSize(w,h);
               ^^^^^^^^^^^^             
The above code is superfluous if you're adding your component to any 
container with a LayoutManager present.

>             setPreferredSize(dim);
>             setOpaque(false);
>         }
> 
>         public void paintComponent(Graphics g)
           ^^^^^^ -> "protected" is better since you don't want anyone 

                     calling it directly anyway
>         {
>             tree.draw(g,0,0,this);
>         }
> }
> 
> Now, everything is fine as long as I add this to the top level content
> pane of a JFrame - it's rendered correctly. However, as soon as I add
> this into a JScrollPane, trouble begins. The image gets rendered, but
> something then erases the image again with the default grey background,
> writing on top of my rendered image. I've already tried to set the
> JScrollPane to non-opaque, but no go. Any idea what's going on here?
> 

I would bet it has something to do with what you're doing in the draw
method of your Tree class. (And also the fact that your draw method
should require a reference to the ImgPanel in addition to the Graphics
context makes me very suspicious that you're doing something naughty
with the code in there :-))


BK




==========================================================================
TOPIC: Need as much help as possible
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c8e64b34d7154d8
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 12 2004 3:10 am
From: Joona I Palaste <[EMAIL PROTECTED]> 

WCU_Student3456 <[EMAIL PROTECTED]> scribbled the following:
> hey i'm new to the java scene and i have a major assignment due for class
> on the 12th of nov.  I need help with a program that has a point class...a
> driver and a circle class. the program is suppost to display info about the
> circle...if anyone is interested or has pitty...college students love
> pitty..please respond and i will try to send the assignment to you...i
> have it scanned on adobe...

> thanks ever so much

By the time you get to read this, the deadline will have expired. So
please send the assignment to you and I'll send you the required program
code some time on Saturday on Sunday.

-- 
/-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"To doo bee doo bee doo."
   - Frank Sinatra




==========================================================================
TOPIC: How to exclude a string using regexp pattern?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e2c5860c47dc5d15
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 12 2004 3:34 am
From: Alan Moore <[EMAIL PROTECTED]> 

On 11 Nov 2004 22:23:03 -0800, [EMAIL PROTECTED] (Victor) wrote:

> From the following log.txt file, if I want to remove the other strings
> but to keep the "[GC 84000K->74959K(88984K), 0.0250350 secs]" string:
> 
> [Thu Nov 11 00:34:25 EST 2004] stderr:  ejbcontainer: >>>> EJB LOG
> >>>>
> [Fri Nov 12 01:15:19 EST 2004] stdout:  [GC 84000K->74959K(88984K),
> 0.0250350 secs]
> 
> What regexp pattern I should use? For example, if I specify a "!" in
> front of the pattern (\[GC.*\]) which is correctly representing the
> "[GC 84000K->74959K(88984K), 0.0250350 secs]" string:
> 
> <replaceregexp file= "C:\log.txt" flags= "s" > 
>     <regexp pattern="!(\[GC.*\])" />
>     <substitution expression="" />
> </replaceregexp > 
> 
> It just won't work.
> 
> Do you have any idea(obviously we can't use the '^' for this purpose)?
> Or I have to create a new java program to do this?

Unfortunately, regexes don't provide a way to not-match specific
sequences of characters, but through creative use of lookaround and
negated character classes, we can usually manage it.  Try this:

<replaceregexp file= "C:\log.txt" flags= "g" > 
  <regexp pattern="(?:[^\[]++|\[(?!GC ))*+((?:\[GC [^\]]++\])|$)" />
  <substitution expression="\1\n" />
</replaceregexp > 

That is, match one or more of any character other than an open
bracket, or an open bracket if it's not followed by "GC ", repeated
zero or more times.  That part of the regex will match everything up
to the next GC block (or to the end of the file if there aren't any
more GC blocks), and the text matched by it will be discarded.  Upon
finding an open bracket that's followed by "GC ", the next part will
match and capture everything up to and including the next close
bracket, and that text will be inserted into the output.

With this regex, you don't need to use the "s" flag, but you may need
to use the "g" flag--I'm not sure if Ant requires that when you're
using the JDK regex engine (I assume that's what you're using; if not,
this regex won't work at all).



== 2 of 2 ==
Date:   Fri,   Nov 12 2004 5:54 am
From: "Ann" <[EMAIL PROTECTED]> 


"Alan Moore" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 11 Nov 2004 22:23:03 -0800, [EMAIL PROTECTED] (Victor) wrote:
>
> > From the following log.txt file, if I want to remove the other strings
> > but to keep the "[GC 84000K->74959K(88984K), 0.0250350 secs]" string:
> >
> > [Thu Nov 11 00:34:25 EST 2004] stderr:  ejbcontainer: >>>> EJB LOG
> > >>>>
> > [Fri Nov 12 01:15:19 EST 2004] stdout:  [GC 84000K->74959K(88984K),
> > 0.0250350 secs]
> >
> > What regexp pattern I should use? For example, if I specify a "!" in
> > front of the pattern (\[GC.*\]) which is correctly representing the
> > "[GC 84000K->74959K(88984K), 0.0250350 secs]" string:
> >
> > <replaceregexp file= "C:\log.txt" flags= "s" >
> >     <regexp pattern="!(\[GC.*\])" />
> >     <substitution expression="" />
> > </replaceregexp >
> >
> > It just won't work.
> >
> > Do you have any idea(obviously we can't use the '^' for this purpose)?
> > Or I have to create a new java program to do this?
>
> Unfortunately, regexes don't provide a way to not-match specific
> sequences of characters, but through creative use of lookaround and
> negated character classes, we can usually manage it.  Try this:
>
> <replaceregexp file= "C:\log.txt" flags= "g" >
>   <regexp pattern="(?:[^\[]++|\[(?!GC ))*+((?:\[GC [^\]]++\])|$)" />
>   <substitution expression="\1\n" />
> </replaceregexp >
>
> That is, match one or more of any character other than an open
> bracket, or an open bracket if it's not followed by "GC ", repeated
> zero or more times.  That part of the regex will match everything up
> to the next GC block (or to the end of the file if there aren't any
> more GC blocks), and the text matched by it will be discarded.  Upon
> finding an open bracket that's followed by "GC ", the next part will
> match and capture everything up to and including the next close
> bracket, and that text will be inserted into the output.
>
> With this regex, you don't need to use the "s" flag, but you may need
> to use the "g" flag--I'm not sure if Ant requires that when you're
> using the JDK regex engine (I assume that's what you're using; if not,
> this regex won't work at all).

I don't know if java has a 'c' option like perl does. For example:

/[a-z][A-Z]/c

matches every character except letters.






==========================================================================
TOPIC: Java client connected to non-Java server problems
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9dcb548fa77a4b46
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 12 2004 3:37 am
From: Keith Wansbrough <[EMAIL PROTECTED]> 

[EMAIL PROTECTED] (Illusionistx) writes:

> Thanks Esmond, but that made no sense, and no difference. I got it all
> worked out now thanks all.

So what was the problem, and solution?

--KW 8-)
-- 
Keith Wansbrough <[EMAIL PROTECTED]>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.




==========================================================================
TOPIC: jain-sip api
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/918018aa473fe074
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 12 2004 3:42 am
From: Thomas Schodt <[EMAIL PROTECTED]> 

maquill wrote:

> can you help me writing the simplest sip applications by this API?
> for example a simple application that sends a sip message

Google [ jain sip example ]



== 2 of 2 ==
Date:   Fri,   Nov 12 2004 3:45 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 12 Nov 2004 03:26:36 -0800, maquill wrote:

> can you help me writing the simplest sip applications by this API?

Start here..
<http://developers.sun.com/techtopics/mobility/apis/articles/sip/>

When you have a specific question*, get back to us.
* <http://www.physci.org/codes/javafaq.jsp#specific>

> please help me,

Please don't act pathetic.  That goes down like a 
lead balloon even on c.l.j.help.  

Read the FAQ carefully.
<http://www.physci.org/codes/javafaq.jsp> especially 
<http://www.physci.org/codes/javafaq.jsp#start> 
and the next two sections.

Also, since you are posting from Google, I will point out ..
Wait at least 24 hrs before reposting a question.
<http://groups.google.com/googlegroups/help.html#updated>

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==========================================================================
TOPIC: Property editor
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/900d4aeb52446c2e
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 12 2004 4:23 am
From: "Sylvain LECORNE" <[EMAIL PROTECTED]> 

  Hi all,

  I am doing a library with some beans (Bean A and B for example). B has a
"aProperty" that references an object of type A. I would like to do a
property editor thar pemits, doing an object of type B to get in the
aProperty a list of A existing objects. For example, y put in my form 2
objects a1 y a2 of type A. if I create a b1 object of type B y would like to
show a1 and a2 in the posibles values.
  I can do a static list using the getTags function of my property class,
but don't know how to access to a1 and a2 variables.
  Any idea ?

  Thanks a lot,

Sylvain. 






==========================================================================
TOPIC: How to paint in Component Graphics?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c10fbaedc6c93664
==========================================================================

== 1 of 6 ==
Date:   Fri,   Nov 12 2004 4:37 am
From: VideoProcessor <[EMAIL PROTECTED]> 

Does anyone have a solution for painting in components without overwriting 
the paint-Method?

I can access a component'g Graphics-Object by

Component abc;
...
Graphics g = abc.getGraphics();



Then I'm able to paint in it:

g.drawRect(10, 10, 20, 20);



... and paint it in the component:

abc.paint(g);



The problem to solve is that after updating the component, the rect is not 
visible, because it's not in the component graphics. Is there any way to do 
this without overwriting the component? Or a way to send a notice that the 
component graphic was updated so that I can repaint the rect immediately?



== 2 of 6 ==
Date:   Fri,   Nov 12 2004 4:43 am
From: "Andrei Kouznetsov" <[EMAIL PROTECTED]> 

> Does anyone have a solution for painting in components without overwriting
> the paint-Method?
>
> I can access a component'g Graphics-Object by
>
> Component abc;
> ...
> Graphics g = abc.getGraphics();
>
>
>
> Then I'm able to paint in it:
>
> g.drawRect(10, 10, 20, 20);
>
>
>
> ... and paint it in the component:
>
> abc.paint(g);
>
>
>
> The problem to solve is that after updating the component, the rect is not
> visible, because it's not in the component graphics. Is there any way to
do
> this without overwriting the component? Or a way to send a notice that the
> component graphic was updated so that I can repaint the rect immediately?

why you don't want to overwrite paint?

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities





== 3 of 6 ==
Date:   Fri,   Nov 12 2004 4:51 am
From: VideoProcessor <[EMAIL PROTECTED]> 

"Andrei Kouznetsov" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

>> Does anyone have a solution for painting in components without
>> overwriting the paint-Method?
>>
>> I can access a component'g Graphics-Object by
>>
>> Component abc;
>> ...
>> Graphics g = abc.getGraphics();
>>
>>
>>
>> Then I'm able to paint in it:
>>
>> g.drawRect(10, 10, 20, 20);
>>
>>
>>
>> ... and paint it in the component:
>>
>> abc.paint(g);
>>
>>
>>
>> The problem to solve is that after updating the component, the rect
>> is not visible, because it's not in the component graphics. Is there
>> any way to 
> do
>> this without overwriting the component? Or a way to send a notice
>> that the component graphic was updated so that I can repaint the rect
>> immediately? 
> 
> why you don't want to overwrite paint?
> 

Beacause I can't access the code ... ;-)
It's the visual component of a jmf video player and I have to mark some 
regions in it.
Maybe any other idea for doing this?



== 4 of 6 ==
Date:   Fri,   Nov 12 2004 5:07 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 12 Nov 2004 12:37:04 GMT, VideoProcessor wrote:

> Does anyone have a solution for painting in components ..

What Components?  Swing or AWT? (Or other?)
<http://www.physci.org/guifaq.jsp#2.4>

Note also, better group for GUI matters is..
<http://www.physci.org/codes/javafaq.jsp#cljg>

> ...without overwriting ..

Ir is 'overide/overiding', not 'overwrite/overwriting'.

> ..the paint-Method?

..possibly paintComponent, depends on the code you did not supply.
<http://www.physci.org/codes/sscce.jsp>

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 5 of 6 ==
Date:   Fri,   Nov 12 2004 5:11 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 12 Nov 2004 12:51:02 GMT, VideoProcessor wrote:

> It's the visual component of a jmf video player and I have to mark some 
> regions in it.

Get the graphics of the video player and render them to 
the Graphics of a BufferedImage, paint your rectangle on 
same, paint BufferedImage ( quickly ;-).

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 6 of 6 ==
Date:   Fri,   Nov 12 2004 5:42 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

VideoProcessor wrote:

> Beacause I can't access the code ... ;-)
> It's the visual component of a jmf video player and I have to mark some
> regions in it.

I've never tried this myself, so I may be completely wrong, but it sounds as if
a "glass pane" might be a potential solution.  There's a description in the
Swing tutorial at:

http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html#glasspane

    -- chris








==========================================================================
TOPIC: Swing - Detect how focus was moved?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/844c965c9aa3c8c1
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 12 2004 4:41 am
From: "Andrei Kouznetsov" <[EMAIL PROTECTED]> 

> Currently I'm looking at monitoring the sequence of FocusListener and
> MouseListener events to determine whether the user used the keyboard or
> mouse to move focus, but it seems unelegant and relies on eg.
mousePressed()
> running after requestFocus() and before focusGained().  Is there a better
> way to detect how the focus was moved?

may be you could check caret position, this works however only if user
clicks between first an last character.

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities





== 2 of 2 ==
Date:   Fri,   Nov 12 2004 5:52 am
From: "Ann" <[EMAIL PROTECTED]> 


"MikL" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> I have a Swing UI containing JTextFields.  When the user moves the focus
> into a JTextField using the keyboard (eg. by pressing TAB), I want to use
> selectAll() so that the user can then overwrite the field contents without
> messing with the mouse or having to type multiple backspaces or other
> keyboard gymnastics.  However, I _don't_ want to selectAll() if focus was
> moved to the field using the mouse.
>
> Currently I'm looking at monitoring the sequence of FocusListener and
> MouseListener events to determine whether the user used the keyboard or
> mouse to move focus, but it seems unelegant and relies on eg.
mousePressed()
> running after requestFocus() and before focusGained().  Is there a better
> way to detect how the focus was moved?
>
> Regards,
> MikL
>
Not sure, but can you set a flag in "mouse listener?"






==========================================================================
TOPIC: who uses algorithms learned in cs studies?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 12 2004 5:23 am
From: "Tim Ward" <[EMAIL PROTECTED]> 

"bebop o'saurus" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> 1) does anybody here use (in their everyday java coding gigs) any of the
> algorithms they were taught in their cs classes?

Er, everybody, I would hope??

> 2) what algorithms learned in your cs studies have you used recently?

Who knows, it's all just "stuff I do" these days, I'm no longer usually
concious of applying a particular piece of knowledge that I learnt at a
particular time.

There are exceptions. When, for example, I found myself having to calculate
the transitive closure of a sparse connectivity matrix ... in SQL, believe
it or not ... that definitely recalled a particular CS lecture and set of
diagrams on the blackboard.

> 3) if you haven't used any cs studies algorithms in your real-world jobs,
> why not?
>
> 4) if you do use any cs algorithms in your real-world jobs, how often do
you
> use them?

Every day, but like I said this stuff is mostly subconcious now so I don't
usually know I'm doing it.

--
Tim Ward
Brett Ward Limited - www.brettward.co.uk






==========================================================================
TOPIC: RegEx partial matching
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/14069fafc93c4493
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 12 2004 5:39 am
From: Stanimir Stamenkov <[EMAIL PROTECTED]> 

/Yamin/:

> There is a very simple solution to this. 
> Just keep appending data to your main buffer, and do a simple pattern 
> match.  If you don't want your buffer to be too big, simply chop off 
> any early data that you know cannot match the string.

How do I know which earlier data cannot match the regular 
expression? (see bellow)

> Suppose the string you're trying to match is 10 character long. 
> If you've read 20 characters already, and you have not found a full 
> match, you can safely discard the lower 10 characters.  Normally I 
> like to be safe and just keep 3x the length of the pattern I'm looking 
> for.

I want to match full featured regular expressions not just fixed 
strings (as I've included in my example for simplicity). I can't 
possibly determine the result length which would match some regular 
expression as in:

opentag [.\n]* closetag

What would be the length of "[.\n]*" ?

The only reasonable solution is to use rexeg library which supports 
streaming source as Adam (bilbo) has already proposed in another 
message in this thread.

-- 
Stanimir



=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to