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

Today's topics:

* JSplitPane. - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ea0ec20fad5f90
* Printing with GSprint Command - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/53b5c5833e01870c
* Obtaining derived classes - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/daa11ba437b8878b
* Improving website responsiveness. - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f719ebe188f50463
* java static factory method vs. constructor - object reuse - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c9c44eab569d8444
* Socket problem -- response slow for host with domain (on SunOS 5.8) - 1 messages, 1 
author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bfb84c34caf0c9e9
* paint program - 5 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a58412a811c7bb44
* Visual Modelling Tool - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c3aab05fc2bb074a
* compressed suffix trie - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8da323eedab790fd
* Hi , deprecated problem. - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29f429e26a464e8
* Literature on boolean naming/usage conventions? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dabf0085d6427c15
* Basic Struts logging - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fd2223a4c1cd5aa8
* How to get jsp and servlet interaction. - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/517cc3bfcef61520
* textValueChanged sometimes not called by TextField.setText - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e34c6fe4465a18aa
* A question about practical Java programming books - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d9f92694ab8e3228
* compiling java source - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9ed74ee3ba9401e9
* Problems with JProgressBar!!! - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5dbadddd537e2772
* blanking a java.util.Date in 1.5 - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b61c04b0e8db0fbf
* Is an extension of ".xslt2" a must for xslt stylesheets of spec 2.0 ? - 1 messages, 
1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/185fded1ba905165
* Why can't static methods be overridden? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f211d387a7676de
* OT: game programmer SALARY - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/87940bc0e58ea09
  
==========================================================================
TOPIC: JSplitPane.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ea0ec20fad5f90
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 9:25 am
From: "Kalpesh Modha" <[EMAIL PROTECTED]> 

Thinking about it now, it probably.  I'll give that a shot.
thanks.
"andreas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
>>>> Hello.
>>>>
>>>> I have a JSplitPane as below.  Now currently the right handside is a 
>>>> html area.  What I want to do is make the right hand side load a JFrame 
>>>> or a class.  So depending on which branch/left the user selected on the 
>>>> left the right class would be loaded on the right hand side.
>>>>
>>>> Can I do that, if so how ?
>>>>
>>>
>>> Your question ( at least one part of it) doesn't make too much sense. 
>>> How do you load a "class" into one pane of a JSplitPane ?? Do you mean a 
>>> JPanel or something like that ?
>>>
>>> As for loading JFrames, I'm afraid it is not possible. The AWT subsystem 
>>> does not allow any Component descending from java.awt.Window to be added 
>>> to any other Container. So Windows, Frames and Dialogs must always be 
>>> only top level containers.
>>>
>>> BK
>>
>>
>
> why do you need to load a JFrame anyway. just load the 
> jframe.getComponentPane()
> into your JSplitPane. would make more sense...
>
> andreas
> 






==========================================================================
TOPIC: Printing with GSprint Command
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/53b5c5833e01870c
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 9:36 am
From: Gordon Beaton <[EMAIL PROTECTED]> 

On 22 Sep 2004 02:16:56 -0700, Mao wrote:
> Is There a way to know if a OS process is running using some JAVA
> functions???? I need to know if gsprint process is running....

Did you read my response to your earlier, similar question about
gsprint? Did it not answer your question, and if not, why?

Please don't just start a new thread to ask the same question again.

(BTW the answer is no, but I provided a better solution to your real
problem in my other reply).

/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: Obtaining derived classes
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/daa11ba437b8878b
==========================================================================

== 1 of 3 ==
Date:   Wed,   Sep 22 2004 9:50 am
From: EjP <[EMAIL PROTECTED]> 

EjP wrote:
> 
> Is there a way to get a list of classes derived from a particular base
> class?
> 
> Something like
> 
>    Class c = Class.forName("BaseClass");
>    Class d[] = c.getDerivedClasses();  //I know this doesn't work
> 
> Any advice would be appreciated.
> 
>                 Thanks,
>                 E
> 
> 
> 
OK, I think I see the error of my ways.  How about advice on
the quickest way to load all the classes in a particular
directory?

Thanks,
E




== 2 of 3 ==
Date:   Wed,   Sep 22 2004 10:32 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Wed, 22 Sep 2004 11:50:52 -0500, EjP wrote:

> ..How about advice on
> the quickest way to load all the classes in a particular
> directory?

URL theDir = this.getClass().getResource("/");
File f = new File( url.getFile() );
f.listFiles( new ClassFilter() );
...

class ClassFilter extends FileFilter {

  boolean accept(File f) {
    return f.getName().toLowerCase().endsWith(".class");
  }
}

( quickly, of course.. ;-)

BTW, please keep your posts to c.l.j.help for the moment
EjP, it is not generally a good idea to x-post between
c.l.j.help and c.l.j.programmer.

** F'Ups set to c.l.j.help **

HTH

-- 
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:   Wed,   Sep 22 2004 11:09 am
From: "Ann" <[EMAIL PROTECTED]> 


