comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]Today's topics: * blanking a java.util.Date in 1.5 - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b61c04b0e8db0fbf * Memory leakage problem with a database application - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd24fb0a93e5b285 * Noobie looking for relevant Java knowledge - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/289f1f05fa606891 * How to incremet IndetAddress / IP numbers - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/94897e32234ceaaf * newbie RMI User - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af49b3bdfce876e4 * HTML Applet Code - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4c474db6bb89b26e * Java trick - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bfd25be52dc6a3ad * what u program? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee20f99e67fd5410 * simpleDateFormat and April month - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/383df9c88dcb10ba * writing and reading objects - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/42024eb362a85850 * Job Openings in Phoenix - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c09d556eba846dd8 * Can I implement INSERTs and DELETEs in DAOs or only in EntityBeans? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/44068d680f903d5e * update doesnt´t work ? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3619d270a4e29711 * Fixed & Updated Groupable Table Header - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b798b3fe6e56ad6 * Problem with IE and Applets. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/85712e86df721a37 * Detecting Space-down on a mouse click - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d758d3be8abe43b ========================================================================== 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 2 == Date: Sat, Sep 18 2004 1:34 am From: [EMAIL PROTECTED] (Chris Murphy) I have some code that compares java.util.Date[s]. The dates in question have some of their fields blanked out so that the time portion will be irrelevant to the comparison. I am not sure of the technique being used to 'blank out' various fields in a java.util.Date, but I do know that the technique gives different results in the 1.4 and 1.5 JVMs. The last line of output in the following code under 1.4 is Got day: [Sat Sep 25 00:00:00 EST 2004] Under 1.5 it is Got day: [Sat Sep 25 12:00:00 EST 2004] Is there any way I can get them to be the same under 1.4 and 1.5? Preferably both having the time component of [00:00:00]? ==============================BEGIN CODE public static void main( String[] args) { int dateInt = 25; int monthInt = 8; int yearInt = 2004; GregorianCalendar day = new GregorianCalendar(); clearCalendar( day); Err.pr( "date using: " + dateInt); day.set( Calendar.DATE, dateInt); Err.pr( "month using: " + monthInt); day.set( Calendar.MONTH, monthInt); Err.pr( "year using: " + yearInt); day.set( Calendar.YEAR, yearInt); //With 1.5 get [Sat Sep 25 12:00:00 EST 2004] //With 1.4 got [Sat Sep 25 00:00:00 EST 2004] Err.pr( "Got day: [" + day.getTime() + "]"); } /** * Clears everything from the calendar arg. The intention being * that this method can be called before the invoking code goes * on to set only the fields that it wants to set. */ public static void clearCalendar( Calendar calendar) { calendar.clear( Calendar.DAY_OF_WEEK_IN_MONTH); calendar.clear( Calendar.DATE); calendar.clear( Calendar.DAY_OF_MONTH); calendar.clear( Calendar.HOUR); calendar.clear( Calendar.HOUR_OF_DAY); calendar.clear( Calendar.MINUTE); calendar.clear( Calendar.SECOND); calendar.clear( Calendar.MILLISECOND); //attempting fix of 12:00 being introduced, but no help calendar.clear( Calendar.PM); } ==============================END CODE Thanks for any help with this. - Chris Murphy == 2 of 2 == Date: Sat, Sep 18 2004 7:44 am From: "P.Hill" <[EMAIL PROTECTED]> Chris Murphy wrote: > I have some code that compares java.util.Date[s]. The dates in > question have some of their fields blanked out so that the time > portion will be irrelevant to the comparison. First of all java.util.Date does not have fields. When you ask for a toString() from a java.util.Date you actually get a SimpleDateFormat (SDF) created which does all the right default things to use a Calendar with a Timezone to make all the fields to make a String. The fields are in the Calendar object. Given all that, may I suggest that you please use your own SDF to define what you want for a String. toString() does not have a contract that says that have to keep giving the same representation across various releases. They don't even have to give the same value across different invocations of the same VM. > The last line of output in the following code under 1.4 is > Got day: [Sat Sep 25 00:00:00 EST 2004] > > Under 1.5 it is > Got day: [Sat Sep 25 12:00:00 EST 2004] > > Is there any way I can get them to be the same under 1.4 and 1.5? > Preferably both having the time component of [00:00:00]? > > ==============================BEGIN CODE > > public static void main( String[] args) > { > int dateInt = 25; > int monthInt = 8; > int yearInt = 2004; > GregorianCalendar day = new GregorianCalendar(); > clearCalendar( day); > Err.pr( "date using: " + dateInt); > day.set( Calendar.DATE, dateInt); > Err.pr( "month using: " + monthInt); > day.set( Calendar.MONTH, monthInt); > Err.pr( "year using: " + yearInt); > day.set( Calendar.YEAR, yearInt); > > //With 1.5 get [Sat Sep 25 12:00:00 EST 2004] > //With 1.4 got [Sat Sep 25 00:00:00 EST 2004] > Err.pr( "Got day: [" + day.getTime() + "]"); Try String FORMAT_8601 = "yyyy-MM-dd 'T' HH:mm:ss.S zzz"; SimpleDateFormat localTime = new SimpleDateFormat( FORMAT_8601 ); Err.pr( "Got day: [" + localTime.format( day ) + "]")); And you will learn more about what it is going on. I have displayed the HOUR of the DAY and not the AM/PM hour. It may be that the traditional Unix-like format used for the Date.toString() uses HOUR (AM/PM hour) and that in 1.5 someone decided 12 (midnight or noon) is the right way to display AM/PM hours and not 00:00 for midnight. -Paul ========================================================================== TOPIC: Memory leakage problem with a database application http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cd24fb0a93e5b285 ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 1:54 am From: Babu Kalakrishnan <[EMAIL PROTECTED]> Devian wrote: > Babu Kalakrishnan <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... >> >>> While the opened frame is closing Frames[iFrmIdx] is set to null.And >>>all of the components of the frame is set to null.But the memory >>>leakage problem goes on.Finally gc() is closed after the frame closed >>>but this dos not solve the problem. >>> >> >>Are you sure you're calling dispose() on the frame before setting it to >>null ? > > > I'm calling dispose() in WindowClosing function of the frame then I > set Frames[iFrmIdx] to null.Frames[iFrmIdx] is in the main frame and > defined static to reach from the opened frame. > Then it is almost certainly due to some strong reference maintained by another live object. The reference need not be of the Frame itself, but could even be to one of the components contained in the frame (because then the Frame can be reached by tracing recursively through the "parent" member of the component) or even an anonymous class declared within your Frame (which will hold a reference to the containing instance). Using a memory profiler should aid in debugging this. BK ========================================================================== TOPIC: Noobie looking for relevant Java knowledge http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/289f1f05fa606891 ========================================================================== == 1 of 2 == Date: Sat, Sep 18 2004 2:15 am From: Pingo <[EMAIL PROTECTED]> Hi y'all I'm just beginning my journey into the world of Java programming. The amount of help and information on the net is vast and trying to discern what is relevant and necessary can be confusing to say the least. If anyone can recommend (tried and trusted) texts, websites, etc that they have used I would be most grateful. Thanks for any help. == 2 of 2 == Date: Sat, Sep 18 2004 3:21 am From: "hilz" <[EMAIL PROTECTED]> http://java.sun.com/docs/books/tutorial/index.html "Pingo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi y'all > I'm just beginning my journey into the world of Java programming. The > amount of help and information on the net is vast and trying to > discern what is relevant and necessary can be confusing to say the > least. > If anyone can recommend (tried and trusted) texts, websites, etc that > they have used I would be most grateful. > Thanks for any help. ========================================================================== TOPIC: How to incremet IndetAddress / IP numbers http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/94897e32234ceaaf ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 2:12 am From: "John B. Matthews" <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, Paul Lutus <[EMAIL PROTECTED]> wrote: > John B. Matthews wrote: > > > In article <[EMAIL PROTECTED]>, > > Paul Lutus <[EMAIL PROTECTED]> wrote: > > > >> Markus Kern wrote: > >> > >> > Hey, > >> > > >> > i am coding a simple port scanner. > >> > now i want to make it scan a whole range of ip numbers. how can i > >> > increment the datatype InetAddress? > >> > >> Your inquiry has been asked and answered, in a thread you started in > >> comp.lang.java.help on 9/14/2004. > > [...] > > > > I had missed this thread on c.l.j.h. Before seeing your very > > illuminating code, I had tried the following: > > [my erroneous code deleted] > > > > It seems to work, but I'm vaguely uneasy about relying on > > wrap-around with signed integer arithmetic. > > There is no need to use this approach. Just increment an integer or a long, > dismantle a copy into byte components, and use the bytes to construct the > IP address, as in my prior code example. Yes, I see. You proposed something like this: public static InetAddress toInetAddress(int addr) throws UnknownHostException { byte[] b = new byte[4]; b[3] = (byte) addr; addr >>= 8; b[2] = (byte) addr; addr >>= 8; b[1] = (byte) addr; addr >>= 8; b[0] = (byte) addr; return InetAddress.getByAddress(b); } The inverse would just combine the bytes: public static int toInt(InetAddress ip) throws UnknownHostException { byte[] b = ip.getAddress(); int addr = 0; for (int i = 0; i < 4; i++) { addr |= (((int) b[i]) & 0xff) << (8 * (3 - i)); } return addr; } For reference, my original code was erroneous. The correction is as follows: public static InetAddress inc(InetAddress ip) throws UnknownHostException { byte[] b = ip.getAddress(); b[3]++; if (b[3] == 0) { b[2]++; if (b[2] == 0) { b[1]++; if (b[1] == 0) { b[0]++; } } } return InetAddress.getByAddress(b); } Sorry, I just can't resist bit-twidling in every language I learn:-) John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/ ========================================================================== TOPIC: newbie RMI User http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af49b3bdfce876e4 ========================================================================== == 1 of 3 == Date: Sat, Sep 18 2004 2:33 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 18 Sep 2004 07:39:03 +0000 (UTC), Paul Foreman wrote: > I have just got an applet I am developing to use the RMI method to get > information from a server. > > I was using JBuilder and using try and catch statements for each of the > methods that needed the remote information. So there were several methods > which invoked the RMI method Naming.lookup. All seemed well until I tried to > use the applet in a browser. When I did this I got a 'notinited' message and > the applet failed to load. <http://www.physci.org/codes/javafaq.jsp#appletie> -- 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 == 2 of 3 == Date: Sat, Sep 18 2004 5:48 am From: "paul.foreman" <[EMAIL PROTECTED]> Andrew, Thanks for the pointer to IE settings and selecting Java (sun). I checked my current IE setting which already had Java(sun) selected for applets. I did not make it clear that when my applet only had one use of the RMI Naming.lookup method the applet did run within my browser. It was only when I re-introduced more than one method in the same applet, that called on the same remote server that I had a problem. Basically the applet had three buttons which when pressed called the remote server. Each button invoked a different remote method on the same server. Is there any way of getting more information from my PC on why the applet is failing? Regards Paul "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sat, 18 Sep 2004 07:39:03 +0000 (UTC), Paul Foreman wrote: > >> I have just got an applet I am developing to use the RMI method to get >> information from a server. >> >> I was using JBuilder and using try and catch statements for each of the >> methods that needed the remote information. So there were several methods >> which invoked the RMI method Naming.lookup. All seemed well until I tried >> to >> use the applet in a browser. When I did this I got a 'notinited' message >> and >> the applet failed to load. > > <http://www.physci.org/codes/javafaq.jsp#appletie> > > -- > 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: Sat, Sep 18 2004 6:18 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 18 Sep 2004 12:48:56 +0000 (UTC), paul.foreman wrote: > Andrew, Hi Paul, could you put your replies directly after the relevant line and trim unnecessary text, such as signatures? <http://www.physci.org/codes/javafaq.jsp#netiquette> See further comments in that style (in-line with trimming) > "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Sat, 18 Sep 2004 07:39:03 +0000 (UTC), Paul Foreman wrote: >> >>> I have just got an applet I am developing to use the RMI method to get >>> information from a server. Can we see you applet? What is the URL? If it is on a restricted intranet, can you haul a failing example of it out onto a public URL? [ I should have asked that first, but forgot because I was so sure I was right, ..dope me. ] >>> I was using JBuilder and using try and catch statements What *exactly* are you doing in these catch statements? Do you print the stack trace? And for that matter, what is an (SHORT) example code that displays the problem? <http://www.physci.org/codes/sscce.jsp> >>> ..for each of the >>> methods that needed the remote information. So there were several methods >>> which invoked the RMI method Naming.lookup. All seemed well until I tried >>> to >>> use the applet in a browser. When I did this I got a 'notinited' message <http://www.physci.org/codes/javafaq.jsp#exact> I do not mean the message you get in the status bar at the bottom of the browser, the message in the Java console. >>> and >>> the applet failed to load. >> >> <http://www.physci.org/codes/javafaq.jsp#appletie> > Thanks for the pointer to IE settings and selecting Java (sun). > I checked my current IE setting which already had Java(sun) selected for > applets. That is confusing to me.. OK, it seems our not inited message is not the typical > I did not make it clear that when my applet only had one use of the RMI > Naming.lookup method the applet did run within my browser. It was only when > I re-introduced more than one method in the same applet, that called on the > same remote server that I had a problem. Basically the applet had three > buttons which when pressed called the remote server. Each button invoked a > different remote method on the same server. I have not dabbled in RMI. Hopefully an RMI guru (or at least somebody more exp. than myself) will jump right in. > Is there any way of getting more information from my PC on why the applet is > failing? Well.. You know about the Java console? Tools | Sun Java Console ..if you are printing stack traces, it should give you the exact line number the problem occurs. Now.. did you notice how I cleverly answered your questions by bombarding you with many more? Almost makes me seem like I have a clue what is going on here. ;-) -- 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: HTML Applet Code http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4c474db6bb89b26e ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 2:35 am From: Andrew Thompson <[EMAIL PROTECTED]> On 17 Sep 2004 21:48:13 -0700, RNS wrote: > If > someone could provide some more robust code that would be great. Use a standard applet tag and the JavaVersionApplet.. <http://www.physci.org/codes/jre.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 ========================================================================== TOPIC: Java trick http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bfd25be52dc6a3ad ========================================================================== == 1 of 3 == Date: Sat, Sep 18 2004 2:38 am From: Lee Fesperman <[EMAIL PROTECTED]> Thomas G. Marshall wrote: > > Michael Borgwardt coughed up: > > Thomas G. Marshall wrote: > >> The reason it works is that a variable to a class object of any > >> value can still yield access to a static. > > > > Actually, there is no object involved at any point. The *compiler* > > [snip] > > You're right. What I really should have said was a "variable of reference > of any value", not object. > > Basically, given the declaration & definition: > > {Type} {Variable Name} = {reference}; > > *Regardless* of the value of {reference}, > > {reference}.{static id} > > yields the same thing as > > {Type}.{static id} It's simply a reference, you don't need a variable at all. It is any expression producing a reference. It could be a method returning a reference or even: ((Type) null).{static id} The static can be a field or a method. -- Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com) ============================================================== * The Ultimate DBMS is here! * FirstSQL/J Object/Relational DBMS (http://www.firstsql.com) == 2 of 3 == Date: Sat, Sep 18 2004 6:47 am From: Babu Kalakrishnan <[EMAIL PROTECTED]> Tor Iver Wilhelmsen wrote: > "Adam" <[EMAIL PROTECTED]> writes: > > >>This will compile and run correctly, >>even though foo() is not static. > > > IIRC, it's because the member method foo() is "synthesized" into the C > method > > CSomeClass_foo(CsomeClass* this) { > > } > > and your code doesn't use "this" for anything. > > Methods in Java are "real" member methods. > > To the OP: Whether you get the static member's value or a > NullPointerException depends on which runtime you use: There was a > change-note for one version (I seem to recall) that spoke of a change > regarding whether your code should give a NPE at runtime or not. I'm curious about this too. I thought the compiler was the one which would automatically convert the instance based reference to a class reference. In which case how would the runtime know about the instance at all ? (to check for null) BK == 3 of 3 == Date: Sat, Sep 18 2004 7:28 am From: "Thomas G. Marshall" <[EMAIL PROTECTED]> Michael Borgwardt coughed up: > Thomas G. Marshall wrote: >> Basically, given the declaration & definition: >> >> {Type} {Variable Name} = {reference}; >> >> *Regardless* of the value of {reference}, >> >> {reference}.{static id} >> >> yields the same thing as >> >> {Type}.{static id} >> >> Which is something I've always thought sloppy about Java. > > I (and most knowledgeable people I know) think that static members > should be accessible only through the class name, not through > a reference. Yeah. Some compilers (like eclipse's) allow a setting to change the compiler's reaction to that from silent, to warning, to error. At least that's a start. -- "It's easier to be terrified by an enemy you admire." -Thufir Hawat, Mentat and Master of Assassins to House Atreides ========================================================================== TOPIC: what u program? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ee20f99e67fd5410 ========================================================================== == 1 of 2 == Date: Sat, Sep 18 2004 3:47 am From: [EMAIL PROTECTED] (Tabrez Iqbal) jaYPee <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > I just wanted to know what most program u do in java? coz i'm a vb > programmer and i do a lot of database programming. > > thanks in advance mostly web-based applications(JSP etc based) tabrez == 2 of 2 == Date: Sat, Sep 18 2004 4:41 am From: Joona I Palaste <[EMAIL PROTECTED]> jaYPee <[EMAIL PROTECTED]> scribbled the following: > I just wanted to know what most program [you] do in [Java]? [Because] > [I'm] a [VB] > programmer and [I] do a lot of database programming. > [Thanks] in advance I'm currently pretty much completely engaged in a large customer project. Our customer is the Finnish state bureau for gambling - Veikkaus OY. They want to upgrade their internal game winnings monitoring system and we're implementing a new one for them. Java-wise, this means a Servlet that basically acts as a gateway to a humongous request-response -style database access program with different customised information retrieval and update components. It's more fun than it sounds, really. -- /-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\ \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/ "It was, er, quite bookish." - Horace Boothroyd ========================================================================== TOPIC: simpleDateFormat and April month http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/383df9c88dcb10ba ========================================================================== == 1 of 3 == Date: Sat, Sep 18 2004 3:51 am From: [EMAIL PROTECTED] (Nurettin Arslankaya) My java version is below: java version "1.4.1_03" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02) Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode) The example that I wrote is only an example, not my complete code. My complete code is huge, diffucult to understand and not focusing the problem. I am at GMT+2 timezone ANKARA/TURKEY. And now its daylight+1 time in Turkey. I think there is a logical error. Because I create an calendar object with Y M D H M S, when I rerequest these values it gives different values. It allowes data without any Timezone information and responses with timezone data. Whatever, I solved my problem by creating SimpleTimeZone object without Daylight saving at GMT+0. Then set it default and set TimeZone property of the SimpleDateFormat object. This runs without error. Now I am testing my code against to errors. thanks for helping Sudsy <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Nurettin Arslankaya wrote: > > Hi, > > here is the all code and execution result : > <snip> > > /* Execution result */ > > /* -------------------------------------------- */ > > /* > > > > Testing Dateformatter > > ---------------------- > > 1980-04-01 01:00:00 > > 1975-04-12 01:00:00 > > > > */ > > My results: > > Testing Dateformatter > ---------------------- > 1980-04-01 00:00:00 > 1975-04-12 00:00:00 > > So it would certainly seem to be something to do with your environment. > I note the package directive at the top of your code. Is it possible > that you've got a "stale" version sitting somewhere in your CLASSPATH? > BTW I'm running Java 1.4.2_02 under Linux. == 2 of 3 == Date: Sat, Sep 18 2004 7:23 am From: "P.Hill" <[EMAIL PROTECTED]> Nurettin Arslankaya wrote: > The example that I wrote is only an example, not my complete code. My > complete code is huge, diffucult to understand and not focusing the > problem. So does the code you posted result in the wrong values on your machine? > I am at GMT+2 timezone ANKARA/TURKEY. And now its daylight+1 time in > Turkey. > I think there is a logical error. Because I create an calendar object > with Y M D H M S, when I rerequest these values it gives different > values. It allowes data without any Timezone information and responses > with timezone data. Can you show THIS as code since that is NOT what you are doing in the previous code you posted. For example, if you set the time right now during DLS then switch to date which is non-DLS there are certain scenerios which will correctly make the hour value move by one hour. > Whatever, I solved my problem by creating SimpleTimeZone object > without Daylight saving at GMT+0. Then set it default and set TimeZone > property of the SimpleDateFormat object. This runs without error. This manualy setting of the timezone of the SimpleDateForma (SDF) does suggest that however you are creating SDFs they are coming up with a surprising TZ. As I suggested before when you debug dates and times, show the zzz or ZZZZ to see what zone each SDF is using. -Paul == 3 of 3 == Date: Sat, Sep 18 2004 7:29 am From: "P.Hill" <[EMAIL PROTECTED]> P.Hill wrote: > For example, if you set the time right now during DLS then switch > to date which is non-DLS there are certain scenerios which will > correctly make the hour value move by one hour. Here is an example: import java.text.SimpleDateFormat; import java.util.*; public class HourJump { public static final String FORMAT_8601 = "yyyy-MM-dd 'T' HH:mm:ss.S zzz"; static SimpleDateFormat localTime = new SimpleDateFormat( FORMAT_8601 ); static SimpleDateFormat gmtTime = new SimpleDateFormat( FORMAT_8601 ); static { gmtTime.setTimeZone( TimeZone.getTimeZone( "GMT" )); } public static void main(String[] args) { Calendar cal = new GregorianCalendar(); showTime( cal ); cal.set( 2004, Calendar.DECEMBER, 15); showTime( cal ); } static void showTime( Calendar cal ) { System.out.println( " The GMT Time is: " + gmtTime.format( cal.getTime() ) + " The Local Time is: " + localTime.format( cal.getTime() ) ); } } The output is: The GMT Time is: 2004-09-18 T 14:23:01.839 GMT \ The Local Time is: 2004-09-18 T 07:23:01.839 PDT The GMT Time is: 2004-12-15 T 15:23:01.839 GMT \ The Local Time is: 2004-12-15 T 07:23:01.839 PST Notice that by only moving the date by manipulating a calendar object, I was able to make the GMT clock time move by one hour. That is because the calendar I was using when I set was running on local time while the display is using GMT time. I would guess your problem is something close to this scenerio. -Paul ========================================================================== TOPIC: writing and reading objects http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/42024eb362a85850 ========================================================================== == 1 of 2 == Date: Sat, Sep 18 2004 4:29 am From: "Madhur Ahuja" <[EMAIL PROTECTED]> Hello I have been given the task of doing simple file handling in java. i.e. I want to write set of records to a file and read them. The problem is that writeObject function produces inconsistent results when we write a series of records in one session and when we write same number of records by running the program again and again i.e. appending. The file size differs in above 2 cases. Thus reading the records produces this exception: StreamCorruptedException This exception occurs only when we read from the file in which data has been appended. The exception doesnt occurs if we write to file only once and then read. The code that am using is: //////////////////////////// import java.io.*; public class serial6 { FileOutputStream fos = null; FileInputStream fis = null; ObjectOutputStream oos = null; public serial6() { try { MyClass1 obj1 = new MyClass1("sasas",12); MyClass1 obj2 = new MyClass1("d",12); try fis = new FileInputStream("serial133.txt"); fis.close(); fos = new FileOutputStream("serial133.txt",true); } catch(FileNotFoundException e) { fos = new FileOutputStream("serial133.txt"); } oos = new ObjectOutputStream(fos); oos.writeObject(obj1); oos.writeObject(obj2); } catch( IOException e) { } try { oos.close(); } catch(IOException e) { } } public serial6(int i) { try { FileOutputStream fos1 = new FileOutputStream("serial33.txt",true); } catch(IOException e) { } } public static void main(String args[]) serial6 sr = new serial6(1); serial6 sr1 = new serial6(); } } class MyClass1 extends Object implements Serializable { String name; int roll; MyClass1(String a,int b) { this.name=a; this.roll=b; } } -- Winners dont do different things, they do things differently. Madhur Ahuja India Homepage : http://madhur.netfirms.com Email : madhur<underscore>ahuja<at>yahoo<dot>com == 2 of 2 == Date: Sat, Sep 18 2004 5:06 am From: Andrew Thompson <[EMAIL PROTECTED]> On Sat, 18 Sep 2004 16:59:44 +0530, Madhur Ahuja wrote: > The code that am using is: No it is *not* the code you are using! The code you provided does not compile. But before you post your *actual* code, I suggest you join all the try's in a single block and.. > //////////////////////////// > import java.io.*; > public class serial6 ... > catch( IOException e) > { e.printStackTrace(); > } Exceptions (at least the stack traces) are your friend.. <http://www.physci.org/codes/javafaq.jsp#exact> 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 ========================================================================== TOPIC: Job Openings in Phoenix http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c09d556eba846dd8 ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 6:04 am From: Mark Reha <[EMAIL PROTECTED]> I have 3 job openings in the Tempe Arizona. I work for a company called Vital Processing. See www.vitalps.com for details. I am looking for 3 mid to senior level J2EE software engineers who have 3-5 years working with JSP, Struts, EJB, and JDBC/SQL. We are developing on IBM's WSAD, JRules, and Hibernate and deploying on WebSphere and IBM servers. This is a large multi-year project and the openings are for full time positions. Sorry no H1's or contractors will be considered. A relocation package will be considered. If you are interested please send your resume to [EMAIL PROTECTED] Thanks. ========================================================================== TOPIC: Can I implement INSERTs and DELETEs in DAOs or only in EntityBeans? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/44068d680f903d5e ========================================================================== == 1 of 2 == Date: Sat, Sep 18 2004 6:31 am From: Sudsy <[EMAIL PROTECTED]> Tobias Merler wrote: > Ok, when I access SQL databases I could use DAOs and EntityBeans in general. > > SELECT queries can be implemented in DAOs as well as in EntityBeans. > But what about INSERTs, DELETEs and UPDATEs ? > From what I have heard so far these non-select statement MUST be implemented by > EntityBeans. > Is this true? Not at all! I've implemented solutions using stateless session beans which manipulate the database in the usual CRUD way. Some customers don't want to deal with the added complexity of entity beans. In some situations (mostly in the past) there was also a performance penalty to pay for the additional level of indirection. Since you're using DAOs anyway, including the additional functionality there would achieve the same goal. You will have to manage transactions programmatically (using JTA) rather than declaratively, however. == 2 of 2 == Date: Sat, Sep 18 2004 6:43 am From: jlp <[EMAIL PROTECTED]> Tobias Merler wrote: > Ok, when I access SQL databases I could use DAOs and EntityBeans in general. > > SELECT queries can be implemented in DAOs as well as in EntityBeans. > But what about INSERTs, DELETEs and UPDATEs ? > From what I have heard so far these non-select statement MUST be implemented by > EntityBeans. > Is this true? > > Tobias > It's false. You can do update/delate/insert statement with POJO objects and JDBC drivers ( POJO Plain Old Java Object ). See also software Object/Relational Mapping like Hibernate, Cayenne, Toplink ... You can also use JDO to acces database. All this software need a JDBC Driver. ========================================================================== TOPIC: update doesnt´t work ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3619d270a4e29711 ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 6:40 am From: Babu Kalakrishnan <[EMAIL PROTECTED]> gzell wrote: > Babu Kalakrishnan <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > >>>.. But everytime, when I call repaint(), my canvas-area first >>>get´s a "clear screen" . Is there anyone who knows why ? >>> >> >>Probably because the paint() method of the canvas derived component >>clears the drawing surface before painting the contents ? (As is very >>commonly done) >> > I inserted a method > public void update(Graphics g) {paint(g);} > to avoid this. (see source-code )... > You are assuming that the moment you call repaint(), a paint cycle is performed by the AWT subsystem (the first being a "paint()" and the subsequent ones being "update() calls) - which is not true. When the actual painting occurs isn't really decided by you - it happens asynchronously. (It is another matter that even if your assumption were true, calling the myC.zeichneLinie(p1,p2) method twice from the constructor will not result in 2 lines being drawn anyway. At the point of time when these calls are made, the frame is not even visible, and therefore you cannot expect a paint event to occur). I would suggest several changes in your code : [For simplicity I'll refer to the Canvas derived class in your example code as "canvas" and the line drawing initiation method as "addLine" because the names "Parabeln" and "zeichneLinie" is a bit difficult for me to spell] a) Don't use a java.awt.Canvas in a Swing based application. Use a JPanel instead for your canvas class. Mixing the two can cause very unexpected results. (though your current problem isn't really due to this). Do all your painting in an overridden paintComponent method - and do not override paint() or update(). b) The code inside the paintComponent method *must* be capable of rendering from scratch everything that is needed to produce the visual display from scratch anytime that the method is called. which means that if you want two lines to be seen on the screen, there must be two lines drawn by the paintComponent method. Do not expect that a line will be drawn in one place in the first paint cycle and another place in the second cycle (because you changed the coordinates by then by calling addLine) does not work in the AWT/ Swing environment. c) The requirement (b) forces a redesign of your line drawing code. Your canvas must now maintain some internal state using which the paintComponent method must determine how many times you had called the addLine method. A convenient way would be to use a java.util.List derivative (say an ArrayList) each member of which holds an Object that describes the start and end points of a line. (Several ways of representing this - could be a array of Point objects, a Line2D object, a Rectangle object or even a custom class). The addLine method must only add one new Line object to this List, and call repaint(). d) Now your painting code becomes simple enough : clear the background, draw your coordinates and draw as many lines as available in the lines List. (don't worry about this causing a flicker due to the clearing of the background - Swing's double-buffering will take care of it) Some additional (minor) points. It is better to stick to Java naming conventions when programming in Java. So Classnames should begin with a capital letter. Also Using a null layout manager and hard-coding dimensions/locations in pixels is a practice that is often frowned upon. Try to use a LayoutManager appropriate to the application which will then allow the application to display uniformly on different platforms, resolutions and user preferences. BK ========================================================================== TOPIC: Fixed & Updated Groupable Table Header http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b798b3fe6e56ad6 ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 6:52 am From: "Webby" <[EMAIL PROTECTED]> Hi, I've taken the existing Groupable Table Header code which was available elsewhere and tweaked it so it now :- 1) Works with the latest official 1.4 java release. 2) Corrected some layout issues where the columns didn't line up correctly. 3) Corrected the paint algorithm so that components are only drawn once rather than being repeatedly redrawn. 4) I've created a new GroupableColumnTableModel which derives from the DefaultTableColumnModel so that the groupable aspect of the data is now in a model rather than stored in the header. The files can be found here http://www.swebb99.f2s.com/GroupableHeader/ and include a demo file to show you what it does and how it does it. I'll add a link to provide the demo using webstart when I get round with it. Im sure there are still lots of tweaks and improvements that can be done but for now it works great for me, if only the same could be said about the way JTable works :( Anyway enjoy and I look forward to any feedback, errr I think ;) Steve Webb -- Please remove 'y' from return address to reply (Anti Spam !!) ========================================================================== TOPIC: Problem with IE and Applets. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/85712e86df721a37 ========================================================================== == 1 of 1 == Date: Sat, Sep 18 2004 7:16 am From: [EMAIL PROTECTED] (Vardan) At first: in http://www.javazoom.net/services/jchatbox/jchatbox.html in left side, under Applets Skins, choose some skin and it open applet. And second: Yes I see the http://www.physci.org/pc/property.jsp?prop=java.version+java.vendor applet. It's system information with chooser that what information i want to see. ========================================================================== TOPIC: Detecting Space-down on a mouse click http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d758d3be8abe43b ========================================================================== == 1 of 2 == Date: Sat, Sep 18 2004 7:30 am From: "Aaron Fude" <[EMAIL PROTECTED]> Hi, The modifiers of the mouse-clicked event object tell me weather alt or shift or ctrl key is down. What's the best way to detect whether some other key (such as "Space" or "a") is down? The idea is to simulate the photoshop feature that when alt and space are both pressed the active tool switches to zoom. I have a solution in mind where the overall frame captures the clicks and stores it in some kind of global object, etc. But that seems overly complicated for this simple task. Besides, I can't always control the JFrame that my component will end up in. Very many thanks in advance! Aaron Fude == 2 of 2 == Date: Sat, Sep 18 2004 8:01 am From: Paul Lutus <[EMAIL PROTECTED]> Aaron Fude wrote: > Hi, > > The modifiers of the mouse-clicked event object tell me weather alt or > shift or ctrl key is down. What's the best way to detect whether some > other key (such as "Space" or "a") is down? There is an important distinction you need to make between alt/shift/ctrl and space. The former are modifiers for keystrokes, the latter is a keystroke event. Because the latter is an event, and in reading your plan, I would say you do not want to try to use it as you are doing. > The idea is to simulate the > photoshop feature that when alt and space are both pressed the active tool > switches to zoom. So? Detect the same combination that Photoshop detects. Surely you don't think the patent police will come after you for using the same keystroke combination for your own purposes, do you? > > I have a solution in mind where the overall frame captures the clicks and > stores it in some kind of global object, etc. But that seems overly > complicated for this simple task. Besides, I can't always control the > JFrame that my component will end up in. Okay, fine. But you are much better off using a passive modifier like alt/shift or some similar choice. -- Paul Lutus http://www.arachnoid.com ======================================================================= 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 ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
