Re: jdk 1.2

1998-05-25 Thread Pavel

Hello Gabor,

Look at JGL pure Java container library
(http://www.objectspace.com/jgl/) from Object Space. It is absolutely
free, is given in source code and much more powerful that 1.2.
collection stuff. I have read that Sun licenseed their library for 1.2.
but apparently they reduced it if used it at all. For other things of
this sort, look also at http://www.x3m.com/. Their library is even
smarter (unlike JGL, it does not simulate C++'s STL) but had no new
release for more than one year. Or you can try to compile Sun's source
code with 1.1. (but it is not possibly allowed by their license -- read
it carefully before doing this).

All the Best
Pavel

[EMAIL PROTECTED] wrote:
> 
> Hi,
> 
> will there be a jdk1.2 port in the near future (even for the betas)? I'd
> like to use collections and I'm not willing to switch to NT :-(
> 
> cheers,
> 
> Gabor
> 
> -- Gabor Szentivanyi, [EMAIL PROTECTED] --
> -- Multimedia Information Systems Design  --
> --  ITS, Delft University of Technology   --
> --   "The more I practice, the luckier I get."--


Re: Passing classes as parameters

1998-05-26 Thread Pavel

Yes. If your class has a no-arg constructor, just do like this:

void method(Class c)
{
...
Object o = c.newInstance();
... // use 'o'
}

Otherwise, look for a Constructor class documenation from
java.lang.reflect package to create and initialize your object with a
constructor with parameters.

All the Best
Pavel

Wim Ceulemans wrote:
> 
> Hi
> 
> Does anyone has experience in passing a class as a parameter in java?
> 
> I want to do something like call a method with as parameter a class name and
> then create instances of that class in that method. Is this possible?
> 
> Regards
> Wim Ceulemans
> Nice Software Solutions
> Eglegemweg 3, 2811 Hombeek
> Tel 0032-15-41-29-53 Fax 0032-15-41-29-54


Re: Building nice looking forms with layout managers

1998-05-28 Thread Pavel

GridBagLayout can do this 
(with
GridBagConstraints gbc = new GridBagConstraints();
...
gbc.fill = GridBagConstraints.NONE;
...
)
and many other things. Since I have learned this layout manager I do not
need any other layout manager(s). But it is complex and has very
unpolish design. So do not hesitate to ask me if you have problems with
it.

Pavel

Wim Ceulemans wrote:
> 
> Hi
> 
> Thanks everyone for responding to my question of passing classes as
> parameters. I've successfully used the java.lang.reflect API to dynamically
> create instances even with parameters in the constructor.
> 
> I have another question concerning building nice looking forms. In any data
> input form you have labels and next to the labels you have fields (in my
> case JLabel's and JTextField's). For laying out these labels and fields I
> use a BoxLayout and two GridLayout's like this:
> 
> JPanel dataPanel = new JPanel();
> dataPanel.setLayout(new BoxLayout(dataPanel,BoxLayout.X_AXIS);
> JPanel labelPanel = new JPanel(new GridLayout(0,1));
> dataPanel.add(labelPanel);
> JPanel fieldPanel = new JPanel(new GridLayout(0,1));
> dataPanel.add(fieldPanel);
> 
> This works nice but the only problem is that all fields are stretched to the
> width of the largest field. Even if I add the JTextfield's with the width
> parameter (new JTextField(width)).
> 
> Does anyone know of a possibility using layout managers to inhibit this
> stretching of fields?
> I don't want to resort to absolute positioning because this involves a lot
> of work and because my form template now is independant of the data.
> 
> Wim Ceulemans
> Nice Software Solutions
> Eglegemweg 3, 2811 Hombeek
> Tel 0032-15-41-29-53 Fax 0032-15-41-29-54


Re: RS232/Java

1998-09-04 Thread Pavel

If you are on Linux platform look also at
http://www.mail-archive.com/java-linux@java.blackdown.org/msg01184.html

Pavel.

Jim Watson wrote:
> 
> Dear All,
> 
> I know that this question isn't really related to java/Linux but I could do
> with a few pointers..
> 
> I'd like to write an application that sends and receives short ASCII text
> strings using the com port on my PC, using RS232.  Could anybody point me
> to any packages/existing source code that already does this so I can see
> how to do it.
> 
> Thanks in advance.
> 
> Jim
>  \\\|///
>\\  - -  //
> (--@ @--)
> +-oOOo-(_)-oOOo-+
> | Jim Watson MCI (Sri Lanka)|
> | e-mail: [EMAIL PROTECTED]   |
> +---Oooo+
> oooO   (   )
>(   )) /
> \ ((_/
>  \_)



Re: Can't find class etc etc etc.

1998-09-24 Thread Pavel

> 
> I'm fully agree with you but I think that people so lazy to reading
> FAQ... Aren't they? ;-)  
...
Isn't is good idea to ask Karl to include

1. Link to
http://www.blackdown.org/java-linux/docs/faq/FAQ-java-linux.html
2. Instruction about how to unsubscribe from this list

To the footer of each letter distributing via this maillist?

Just my 2 cents.

All the Best
Pavel



Re: Java language question: static classes ?

1998-10-16 Thread Pavel

>  What is a static class?
Making classes static has good sense if they are nested. Usually nested
class object has hidden member referencing high level class object and
hidden constructor parameters. But static nested class is just like a
high level class. By the way, static public class nested in another
public class is the single method I know to define more than one public
class in one file. I have no idea whether static classes are
syntaxically allowed on the top level. I think it does not matter -- all
such classes are actually static in all senses I can image.

Hope this helps.

Pavel



Re: Java language question: static classes ?

1998-10-16 Thread Pavel

> So public static SwitchPLAFAction { ... } is a just java object class
> that is really instantied just once, like some sort of singleton?
No, no. I did not mean that static classes are related to singletons.
They are not AFAIK.

> Actually I have used a modified version of the ActionEvent class from
> Kim Topley "Core JFC" example in Xsql as an inner class. So now Xsql can
> switch PLAFs too. It works, but I still dont understand public static class ?

This is an example of what I want to say:

// File A.java
public class A {
...
public class B { ... }
}
// End of file
// File C.java
public class C {
...
public static class D { ... }
}
// End of file

You can use both classes A.B or C.D in any packages such as both of them
are public. But A.B class has one additional hidden member of A class
and requires one additional constructor parameter of A type (in default
"no-arg" constructor) if you create it outside of A class scope. C.D
class is just like usual Java top level public class.

That's all I know about static classes

Hope this will help.
Pavel


// 

> 
> I cant find a reference to it in "Exploring Java". I will see if I can
> borrow back "Core Java" this weekend.
> 
> Pete
.. 
> Correct me if I'm wrong, but I do not believe top-level classes can have
> the 'static' modifier applied, but if you want a shared entity, do
> something like this:
> 
> public class DefaultFactory
>extends AbstractFactory
> {
>protected DefaultFactory() { /* empty */ } // or private if you wish
>public final static DefaultFactory SHARED_INSTANCE = new
> DefaultFactory();
>...
> }
> 
> This is how I create shared entities (for example in JUMP, a framework for
> numeric computations). The only potential problem you have here is
...



Re: out of memory

1998-06-18 Thread Pavel

You should probably increase -mx option value when running java. AFAIK
default value is 32M

All the Best
Pavel

Richard Hall wrote:
> 
> I've just begun using JDK1.1.6 on my Debian 2.0.29 machine, and the
> compiler often, but not always claims to be out of memory.  top says:
> 
> Mem:   14324K av,  14020K used,304K free,   8732K shrd, 92K buff
> Swap:  32252K av,  17908K used,  14344K free  3616K cached
> 
> The compiler has bailed with close to 1M of RAM free.  The only things
> running while this is happening besides a few xterms are X, Netscape, and
> XEmacs.  Do I need to add more swap or what?
> 
> Richard Hall
> Network Services
> University of Tennessee




Re: Regexp utility classes..

1998-06-30 Thread Pavel

I had some references but now have managed to find only one (but the
best). It is free (but not GNU and no sources). Manages full Perl5
regular expression syntax. OROMatcher.

http://www.oroinc.com/

All the Best
Pavel

Per Widerlund wrote:
> 
> Hello List..
> 
> This may not be the appropriate mailing list to ask about this,
> but does anyone know of some good classes for handling regular
> expressions?
> 
> /Per Widerlund




Re: Deprecated `Thread.stop()' in forthcoming JDK 1.2. Why?

1998-11-13 Thread Pavel Tolkachev

>  I read somewhere that Thread.stop() is now deprecated. 
Yes, and it's very good.
> Now how on  earth do we stop a thread ?
Just allow it to exit from its run() method.

Try to use this pattern: pattern is (run() can be in Thread subclass or
in Thread Runnable))

private boolean runEnabled_ = true;
private Object stopsync_ = new Object();
public void run() {
 while(isRunEnabled())
  {
  ... // do things in your thread
  }
}
public void stop() // call this function from other thread when you want
to stop thread
 {  syncrhonized(stopsync_)   { runEnabled_ = false; } }
public boolean isRunEnabled()
 {
 boolean result;
 synchronized(stopsync_)  { result = runEnabled_; }
 return result;
 }

>  I thought the solution would be Thread.interrupt()
>  but that only works when the thread is sleeping, at least in JDK 1.1
>  documentation.
Yes, it is just to awake waiting, joining or sleeping thread.
>It seems to be idiocy to have a start method and not have a stop method. 
In single thread You can call method from outside but you cannot stop it
until it leaves (things like Ctrl-C do the trick but there is destroy()
method in Thread API that is the analog of such unnormal killer). What
do you think it is strange here?

See also
http://java.sun.com/products/jdk/1.2/docs/guide/misc/threadPrimitiveDeprecation.html 

Hope this help

Pavel



Re: Deprecated `Thread.stop()' in forthcoming JDK 1.2. Wh

1998-11-13 Thread Pavel Tolkachev



[EMAIL PROTECTED] wrote:
...
> Class.forName( "org.blackdown.jdbc.AnyOldDriver" );
> Connection con = DriverManager.getConnection( url, username, password );
> Statement stmt = con.createStatement( "select * from JDK_RELEASES" );
> 
> stmt.executeQuery();  // One atomic call with no way to run to !!!

> I have a spawn threads to execute the above SQL query and then allowed to
> operator to kill the thread if the query was slow. 
Can stmt.setQueryTimeout(someTimeout) help you? Your software could even
compute different timeouts depending on expected query complexity.

Pavel



Re: Basic installation. Please Help.

1998-11-17 Thread Pavel Tolkachev

> IMO, the cross-platform capabilities of java are seriously hurt by all the hoops
> that end-users have to jump through (setting up classpaths, .sh/.bat files, etc)
> just to get someone elses application to run. Admittedly, java installshield and
> the like do do a good job of setting this stuff up, but a more general (and built
> in) solution is required.
> 
>   [ bryce ]
According the Sun (unfortunately I do not remember URL) the 'preferred'
way to specify classpath is do not set CLASSPATH environment variable at
all (namely because it is not portable) but to use -cp and -classpath
for jre start (apparently -classspath is for 'everywhere used' packages
like Swing, probably JGL and jpython) and -cp for the application
classpath itself and other its specific packages. Anyway you will
usually have non-portable scripts to start applications... probably
concatenating command line from other environment variables not
deprecated by Sun like SWING_RELEASE_PATH :). For development (where we
need to use java instead of jre) all should be put in -classpath, I
beleive.
Just my 2cents

Pavel



Re: Deprecated `Thread.stop()' in forthcoming JDK 1.2. Why?

1998-11-23 Thread Pavel Tolkachev

> Right.  Sleeping and blocking I/O are interrupted by the interrupt
> mechanism; when this happens, the I/O methods and the sleep method
> throw an appropriate exception that tells you it is interrupted.

I/O methods do not throw, at least not on NT Sun's JDKs and API
documentation does not state they must. Sorry for repeating posting but
this is my test case from message posted earlier to this thread. Please
try it on Linux with native threads if possible: 

-
Well, as my testing has shown even stop() function does not stop thread
waiting IO (I tested on NT Sun's JDK 1.1.7 though). I do not feel it is
thread API design disadvantage; sooner it is drawback of java.io API. My
common sense tells me: there is no way to stop thread "in correct
manner" if it has no provisions for this. InputStream makes you to poll
available() function for non-blocking read. Probably my testing code
will give you some assistance in your problem:
...

cut here--
/**
 * Q. Can I interrupt input waiting?
 * A1. No -- with stop(), destroy() or interrupt().
 * A2. Yes -- with available() polling.
 */
public class IOWaiting
  {
  public static void main(String [] argv)
{
final Thread mainThread = Thread.currentThread();
Thread t;
(t = new Thread(new Runnable()
{
public void run()
  {
  try
{
Thread.currentThread().sleep(5000);
System.out.println("Stopping main thread...");
// uncomment call you want to test
//  mainThread.interrupt();
//  mainThread.destroy();
mainThread.stop();
}
  catch(InterruptedException e)
{
System.out.println("Interrupter has been interrupted!");
}
  }
}
  )).start();
System.out.println("Input something... or don't do it :)");
int ioResult = 777;
try
  {
  ioResult = System.in.read();
  t.interrupt();
  }
catch(java.io.IOException e)
  { e.printStackTrace(); }
System.out.println("IOResult:" + ioResult);
(t = new Thread(new Runnable()
{
public void run()
  {
  try
{
Thread.currentThread().sleep(5000);
System.out.println("Stopping main thread...");
mainThread.interrupt();
}
  catch(InterruptedException e)
{
System.out.println("Interrupter has been interrupted!");
}
  }
}
  )).start();
try
  {
// clear System.in for the next test
  while(System.in.available() > 0)  ioResult = System.in.read();
  System.out.println("Input something again ... or don't do it :)");
  try
{
while(System.in.available() == 0)
  { // polling... but what can I do?
  Thread.currentThread().sleep(100);
  }
ioResult = System.in.read();
t.interrupt();
}
  catch(InterruptedException e)
{ System.out.println("Reading has been interrupted!"); }
  }
catch(java.io.IOException e)  { e.printStackTrace(); }
System.out.println("IOResult:" + ioResult);
}
  }
---cut here

All the Best
Pavel



Re: Deprecated `Thread.stop()' in forthcoming JDK 1.2. Why?

1998-11-24 Thread Pavel Tolkachev

...
>> My
> >common sense tells me: there is no way to stop thread "in correct
> >manner" if it has no provisions for this. InputStream makes you to poll
> >available() function for non-blocking read. Probably my testing code
> >will give you some assistance in your problem:
> 
> It is hard to have stop() work during blocking I/O on native threaded
> systems since the native threading and I/O blocking may not have a way
> to cleanly "break" out of the blocked I/O state.  The only option may
> be to kill the process (or thread) at a OS level and thus you would
> have a problem of not being able to clean up.

This is what I tried to say. Moreover, with 'green threads' stopped
thread will also have cleanup problem if non-preemptive task manager
calls like Thread.yield() are hidden in the many common API functions.
Again, imho code running in thread must know that it is interruptable
and provide API for well behaving interrupt
(via timeout as DatagramSocket.setSoTimeout() does or directly as
java.sql.Statement.cancel() does).

Pavel



Re: Using "setSize" with a Frame.

1998-11-29 Thread Pavel Tolkachev

> > It opens a frame with the size 1100x100.
> You and I should read more closely. 1100x100 works correctly here. 100x100 doesn't.

It's expected behavior of java. First time 'releasing' window or other
native component you indirectly call Component.addNotify() that adds
native peer to component. During adding peer it can change size as it
wants (what it wants for Frame does depend on Window system and
particular on window manager if it is XWindow window system). The
general solution is to resize component after it is release. Further,
"to release" means do something that call addNotify(). From usual calls
these are pack() and setVisible(true) if called for the 1st time for
component. However remember that it is not safe to change size from any
other thread but EventProcessingThread as soon as component is released
such as AWT is not thread-safe. If you call pack() and then setSize()
*before* setVisible(true) or show() it is a good chance (maybe 100%)
that your setSize() will not clash with any event handler (such as a few
or no events are passed to component until it is visible), so this will
work almost always or even always (I cannot say 100%). Other way that I
am using and that must work in 100% is the following:

setVisible(true);
SwingUtilities.invokeLater()
{
new Runnable()
{
frame.setSize(100,100);
}
}

This includes utility from Swing that in fact must be available in AWT.
It allows you to execute some code in event processing thread. You can
also safely set initial size in window or component listener of some
ready event like WINDOW_OPENED or so.

Also be sure that your window manager ALLOWS so small Frames at all.
Otherwise, peer can prevent your setSize() from doing its work.

Hope this helps
Pavel



Re: swing-1.1beta3

1998-12-03 Thread Pavel Tolkachev



[EMAIL PROTECTED] wrote:
> 
> I'm having some problems to install swing-1.1beta3 on RH5.2.
> 
> 1. I installed jdk in /java/jdk117_v1a/
> 2. I downloaded swing11-beta3.tar.z into /java
> 3. tar xvzf swing11-beta3.tar.z created directory /java/swing-1.1beta3 + 60
> html files own by user uucp and group 143.
> 4. I added the following lines to .bash_profile for user /home/wdacruz:
> PATH:/java/swing-1.1beta3:$PATH
> CLASSPATH=.
> SWING_HOME=/java/swing-1.1beta3
> export PATH CLASSPATH SWING_HOME
You can try to add /java/swing-1.1beta3/swingall.jar to your CLASSPATH
(note that it is not only directory but full path to swingall.jar).
Adding SWING_HOME to PATH seems to me excessive such as you probably do
not want start executable files resided in this directory (there is no
such files there).

Hope this helps
Pavel



Re: Reading (All) Environment Variables in W95/NT

1998-12-14 Thread Pavel Tolkachev

Try something like this in your NT/95 startup script (smth like this
must work also on linux/bash with changing \ to /, %% to $, del to rm
and doing smth with :s and ;s in multiple paths in environment):

set >%TMP%\env
java -Denv.file=%TMP%\env ...
del %TMP%\env

and then in your code:
Properties p = new Properties();
p.load(new FileInputStream(System.getProperty("env.file")); //

Hope this helps.

All the Best
Pavel

[EMAIL PROTECTED] wrote:
> 
> I am getting some requests from NT users on an application that I wrote on
> a Java/Linux environment. I have a Java application that runs fine on Unix
> and I am trying to get to run perfectly on NT. I have a run time shell
> script that passes the entire environment to the JVM using a system
> property.
> 
> java -Denv=`env` xenon.xsql.editor.Xsql
> 
> The env produces the multiline environment variables list that we know and
> love. On running the application the program looks for the value of system
> property called `env'. Hence the JVM gets the entire environment. I have
> source code that breaks down the multiline value and cuts out each variable
> definition like `HOME=/home/peterp'. The definition is further split into a
> name and value (`HOME' and `/home/peterp') and then place stored in the
> system properties as renamed property `env.HOME' and `/home/peterp'. In
> short all the environment variable are prepended with `env.'. Using this
> hand-me-down old deprecated source code from an unknown URL, I can write
> code like this:
> 
> String imagesDir=System.getProperty("env.IMAGES_DIR");
> String searchPath=System.getProperty("env.JAVAFILESEARCHPATH");
> 
> 
> Of course this does not work with Windows NT (or 95/98). I am not an expert
> on NT. I do not think there is an equivalent for `env' under NT.
> Is there such thing ?
> 
> Of course I could write a work around that involve just passing a limited
> number of properties to JVM in a NT batch command `.BAT' file.
> 
> java -DIMAGES_DIR=%IMAGES_DIR%  ...  xenon.sql.editor.Xsql
> 
> Admittedly the full final code would look terrible ugly. I am clueless if
> the DOS? W95/NT Shell allows long character lines. Can you even do `back
> subtitution' using the W95/NT shell is also quite another thing as well?
> Also when I tried extending my `PATH' under W95 I got `out of environment
> space' or something?
> 
> However do any other java-linuxers know of a better solution or API?
> 
> Any help receives my grateful kudos.
> 
> Pete



Re: Request For OS Sys Props [was Re: Reading (All) EnvVars ]

1998-12-16 Thread Pavel Tolkachev

Well, 

First of all this is information you asked for.

os.name= Windows NT
os.arch= x86
os.version = 4.0

Then, why do you think this practice (with directories in user.home
started from .) is bad on WIN32? Yes, files started from '.' are visible
in explorer, so what? Sun's Workshop and my software and many other
softwares (even not written on java, e.g. Netscape Communicator) still
use directories and files instead of registry to store settings on 'by
user' basis. Storing settings on 'by machine' basis is not standardized
on Unix and is also difficult on Win32 (registry has more drawbacks than
advantages). Note that currently (Java 1.1 platform) user.home on NT is
set to directory %HOMEDRIVE%%HOMEPATH% but in 1.2. it will be set to
directory %USERPROFILE% that actually plays more as Unix home directory
on Windows NT than %HOMEDRIVE%%HOMEPATH% (it is so usual for Microsoft
to change the meaning of well known words in their products ;-) ). 

All the Best
Pavel

[EMAIL PROTECTED] wrote:
> 
> Right then.
> 
> I notice that the GIMP is very in that it creates a `~/.gimp subdirectory'
> to place multiple configurations. So does the the CDE on my Solaris box in
> `~/.dt'. On non-Unix machine the `dot' directory does not make a lot of
> sense. Is there a way to find if the JVM is running on a unix box or not?
> 
> If not I can do it the hard way.
> can you mail me your UNIX & non UNIX settings:
> 
> System.out.println( "os.name= "+ System.getProperty( "os.name"));
> System.out.println( "os.arch= "+ System.getProperty( "os.arch"));
> System.out.println( "os.version = "+ System.getProperty( "os.version"));
> 
> Somebody must have already have done this, if not I publish the results in
> a web table in 1999!
> 
> Peter Pilgrim



Re: Request For OS Sys Props [was Re: Reading (All) EnvVar

1998-12-16 Thread Pavel Tolkachev

Yes I do not mind, I even like programs writing their settings in such a
way. Windows NT keeps the whole its registry in memory (based on my
experience with it I even suspect that it keeps it intentionally in
*physical* memory for some strange reasons). Image that you have 100
programs installed on your system. But simultaneously you run, say, 5 of
them. But settings for all other 95 programs are still eating your
physical memory... Because of this I do not like programs keeping large
settings in registry. I am sure I am not alone in this. Note that I even
did not mention cross platform portability issues, just poor registry
implementation in NT.

All the Best
Pavel

> 
> Thanks.
> 
> I had no know idea if "." prefix directories are reasonable of not
> reasonable on Win 95/98/NT. Note this is just UNIX convention, that makes
> sense for UNIX like operating system, because of the default
> de facto behaviour of the `/usr/bin/ls' program.
> 
> In short you do not mind if a program creates
> `C:\Winnt\Profiles\johndoe\.gimprc'
> directory to stores a properties file , say `default.config' on your
> machine. Assuming %USRPROFILE% is `C:\Winnt\Profiles\johndoe'.
> 
> BTW: This `SysProps.java' program is handy.
> 
> Pete



Re: Is this a JVM bug? Why is my local variable not initialized?

1999-01-06 Thread Pavel Tolkachev

This is expected behavior. The following is an excerpt from "The Java
Language Specification", sectoion 12.5 (Creation of New Class
Instances):
cut here-
1.Assign the arguments for the constructor to newly created parameter
variables for this constructor invocation. 
   2.If this constructor begins with an explicit constructor invocation
of another constructor in the same class (using this), then evaluate the
arguments and process that constructor
 invocation recursively using these same five steps. If that
constructor invocation completes abruptly, then this procedure completes
abruptly for the same reason; otherwise,
 continue with step 5. 
   3.This constructor does not begin with an explicit constructor
invocation of another constructor in the same class (using this). If
this constructor is for a class other than Object,
 then this constructor will begin with a explicit or implicit
invocation of a superclass constructor (using super). Evaluate the
arguments and process that superclass constructor
 invocation recursively using these same five steps. If that
constructor invocation completes abruptly, then this procedure completes
abruptly for the same reason. Otherwise,
 continue with step 4. 
   4.Execute the instance variable initializers for this class,
assigning their values to the corresponding instance variables, in the
left-to-right order in which they appear textually in the
 source code for the class. If execution of any of these
initializers results in an exception, then no further initializers are
processed and this procedure completes abruptly with that
 same exception. Otherwise, continue with step 5. (In some early
Java implementations, the compiler incorrectly omitted the code to
initialize a field if the field initializer expression
 was a constant expression whose value was equal to the default
initialization value for its type.) 
   5.Execute the rest of the body of this constructor. If that execution
completes abruptly, then this procedure completes abruptly for the same
reason. Otherwise, this procedure
 completes normally. 
cut here-
Note that item 4 (executing instance vairable initializers) follows 2
and 3 (superclass constructor calls). I did not read Bruce Eckel's book
so I cannot say whether he is wrong or just misinterpreted.

Hope this helps

All the Best
Pavel

Richard Jones wrote:
> 
> Can someone tell me why this program, when run under
> Linux, prints d = 0 (ie. the variable d isn't being
> initialized as expected)? According to Bruce Eckel's
> book, which is the only reference I have available to
> me, d should be initialized to 1, so I suspect this
> may be a JVM bug ...
> 
> Rich.
> 
> -
> /* SuperClass.java */
> 
> public abstract class SuperClass
> {
>   protected SuperClass ()
>   {
> method ();
>   }
> 
>   protected abstract void method ();
> }
> -
> 
> -
> /* DerivedClass.java */
> 
> public class DerivedClass extends SuperClass
> {
>   public int d = 1;
> 
>   public DerivedClass ()
>   {
> super ();
>   }
> 
>   protected void method ()
>   {
> System.out.println ("d = " + d);
>   }
> 
>   public static void main (String[] args)
>   {
> DerivedClass derivedClass = new DerivedClass ();
>   }
> }
> -
> 
> $ java -version
> java version "1.1.6"
> $ java DerivedClass
> d = 0
> 
> --
> -  Richard Jones. Linux contractor London and SE areas.-
> -Very boring homepage at: http://www.annexia.demon.co.uk/  -
> - You are currently the 1,991,243,100th visitor to this signature. -
> -Original message content Copyright (C) 1998 Richard Jones.-



java-linux@java.blackdown.org

1999-01-18 Thread Pavel Tolkachev

Javasoft have not decide yet whether it is lawful to distribute Windows
L&F on non-windows environment. To stay on safe side they embedded the
function 

public boolean isSupportedLookAndFeel()

into all LookAndFeels. For WindowsLookAndFeel it looks like:

public boolean isSupportedLookAndFeel() {
return isNativeLookAndFeel();
}

I am far from knowledge whether it is lawful for you to change it to
'return true' and to try how it looks.

All the Best
Pavel

Yago Diaz wrote:
> 
> I have download the swing-1.1 package from javasoft and I installed it on my
> Linux box with jdk-1.1.7-v1a and native_threads. I run the SwingSet and when I
> try to change to the Windows Look & Feel it gives me an
> unsupportedLookAndFeelException. Does it works for you?
> 
> yago



Unidentified subject!

1999-03-10 Thread Pavel Kessler




Hi !
 
I tried yesterday the jdk 1.2 for i386.
 
Everything compiled without any problems, but I was not able 
to
start the compiled application.
 
The java virtual machine requires libstdc++. which 

IS NOT PART OF MY LINUX DISTRIBUTION ( 
SuSe 6.0) !
 
What about to use static linkage (at least for the preview 
versions),
or distribute the library in your package ?
 
 
Pavel Kessler
==
 
   ... 
...   Dr.  Pavel 
Kessler  .    * .    
.  Software 
Department   .   . .   
.   Bruker Analytik 
GmbH   B R U K E 
R   D-76287 
Rheinstetten 4, Germany   .   . .   
.   Voice: 
++7243-504-428    Fax: ++7243-504-480  
.    * .    
.     
... 
...   
E-mail:    [EMAIL PROTECTED]
 
==


Re: Line numbers vs Compiled Code in stack traces

1999-04-19 Thread Pavel Tolkachev



Michael Nielsen wrote:
> 
> dan wrote:
> >
> > Try running with the "-nojit" option.  Turning off the JIT allows the exception
> > stack trace to display line numbers.
> 
> Where, I tried java -nojit in 1.2, but it complains that no such option.
> 
> mvh
> mike.
> 
The following options must work for both 1.1 and 1.2 (I did not try it
on Linux though, only on NT):

-Djava.compiler=

Pavel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Problems appending to a file

1999-04-28 Thread Pavel Tolkachev

The problem is not with FileOutputStreams but with
ObjectOutputStream(f). ObjectOutputStream is the consistent database and
it must be written and read entirely 'in one eat'. This does not mean
you cannot save two ObjectStreams to one file, but it is up to you to
divide your file to the 2 relevant parts when reading it.

Try change your code to something like this: 

 public static void main(String argv[])
 {
final int portion = 2;
int i;
 try
 {
 FileInputStream
 f = new FileInputStream("out");
 
 ObjectInputStream o;
 
 while (true)
{
i = portion;
o = new ObjectInputStream(f);
while(i-- > 0) System.err.println("Saw: " + (String)o.readObject());
}
 }
 catch (Exception e)
 {
 System.err.println(e.toString());
 }
 }

Or you can store the number of object before objects if it is more
relevant for your application.

Hope this helps
Pavel

> public static void main(String argv[])
> {
> try
> {
> FileInputStream
> f = new FileInputStream("out");
> 
> ObjectInputStream
> o = new ObjectInputStream(f);
> 
> while (true)
> System.err.println("Saw: " + (String)o.readObject());
> }
> catch (Exception e)
> {
> System.err.println(e.toString());
> }
> }
int firstPortion = 2; //objects

 FileInputStream
 f = new FileInputStream("out");
 
 ObjectInputStream
 o = new ObjectInputStream(f);
 
 while (true)
 System.err.println("Saw: " + (String)o.readObject());



"Frank B. Brokken" wrote:
> 
> Dear listmembers,
> 
> I have a problem using FileOutputStreams. I want to be able to append to
> an existing file, and I would like to be able to read the information back
> later.
> 
> To write to the file, I use the following small program, in which a
> FileOutputStream is opened in append-mode, followed by the writing of two
> Strings:
> 
> ///
> import java.io.*;
> 
> public class writer
> {
> public static void main(String argv[])
> {
> try
> {
> FileOutputStream
> f = new FileOutputStream("out", true);  // open in append mode
> 
> ObjectOutputStream
> o = new ObjectOutputStream(f);
> 
> o.writeObject("hello"); // write 2 strings
> o.writeObject("world");
> o.flush();
> f.close();
> }
> catch (Exception e)
> {
> System.err.println(e.toString());
> }
> }
> }
> //
> 
> Then, to read the file again, I use the following small program:
> 
> //
> import java.io.*;
> 
> public class reader
> {
> public static void main(String argv[])
> {
> try
> {
> FileInputStream
> f = new FileInputStream("out");
> 
> ObjectInputStream
> o = new ObjectInputStream(f);
> 
> while (true)
> System.err.println("Saw: " + (String)o.readObject());
> }
> catch (Exception e)
> {
> System.err.println(e.toString());
> }
> }
> }
> 
> 
> Now, after running writer the first time, 'out' is created, and contains
> (hex):
> 
> :  AC ED 00 05 74 00 05 68 65 6C 6C 6F 74 00 05 77  t..hellot..w
> 0010:  6F 72 6C 64  orld
> 
> The reader program reads this, and shows:
> 
> Saw: hello
> Saw: world
> java.io.EOFException: Expecting code
> 
> So far, so good. Now I run writer again, and this results in the following
> contents of the file 'out':
> 
> :  AC ED 00 05 74 00 05 68 65 6C 6C 6F 74 00 05 77  t..hellot..w
> 0010:  6F 72 6C 64 AC ED 00 05 74 00 05 68 65 6C 6C 6F  orldt..hello
> 0020:  74 00 05 77 6F 72 6C 64  t..world
> 
> Note the byte at offset 0x14: it is 0xac, which is -84 when the byte is viewed
> as a signed 8 bits value. When I now run reader, it tells me:
> 
> Saw: hello
>

Re: A bug(?) report

1999-05-07 Thread Pavel Tolkachev



Topi Maenpaa wrote:
> 
> I have noticed some things that do not seem to work right in your current JDK1.2
> release for Linux. The reason why I consider these bugs is that the same things
> work on Sun's implementation.
> 
> 1. Is there a problem with the ActionListeners? I have noticed that some events do
> not arrive to the listeners in the order the listeners were added. I mean that
> when I do button.addActionListener(listener1) followed by
> button.addActionListener(listener2), listener1 should receive action events first.
> If this is not the case, I am doing something very stupid...
...

For this 1st issue, you assumption is not true. Specification does not
warrant the order in which listeners will obtain notifications.
Moreover, if AWTEventMulticaser is used to support event delivery (that
is probably the case for your button), the order will be reverse to the
listener adding order.

All the Best
Pavel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



[Slightly off-topic] Re: How to make a system call in Java

1999-05-13 Thread Pavel Tolkachev

Chris Abbey wrote:
...
> *note: Process.waitFor() has some ugly problems (on all platforms)
> with never returning your call

...It seemed to be a problem also when I played with this (using
JPython, not java directly, though). But then I discovered this was my
lack: I must empty both Output and Error streams before process can
finish. Moreover such as callee can intermix outputs to stdout and
stderr, I had to empty them in different threads. Then waitFor()
returned as awaited. This behaviour can be masked by the fact that
stdout is usually buffered. The following simple program was useful for
me to  check whether my Java code uses exec - waitFor stuff properly:

#include 
int main(void)  {
int n = 100, i = 0;
while(n--)   {
fprintf(stdout, "STDOUT line number %d\n", ++i)
fprintf(stderr, "STDERR line number %d\n", i)}  }

Hopefully this information can be useful to somebody.

Pavel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: indeo avi module & rtf-reader for java-linux?

1999-05-27 Thread Pavel Tolkachev



Bruno Boettcher wrote:
> 2. question didn't found anything in java to display rtf format, maybe
> somebody could redirect me in the right direction? This should surely exist...
Swing javax.swing.text package includes RTF support. I am not sure
whether it is full enough though.

Pavel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Unidentified subject!

1999-06-01 Thread Pavel Kessler

Hi!

I am using your 1.2v1 prerelease on Suse 6.1 Linux.
Java programs without own windows (swing,awt) work
without problems.

Every start of some swing program (e.g. examples from jdk)
ends with following error:

Exception in thread "main" java.lang.Error: can't load
javax.swing.plaf.metal.MetalLookAndFeel

The trace of already loaded classes (see attachement) shows,
that this class was already loaded !

Do you have any idea(s) what may be the cause of this problem ?


Sincerely

Pavel Kessler

#####
Pavel Kessler
Am Grabenacker 8, 76275 Ettlingen 6, Germany
E-mail privat:  [EMAIL PROTECTED]
   office: [EMAIL PROTECTED]
#

 java.error


Re: final variables in constructors

1999-07-15 Thread Pavel Tolkachev

The answer is: according the JLF, superclass constructor is called
*before* any initialization statement in subclass. super() does not
actually run in aClass() but java compiler generates  method where
it is called before first initialization statement of aClass. The syntax
super(...) is allowed only to let class designer to point which
superclass constructor with which parameters he wants to use, not to use
super() as usual method. You can think of it another way: superclass
constructor cannot access subclass instance data members. Consider
making v static (then it will be initialized during class, not instance
initialization).

Hope this helps

All the Best
Pavel


Kontorotsui wrote:
> 
> I wonder why if I write this:
> 
> aClass extends aSuperClass
> {
>   aClass()
>   {
>  super(1);
>   }
> }
> 
> where the superclass is:
> 
> aSuperClass
> {
>   aSuperClass(int i)
>   {
> ...
>   }
> }
> 
> anything works ok.
> 
> If instead I write
> 
> aClass extends aSuperClass
> {
>   final int v = 1;
> 
>   aClass()
>   {
>  super(v);
>   }
> }
> 
> with the same superclass, I get a "Can't reference v before the superclass
> constructor has been called." error from the compiler.
> 
> I understand that in general a variable cannot be referenced before the
> superclass constructor was called, but if that variable is a final, then it's a
> constant, why does the compiler complains?
> The two pieces of code are, semanthically, the same, aren't they?
> The javac pre-processor could even substitute the constant values before
> compiling!
> 
> It's the java language that is excessively pedantic or there is something I'm
> missing?
...


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Frame Layout

1999-08-16 Thread Pavel Tolkachev

Hi all,

With Window, you can do almost all you can do with Frames, but, in spite
of Frames, Windows do not appear at the taskbar (at least on Windows
systems, I suppose for X Window managers similar behaviour can be
observed). IMHO the better AWT design would be to allow to select this
behavior as Window property in public API and then to implement Frames
and Dialogs on pure java deriving them from Window. Unfortunately Sun
went other way :(.

Pavel

[EMAIL PROTECTED] wrote:
> 
> Umm... is there any particular reason you are using a Frame instead of a
> Window?
> 
> On Sat, 14 Aug 1999, Sebastien Vidon wrote:
> 
> > Hi everybody
> >
> > I'm trying to get rid of the borders of any Frame or JFrame. I've tried
> > to find a method
> > to set its Insets, but unsuccessfully. Does anyone know a trick?
> > Thanks
> >
> > Sebastien
> >
> >
> > --
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> >
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: EventListener

1999-08-23 Thread Pavel Tolkachev

One way is to store your frame somewhere in your MIActionListener. With
minimum changes in your code you can write like this

menulistener.addActionListener(new MIActionListener(this));

class MIActionListener implements ActionListener{
Frame f;
MIActionListener(Frame f) { this.f = f; }
public void actionPerformed(ActionEvent Ae){
f.setBounds(...); //...
}
}

Commonly used (but probably not the best) way to shorten code is to use
anonymous internal class in this manner:

menulistener.addActionListener(new MIActionListener()
{
public void actionPerformed(ActionEvent Ae){
JFrame.this.setBounds(...); //...
}
});

Hope this helps

All the Best
Pavel

ALPESH KOTHARI wrote:
> 
> Hello all,
> 
> I am developing a GUI using JAVA 2 on linux.
> 
> There is one menuitem, which when pressed should resize my main window.
> But I am not exactly able to write the resize code in the
> actionlistener..
> 
> class xxx extends JFrame{
> .
> .
> .
> 
> menulistener.addActionListener(new MIActionListener());
> 
> .
> .
> 
> }
> 
> class MIActionListener implements ActionListener{
> public void ActionPerformed(ActionEvent Ae){
> //To write a code so as the resize the
> //main window of xxx.
> }
> }
> 
> So what can I do?
> 
> This may be a silly question, but I would thank if someone answers it.
> THanking YOU
> Alpesh
> 
> 
> 
> ===
> KOTHARI ALPESH D.
> STUDENT M. TECH.
> CEDT
> INDIAN INSTITUTE OF SCIENCE
> BANGALORE-560 012
> INDIA
> __
> Do You Yahoo!?
> Bid and sell for free at http://auctions.yahoo.com
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Still looking for a solution.

1999-10-21 Thread Pavel Tolkachev

Dear Wayne,

Wayne wrote:
...
> Can someone tell me why this doesn't when I have the button. Also how
> can I get
> this to work without putting a handler on the button?
... 
I suppose this is because frame dispatches keyboard event to the lowest
component that has keyboard focus in its Component hierarchy (see
Container's processEvent() function source code). Apparently this lowest
component is your button. And your button consumes this event (call its
consume() method) and so it is not dispatched back to Frame.

I hope this will help to understand what happened. To advice the
solution for the problem, I have no enough information about the
purposes of your application.

All the Best
Pavel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Printing with 1.2

1999-11-12 Thread Pavel Tolkachev

Hi Greg,

See this two articles on Sun's site:

http://developer.java.sun.com/developer/technicalArticles/Printing/Java2DPrinting/index.html,
http://developer.java.sun.com/developer/technicalArticles/Printing/SwingPrinting/index.html

You may need to register as Java Developer (it is free) to read them.

Hope this will help.

All the Best
Pavel

Greg Tomalesky wrote:
> 
> Hi Gang:
> 
> Does anyone know where I can get some examples of printing under JDK
> 1.2?
> 
> Thanks
> Greg
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]