"EjP" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Is there a way to get a list of classes derived from a particular base
> class?
>
> Something like
>
>     Class c = Class.forName("BaseClass");
>     Class d[] = c.getDerivedClasses();  //I know this doesn't work
>
> Any advice would be appreciated.
>
> Thanks,
> E

I might be wrong, but can't you use 'grep'?






==========================================================================
TOPIC: Improving website responsiveness.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f719ebe188f50463
==========================================================================

== 1 of 3 ==
Date:   Wed,   Sep 22 2004 10:02 am
From: Rico <[EMAIL PROTECTED]> 

On Wed, 22 Sep 2004 11:22:04 -0400, Bruce Lewis wrote:
> Rico <[EMAIL PROTECTED]> writes:
>> All right. The post proper is:
>> 
>> Would this:
>>      for x=1 to 3000
>>              select * from table where item = 'x'
>> 
>> be a lot slower than:
>>      write result of (select * from table) into Hashtable
>>      for x=1 to 3000
>>              hashtable.get(x)
>>              
>> The answer, after I took a break: Hell Yes!!
> 
> Are you really planning on doing something with each row in that order?

No. I only wanted to express the idea that there's a big loop going on
without going into redundant details.

> And while we're prematurely optimizing, note that if you know your keys

How can you tell that "we're prematurely optimizing" ?
I actually think that I am rewriting some parts of the code the way they
should have been written in the first place. That's not optimization.

Rico.





== 2 of 3 ==
Date:   Wed,   Sep 22 2004 11:51 am
From: "Will Hartung" <[EMAIL PROTECTED]> 

"ras_nas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thanks for the input Will.
> But "It is unreasonable to make a 1000 requests on the db only to get just
one
> string of path each time" is a far cry from "it's slow". A no-brainer
really.

Yes, but if in fact this isn't being done all the time but only once in a
blue moon, it becomes less of an issue, doesn't it?

> Further, when one function turns out to run 65 times slower than my new
> version, I am pretty sure that my guess was a pretty good one.

It was my understanding that you tried to fix "the problem" and "it was
still slow". That was my point. Rather than instrumenting your code and
finding where it was ACTUALLY slow based on your use cases, you found
something that "looked" slow, changed it, and it didn't appear to have the
effect you anticipated.

> It's just a matter then of locating all the _variants_ of such a function
> whose sin is duplicated all over the place: for every little piece of info
> I need, ask the db - Screw computer science classes and all those stuffs
about
> principle of locality and what not.

This is a tuning problem, not necessarily a design problem. This goes back
to early optimization. Why construct a framework to speed up getting
information, particularly early in development, when you don't necessarily
know which information is needed more often than others, or which
information is particularly difficult to get compared to others?

If your code is factored sufficiently, then all of those DB calls would have
been wrapped anyway (say, in a Data Access Object), then you'd simply change
the wrapper on the select few calls that your metrics show are the offenders
and cache them (or whatever), and not worry about the rest.

It's always better to have a functional system that you can test and tune
than a "fast" system that doesn't work. Through instrumentation, you can
find the critical paths through your system that really need optimization.

Our system has boatloads of "slow code", but we've tuned out and fixed the
most gross offenders and we meet our peformance numbers. When those demands
change, we'll do the tuning process again, meanwhile we can focus on new
functionality that the users really want. It's an incremental process.

For our instrumentation, we rely on the vast amounts of DEBUG level logging
we have in the system anyway, an awk script to digest the log, and a SQL
logging feature we implemented to point out particularly slow queries. We
tried the different analysis tools optimizers and what not, but they never
helped enough for us to justify the costs that they want for them. We run
the SQL log in production to point out whatever horrors the users throw at
our DB.

> I'll keep you Guys updated how things turn out after I've fixed that mess.

Good luck! Let us know!

Regards,

Will Hartung
([EMAIL PROTECTED])






== 3 of 3 ==
Date:   Wed,   Sep 22 2004 11:58 am
From: "Will Hartung" <[EMAIL PROTECTED]> 

"Rico" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> How can you tell that "we're prematurely optimizing" ?
> I actually think that I am rewriting some parts of the code the way they
> should have been written in the first place. That's not optimization.

I posted earlier, but...

If the code you're changing doesn't end up having a net effect on the site,
then it's premature optimization because if it has no net effect, then it's
not really "broken". It may be stylistically ugly, but if the goal is site
performance, it's better to spend time on that factor alone and clean up the
code for the sake of clean code at a later time. Cleaner code may well be
fast code, but if the slow code is functional and not on the critical path,
don't worry about it at this juncture.

Make it work, then make it fast.

Measure to find your real bottlenecks, then fix them one by one.
Inevitiably, you may well be led to your ugly code. But, then again, you may
not. Don't fix it until you know.

Regards,

Will Hartung
([EMAIL PROTECTED])







==========================================================================
TOPIC: java static factory method vs. constructor - object reuse
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c9c44eab569d8444
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 10:00 am
From: [EMAIL PROTECTED] (javaguy44) 

Yup...I misunderstood what Block wrote....which is why I posted in the
first place...it totally didn't make sense to me as I first read it.

Thanks for your replies.




Eric Sosman <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> javaguy44 wrote:
> > Hi Joona,
> > 
> > Have you read Effective Java?  I think you are just reconfirming my
> > question, because unless you misunderstood me, as far as I see, an
> > object of Foo is not being reused.  But unless I misinterpreted, Mr.
> > Bloch says that object's do cache when using static factory methods. 
> > I just don't know how.
> 
>      You may have misunderstood what Bloch wrote.  What he
> probably wrote (my copy is at home where I can't check it
> right now) is that factory methods *can* be used as part
> of an object-reuse scheme.  The code you showed does not
> provide for reuse, but here's one way it could be done:
> 
>       class Thing {
> 
>           /* Don't let outsiders use the constructor */
>           private Thing() { }
> 
>           /* "Reservoir" is some sort of a container in
>            * which created but currently unused objects
>            * live.
>            */
>           private static Reservoir stash = new Reservoir();
> 
>           /* Give the caller a Thing, either newly-minted
>            * or retrieved from the stash.
>            */
>           public static Thing thingFactory() {
>               Thing it = stash.removeNextThing();
>               if (it == null)  // stash was empty
>                   it = new Thing();
>               return it;
>           }
> 
>           /* When the caller no longer needs this Thing,
>            * releaseThing() puts it into the stash where
>            * it becomes available for reuse.
>            */
>           public static void releaseThing(Thing it) {
>               stash.insert(it);
>           }
>       }
> 
>      That's a very simple outline.  In practice, the factory
> method might initialize each recycled Thing to a known state
> (just as a constructor would), and might even take constructor-
> like parameters.  There might be provisions to keep the stash
> from getting obscenely large; there might even be provisions
> to let the Things in the stash be garbage-collected at need.
> The fundamental idea, though, is that an object that is no
> longer needed isn't just dropped on the floor for GC to sweep
> up, but is instead held in a "recycle bin" for future reuse.
> When another instance is needed, the factory method can provide
> one by dusting off an already-used object instead of creating
> a brand-new one.




==========================================================================
TOPIC: Socket problem -- response slow for host with domain (on SunOS 5.8)
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bfb84c34caf0c9e9
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 10:07 am
From: Nishi Bhonsle <[EMAIL PROTECTED]> 



Nigel Wade wrote:

> Nishi Bhonsle wrote:
>
> >
> > Hi:
> >
> > I have a servlet application deployed in OC4J. One of the page of the
> application takes the value for a smtpServer entered by the user from the
> client(value is a string), checks whether the value is valid  in the
> following backend code --
> >
> > try
> > {
> > //if you can open a socket on the smtp host at port 25, then it is a valid
> smtp host
> > Socket smtpSocket = new smtpSocket("smtpServerVal", 25);
> > ...
> > ...
> > }
> > catch(UnknownHostException uhe)
> > {
> > ..
> > ....
> > }
> > catch(IOException ioe)
> > {
> > ...
> > ...
> > }
> > where smtpServerVal is the value entered through the client UI(browser).
> >
> > I noticed that when I pass
> > Socket smtpSocket = new smtpSocket("yahoo", 25);
> > I get the UnknownHostException immediately(response is quick) and the page
> returns.
> >
> > But when I pass
> > Socket smtpSocket = new smtpSocket("yahoo.com", 25);
> > The response of IOException takes a rather long time.. i.e. the page takes
> almost after 30 secs or more to return.
> >
> > I observe this slower response only when the backend code is run on a
> solaris 8 machine, not on windows XP or 2000.
> > Is this a known issue? How can I resolve this if any?
> >
> > Thanks, Nishi.
>
> Most likely one of two issues is involved here.
>
> The first is DNS. Any time a failure takes "around 30s" I think DNS. This is
> the usual timeout for the resolver libraries if they get no response from a
> DNS server. Check whether DNS is working correctly on the Solaris machine.
>
> The second issue is firewalls. If there's a firewall in the way which drops
> rather than rejects packets destined for port 25 then you'll get a timeout
> delay. But I'd expect that to be considerably longer than 30s.
>
> Of course it could be a combination of the two, a firewall which is
> dropping/rejecting the DNS responses from the DNS server...
>
> Without knowing what the constructor for smtpServer(String,int) does I can't
> say more.

The constructor Socket smtpSocket = new smtpSocket("smtpServerVal", 25);
creates a stream socket ad connects it to the specified port number on the named host
here host = smtpServerVal (This is the Outgoing Mail Server hostname)
port=25.
(Got this information from java.net.Socket)

There is a firewall, but its the same for the windows machine too, so why would the 
firewall on the solaris box cause such a big delay?
How can I check whether the DNS is working correctly on the machine?

Is there a resolution?
Thanks, Nishi.

>
> --
> Nigel Wade, System Administrator, Space Plasma Physics Group,
>             University of Leicester, Leicester, LE1 7RH, UK
> E-mail :    [EMAIL PROTECTED]
> Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555





==========================================================================
TOPIC: paint program
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a58412a811c7bb44
==========================================================================

== 1 of 5 ==
Date:   Wed,   Sep 22 2004 10:25 am
From: C Williams <[EMAIL PROTECTED]> 

Paul Lutus wrote:

> C Williams wrote:
> 
> 
>>Hi,
>>
>>I am quite new to Java and thought that making a simple painting program
>>would be a good way to get familiar with how to deal with its graphical
>>features.  I'm using Swing and can see how to draw solid rectangles,
>>circles, lines, etc.  But what I would like to do is implement an
>>airbrush, which I would like to work as fast as possible.  Basically, I
>>would like to work with pixels directly:  take all of the ones within a
>>radius of a mouse click, blend them with a mask the represents the
>>brush, and then update just those pixels back on the canvas.
>>
>>I'm not sure what sort of component I can draw upon that lets me just
>>loop through its pixels.
> 
> 
> For this purpose, you cannot use a preexisting component, you need to so
> some programming.
> 
> One approach would be to create a short-period repeating timer that, when it
> timed out, would find the current mouse cursor position, discover whether
> the mouse button was down, then if these conditions were true, would:
> 
> 1. Generate a set of signed random numbers to represent Cartesian 
>    coordinates in x and y.
> 
> 2. Mathematically process the random numbers so they lie in a circle, rather 
>    than the square that would naturally be true.
> 
> 3. Draw points on the drawing surface at the position of the random x,y 
>    coordinates offset by the mouse position.
> 
> The reason for the timer is that, if you hold the mouse over a specific
> location on the drawing surface, you would want the number of painted dots
> to increase over time, just as would be true if you held a spray can over a
> spot on a wall in the real world.
> 

Thanks, Paul.  Yes, I was planning to incorporate a timer to model an 
actual spray can.  I guess my question is, what is the best way to go 
about actually manipulating a java application's display on a 
pixel-by-pixel basis?  i.e. how do i do this in *java*?

Specifically, how can I get the information for each pixel in a given 
region, come up with a new calculation for each pixel in that region, 
and then update it to my new calculation?

Thanks for anyone who can help!



== 2 of 5 ==
Date:   Wed,   Sep 22 2004 10:53 am
From: John Davison <[EMAIL PROTECTED]> 

C Williams wrote:
> Hi,
> 
> I am quite new to Java and thought that making a simple painting program 
> would be a good way to get familiar with how to deal with its graphical 
> features.  I'm using Swing and can see how to draw solid rectangles, 
> circles, lines, etc.  But what I would like to do is implement an 
> airbrush, which I would like to work as fast as possible.  Basically, I 
> would like to work with pixels directly:  take all of the ones within a 
> radius of a mouse click, blend them with a mask the represents the 
> brush, and then update just those pixels back on the canvas.
> 
> I'm not sure what sort of component I can draw upon that lets me just 
> loop through its pixels.  I've done something fairly similar to this a 
> few years ago (in C++), so I am okay with the concept but just 
> struggling with the implementation in Java.
> 
> Any help you have would be most appreciated!
> 
> Thanks,
> 
> -Casey

My guess is that you'll have to use an image.

I'm guessing that Java probably doesn't keep track of the color of each 
pixel of each component.  It probably just says "draw whatever" and then 
the underlying OS takes care of the pixels.  (Someone correct me if I am 
wrong here.)

But you *can* draw to an image, then draw the image onto a component.

To access the pixels of an image, you have to go through a Raster, which 
"encapsulates a DataBuffer that stores the sample values and a 
SampleModel that describes how to locate a given sample value in a 
DataBuffer."

Check out java.awt.image.Raster and the getPixel() functions.

Hope that helps.

- john



== 3 of 5 ==
Date:   Wed,   Sep 22 2004 11:00 am
From: Paul Lutus <[EMAIL PROTECTED]> 

John Davison wrote:

/ ...

> I'm guessing that Java probably doesn't keep track of the color of each
> pixel of each component.  It probably just says "draw whatever" and then
> the underlying OS takes care of the pixels.  (Someone correct me if I am
> wrong here.)

You're wrong here.
 
> But you *can* draw to an image, then draw the image onto a component.

And you can "draw" directly onto a component, using that component's paint()
method. This is the most efficient way to address the original problem.

-- 
Paul Lutus
http://www.arachnoid.com




== 4 of 5 ==
Date:   Wed,   Sep 22 2004 11:27 am
From: "Skip" <[EMAIL PROTECTED]> 

> I am quite new to Java and thought that making a simple painting program
> would be a good way to get familiar with how to deal with its graphical
> features.  I'm using Swing and can see how to draw solid rectangles,
> circles, lines, etc.  But what I would like to do is implement an
> airbrush, which I would like to work as fast as possible.  Basically, I
> would like to work with pixels directly:  take all of the ones within a
> radius of a mouse click, blend them with a mask the represents the
> brush, and then update just those pixels back on the canvas.

Take a look at:
java.awt.image.MemoryImageSource

use setAnimated(true) to make it dynamic.
it's all you ever wanted ;-)





== 5 of 5 ==
Date:   Wed,   Sep 22 2004 11:52 am
From: C Williams <[EMAIL PROTECTED]> 

Alex Hunsley wrote:

> Paul Lutus wrote:
> 
>> John Davison wrote:
>>
>> / ...
>>
>>
>>> I'm guessing that Java probably doesn't keep track of the color of each
>>> pixel of each component.  It probably just says "draw whatever" and then
>>> the underlying OS takes care of the pixels.  (Someone correct me if I am
>>> wrong here.)
>>
>>
>>
>> You're wrong here.
>>  
>>
>>> But you *can* draw to an image, then draw the image onto a component.
>>
>>
>>
>> And you can "draw" directly onto a component, using that component's 
>> paint()
>> method. This is the most efficient way to address the original problem.
> 
> 
> It's not efficient at all - as the user builds up pixels with their 
> paintbrush, would you redraw every pixel at each paint?
> Much more efficient/easier to draw to a buffer, then draw the buffer (or 
> part thereof) to the screen when needed.
> Swing *does* have double buffering built in, but it is per-paint time 
> and not a persistent image, which is what the OP needs from the sound of 
> it.
> 
> Also, it's a good idea to override paintComponent rather than paint - 
> paint calls paintComponent amongst other things (like paintChildren and 
> paintBorders).
> 
> alex
> 
> 

Thank you all for your input--I shall look into what you have said when 
I next get a chance to work on it (I can't now as I am at work!).

I DO need to know the current state because i want my brush to have more 
capability than just "add paint."  For instance, I might want to blend 
colors or blur or change to greyscale, etc.  Though, as some have 
pointed out, it's probably best to store this information in a buffer 
and write to the screen as necessary.

Thanks, and please continue to give advice!




==========================================================================
TOPIC: Visual Modelling Tool
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c3aab05fc2bb074a
==========================================================================

== 1 of 2 ==
Date:   Wed,   Sep 22 2004 11:07 am
From: "Rizwan" <[EMAIL PROTECTED]> 

I am looking for a modelling tool to use with my java project. Which
modelling tool is popular in the java community. What do you guys recommend?

Also what do you guys think about Rational Rose?

Thanks





== 2 of 2 ==
Date:   Wed,   Sep 22 2004 11:29 am
From: Alex Hunsley <[EMAIL PROTECTED]> 

Rizwan wrote:
> I am looking for a modelling tool to use with my java project. Which
> modelling tool is popular in the java community. What do you guys recommend?

Dunno. Tell us what you're modelling.

> Also what do you guys think about Rational Rose?

It has never hurt me or my family. Beyond that.... can't say.

> 
> Thanks
> 
> 




==========================================================================
TOPIC: compressed suffix trie
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8da323eedab790fd
==========================================================================

== 1 of 2 ==
Date:   Wed,   Sep 22 2004 11:29 am
From: Joseph <[EMAIL PROTECTED]> 

Hi all,

I want to build a compressed suffix trie from a string for string 
matching.instead of doing like:

input:a string with 10 chars
//incremental-insertion method
for loop(10 to 1){
insert char array index 10
insert char array index 9,10
insert char array index 8,9,10
...
insert char array 1,2,3,4,5,6,7,8,9,10
}
and then do the bottom-up compression


problem:
is there any efficient way to build a compressed suffix trie?
the above method is toooo slow and consum much memory!
is there any faster way to do the compression?
OR a dynamic way ?to do the insertion and compression at same time 



Thanks a lot guys



== 2 of 2 ==
Date:   Wed,   Sep 22 2004 12:23 pm
From: Daniel Sjöblom <[EMAIL PROTECTED]> 

Joseph wrote:
> Hi all,
> 
> I want to build a compressed suffix trie from a string for string 
> matching.instead of doing like:
<snip>
> problem:
> is there any efficient way to build a compressed suffix trie?
> the above method is toooo slow and consum much memory!
> is there any faster way to do the compression?
> OR a dynamic way ?to do the insertion and compression at same time 

 From your description I gather that you are using the brute-force
algorithm. For ideas, look here:

http://citeseer.ist.psu.edu/giegerich97from.html
http://citeseer.ist.psu.edu/grossi93suffix.html

For future reference, this newsgroup is supposed to address java
questions only. Next time, try comp.programming or comp.theory.

-- 
Daniel Sjöblom
Remove _NOSPAM to reply by mail





==========================================================================
TOPIC: Hi , deprecated problem.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e29f429e26a464e8
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 11:33 am
From: Alex Hunsley <[EMAIL PROTECTED]> 

Peter wrote:
> Hi
>    Here is my code:
> 
> import javax.swing.*;

[snip]
Peter, please don't post the same problem twice within an hour. I'm 
aware that maybe you thought it hadn't appeared - be aware that posts 
via google can take a while to appear.

alex




==========================================================================
TOPIC: Literature on boolean naming/usage conventions?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dabf0085d6427c15
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 11:39 am
From: "andreas" <[EMAIL PROTECTED]> 

>>> if ( on != true )
>>> if ( on == false )
>>> if ( on == !true ) ..or
>>> if ( !on == true )

i actually had to deal with someones code, which used:
if(notTrue == false)

what is it now. true? false? what is true or false?
i really didn't feel like twisting my mind everytime i see
something like this.
muchbetter for example:

if(buttonPressed)

THIS makes it readable...


andreas 






==========================================================================
TOPIC: Basic Struts logging
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fd2223a4c1cd5aa8
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:02 pm
From: "Will Hartung" <[EMAIL PROTECTED]> 

"fishfry" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Ok my next try was to include the lines
>
>     import org.apache.commons.logging.Log;
>     import org.apache.commons.logging.LogFactory;
>
> in my Action, per the Struts documentation. However these got compile
> errors. I verified that commons-logging.jar is in the lib directory, in
> the same place as struts.jar. So, why can the compiler find struts.jar
> ok, but not the logging stuff?

Logging can be a bit daunting.

Try tossing in a current Log4j.jar in with the commons-logging.jar.

I don't know, but commons-logging may well default to Log4j without
configuration.

You will need a log4j.properties file as well (probably in your
WEB-INF/classes directory) to get log4j going. There should be a sample with
log4j. Heck, there should be one with struts as well.

Regards,

Will Hartung
([EMAIL PROTECTED])







==========================================================================
TOPIC: How to get jsp and servlet interaction.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/517cc3bfcef61520
==========================================================================

== 1 of 2 ==
Date:   Wed,   Sep 22 2004 12:07 pm
From: Chris Riesbeck <[EMAIL PROTECTED]> 

In article <[EMAIL PROTECTED]>,
 Steve Burrus <[EMAIL PROTECTED]> wrote:

> I need some help/assistance from someone with this problem of mine of
> trying to get a jsp which displays a table with some table data in it,
> i.e., some of my favorite movies, to interact successfully with a
> servlet!!!

Several problems, but not, as far as I can see, with 
your use of the dispatcher. 

?? notes are about poor practice not bugs as such. 

!! are about bugs.

> 
>   Here is first my servlet code :
> 
>              import java.io.*;
>              import java.util.*;

?? Since you only use ArrayList and List, just import them explicitly.  
Maintainers to come will thank you.

>              import javax.servlet.*;
>              import javax.servlet.http.*;
> 
>   public class MovieServlet extends HttpServlet {
>        public void service (HttpServletRequest request, HttpServletResponse resp)
>                    throws IOException, ServletException {

!! Don't override service(). The default service() calls doPost() or doGet().
You should override them. And only one needs a real
definition. The other just calls the method with the real code.
See

http://www.phptr.com/articles/article.asp?p=29817&seqNum=3
http://www.stardeveloper.com/articles/display.html?article=2001061901&page=1


>               PrintWriter out = resp.getWriter();

!! Delete. If you're passing the buck to a JSP page, it
makes no sense to write anything to the response.

>               String [] movieList = { "Patton", "Some Like It Hot", "Bank
> Shot","Beyond Atlantis", "Titanic"};
>          java.util.List mymovie = new java.util.ArrayList();

?? You import ArrayList and List, so just write

  List mymovie = new ArrayList();

?? That should be spelled myMovie.

>          myMovie.add(movieList);

!! This puts *one* element in the ArrayList, namely the array.
What's the point of that?  Assuming you wanted the array elements
to become elements of the ArrayList, then import java.utils.Arrays
(note the plural) and do

   List mymovie = Arrays.asList(movieList);

One step, no explicit ArrayList needed.

>               request.setAttribute("movieList", mymovie);

OK, though you could condense this into just

  request.setAttribute("movieList", Arrays.asList(movieList));

>          String[] items = (String[]) request.getAttribute("movieList");
>            for(int i = 0; i < items.length; i++){
>                         String movie = items[i];
>                         out.println(movie);
>             }

!! Delete all of these lines. You shouldn't be writing to the response.

>               RequestDispatcher steve = request.getRequestDispatcher("mymovies.jsp");
>               steve.forward(request, resp);
>     }
> }

?? There's no need for the variable steve. Just write

  request.getRequestDispatcher("mymovies.jsp").forward(request, resp);


> and then my jsp code :
> 
> <%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core"; %>
> <html><head>
> </head><body>
> <b><i>My Personal Movie List</b></i><br><br><br>
> 
> <table>
>    <c:forEach var = "movie" items = "${movieList}"varStatus = 
> "movieLoopCount"> >

?? Standard HTML/XML style is no spaces around = and space
between a value and the next attribute. You also have a 
spurious > as noted by a previous poster. 

movieLoopCount is a misleading name since the variable holds 
a status object which is much more than just a count. So
this should be

   <c:forEach var="movie" items="${movieList}" varStatus="movieLoopStatus">

>      <tr>
>        <td>Count : ${movieLoopStatus.count}</td>
>      </tr>
>      <tr>
>         <td>${movie}</td>
>      </tr>
>      <tr><td>Patton</td></tr>
> 
>   </c:forEach>
>   </table>
>   </body></html>

I may be missing something else but this looks right.

HTH



== 2 of 2 ==
Date:   Wed,   Sep 22 2004 12:26 pm
From: "Will Hartung" <[EMAIL PROTECTED]> 


"Steve Burrus" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I need some help/assistance from someone with this problem of mine of
> trying to get a jsp which displays a table with some table data in it,
> i.e., some of my favorite movies, to interact successfully with a
> servlet!!! Now, in the servlet, I have used--probably for the very 1st
> time ever--the servlet method "RequestDispatcher" and both of the
> getAttribute() and the setAttribute() methods, but alas, when I try to
> view the jsp in my web browser, I only get the jsp title showing!!! Now
> whasssssssssup with that anyway???!!

*snip*

The basic problem is that you're storing a String array in your list. Rather
you should just store the movies in the list.

public class MovieServlet extends HttpServlet {
 public void service (HttpServletRequest request, HttpServletResponse resp)
  throws IOException, ServletException
 {
  PrintWriter out = resp.getWriter();
  String [] movieList = { "Patton", "Some Like It Hot",
        "Bank Shot","Beyond Atlantis", "Titanic"};
  java.util.List mymovie = java.util.Arrays.asList(movieList);
  request.setAttribute("movieList", mymovie);
  RequestDispatcher steve = request.getRequestDispatcher("mymovies.jsp");
  steve.forward(request, resp);
    }
}

Then, in your JSP:
<table>
   <c:forEach var = "movie" items = "${movieList}">
     <tr>
        <td><c:out value="${movie}"/></td>
     </tr>
  </c:forEach>
  </table>

That should work for you.

Regards,

Will Hartung
([EMAIL PROTECTED])








==========================================================================
TOPIC: textValueChanged sometimes not called by TextField.setText
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e34c6fe4465a18aa
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:09 pm
From: "Mickey Segal" <[EMAIL PROTECTED]> 

I have reproduced this problem in a small applet, with a working version and 
full source code at:
http://www.segal.org/java/text_events/

"Mickey Segal" <[EMAIL PROTECTED]> wrote in message news:...
>I thought that textValueChanged was always called when setText of a 
>TextField with a TextListener is used.  However, in a huge applet I find 
>that textValueChanged is not called the first time TextField.setText is 
>called.  However, subsequent calls to TextField.setText do fire 
>textValueChanged events.
>
> This behavior is seen in the Microsoft JVM 3810, Sun 1.5 RC and Macintosh 
> Java 1.3, but textValueChanged is called as expected in Macintosh Java 
> 1.4.
>
> So far I have been unable to reproduce this problem in a small applet - 
> textValueChanged is always called as expected.  In both the huge applet 
> and the test applet visible=true enabled=true valid=false.
>
> Any advice on how to get textValueChanged called as expected?  This is 
> causing problems because first and subsequent calls to TextField.setText 
> are having different effects because textValueChanged is not called the 
> first time. 






==========================================================================
TOPIC: A question about practical Java programming books
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d9f92694ab8e3228
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:16 pm
From: "Will Hartung" <[EMAIL PROTECTED]> 


"TechBookReport" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I think you're right, very often it's the mechanics that get in the way
> rather than the syntax. Some of the better intro books do cover this,
> but never in huge depth. You might want to take a look at Bruce Eckel's
> Thinking In Java (available for free online). The following page from
> Sun might also be useful for any immediate problems:
>
> http://java.sun.com/docs/books/tutorial/java/interpack/managingfiles.html

That looks like a pretty good little page.

When is comes to fixing Java problems, I rely on a simple, 2 page book
titled "How to fix Java Problems"

On page one it says: "It's a CLASSPATH problem."

On page two it says: "See page 1."

The CLASSPATH is THE hurdle you must understand to get anything to work in
Java, and it can be VERY frustrating. Save for syntax issues and basic logic
issues, CLASSPATH issues take up most of the rest of the problems. So, do
spend extra time on the CLASSPATH concept. You WILL be rewarded for your
time.

The other thing you want to set up and get used to, IMHO, is Ant.

Of all things, the Tomcat documentation has a sample Webapp application that
comes with a project hierarchy and configured build.xml for Ant. This is a
small enough project that explains the common, most used bits of Ant for
development and makes a really good use case to study. It doesn't overwhelm
you with options. With the info in that build.xml, you can do lots of things
that builds need to do.

Finally, try and not learn the entire platform at once. Java is ENORMOUS.
Pick a segment and focus on that for awhile. If you don't have a project in
mind, try working with webapps first, then GUIs, then EJBs. Webapps are
quick bang for buck in terms of doing Interesting Things and seeing results
quickly, as well as getting you neck deep into the intricacies of the
platform.

Regards,

Will Hartung
([EMAIL PROTECTED])







==========================================================================
TOPIC: compiling java source
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9ed74ee3ba9401e9
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:28 pm
From: "Will Hartung" <[EMAIL PROTECTED]> 


"Andrew Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Wed, 22 Sep 2004 17:57:57 +0300, Daniel Sjöblom wrote:
> > Andrew Thompson wrote:
> >> On Wed, 22 Sep 2004 09:32:47 +0600, perkal wrote:
> >>>I need to compile a simple java source file from within a java program.
> >>
> >> String args[] = new String[] { options, directory, fileName };
> >> com.sun.tools.javac.Main.compile(args);
> ..
> > But this won't run on a machine with only the runtime installed, ..
>
> As Tor pointed out, it requires tools.jar.
>
> > ..or on any VM not made by Sun, no?
>
> Well puhh.. now you're getting exotic!

Also one of the reasons Tomcat 5.5 is bundling IBM's compiler for their
JSPs.

Regards,

Will Hartung
([EMAIL PROTECTED])







==========================================================================
TOPIC: Problems with JProgressBar!!!
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5dbadddd537e2772
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:40 pm
From: "***C.Steamer***" <[EMAIL PROTECTED]> 

Yeah that fixed it, I totally forgot about switching to the event thread 
first. Funny thing was In other parts of the same class I had code that did 
that very thing, just slipped my mind. Thanks Alot
"Babu Kalakrishnan" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> C.Steamer wrote:
>>
>>     This is where I use the progress bar
>>
>>
>>
>>     panel.getProgressBar().setIndeterminate(true);
>>
>>     int totalFiles = countNonHiddenFiles(file);
>>
>>     panel.getProgressBar().setIndeterminate(false);
>>
>>
>>     panel.getProgressBar().setMinimum(0);
>>
>>     panel.getProgressBar().setValue(0);
>>
>>     panel.getProgressBar().setMaximum(totalFiles);
>>
>>
>
> Are the above calls (the ones on the progressbar) made in the Event 
> Dispatch Thread ? If not, try moving them to the EDT using a 
> SwingUtilities.invokeLater wrapper.
>
> BK 






==========================================================================
TOPIC: blanking a java.util.Date in 1.5
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b61c04b0e8db0fbf
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:43 pm
From: "P.Hill" <[EMAIL PROTECTED]> 

Chris Murphy wrote:

> Thanks for that Paul, but my problem is not with toString(), but with
> the date itself (which is actually stored as a number of milliseconds
> since some fixed date). 

Yes, I said that.  Now you have to show us where the millisecond values
are different.

> Changes to the output of toString() between
> 1.4 and 1.5 correctly reflect the fact that something has changed.

What has changed and what makes you think it is 'correct'?  You have never 
established what has changed by showing us ALL formated fields on your
machine using a complete SimpleDateFormat.  You show a 
java.util.Date.toString().  We can't even tell if it is AM or PM,
or the same actual time or not.

Let's look at the millisecond values and see what they look like.
That is a simple change to your code. (Sorry, I'm busy today and
don't have a 1.5 installed).  Please extend your sample application
to show all formated fields and the binary value.  Then we'll have
something to chew on.

> A program that I have written stores dates in a database, and these
> dates were stored using 1.4. This same program will give completely
> different date calculation results whether run in 1.4 or 1.5. 

By the way the conversion from the DB is the contract of the JDBC driver
not the contract of Calendar or Date.  As John pointed out there may be
some change there also.  For example, how does your DB store dates?  With
no TZ information or without.

 > This has
> nothing to do with how the dates are formatted for toString().

That is how you are claiming things are different.  I just want to
see the rest of the date to see the whole story of how they are different.

> I can
> potentially see programs out there that work with dates previously
> stored in 1.4 having similar troubles.

First, we have to identify where the difference is.

-Paul





==========================================================================
TOPIC: Is an extension of ".xslt2" a must for xslt stylesheets of spec 2.0 ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/185fded1ba905165
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:45 pm
From: [EMAIL PROTECTED] (Ken Philips) 

If I want to use featurwes of Xslt Spec 2.0: Do I have to use an extension
of .xslt2 or can use .xslt as well?

Ken







==========================================================================
TOPIC: Why can't static methods be overridden?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f211d387a7676de
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:51 pm
From: [EMAIL PROTECTED] (Yakov) 

> 
> When I did my Java data structures programming laboratory, the
> instructor had a simple rule: "as few 'static's as possible". I wrote a
> Java program with only one 'static': The main() method in the central
> application class. I got full marks for that laboratory.

Congratulation on your full marks, but your teacher is not that great.
A statement "as few instance's as possible" would be equally wrong.

Regards,
Yakov




==========================================================================
TOPIC: OT: game programmer SALARY
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/87940bc0e58ea09
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 22 2004 12:59 pm
From: [EMAIL PROTECTED] (Bo) 

Hi

I will discuss job offer with a game company soon. Please post how
much I should bargain for.

-job title: port engineer (j2me, Brew phone games)
-at San Francisco

Me:
-fresh out of college
-I think they hired me because I made an impressive 3D engine in Java.
But because '3d engine programmer' pays more than people who ports,
they will still offer the job to me as a port engineer.
-If there is info on '3d engine programmer' for phones please provide
it.

thnx!



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

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