Re: Help with JTable column width

2001-04-25 Thread Christian Pesch

Bill Tschumy schrieb:

 Why is the table allocating so much space to the column?

How about trying to set the second column to be resizable?

  column = getColumnModel().getColumn(0);
  column.setPreferredWidth(20);
  column.setMinWidth(20);
  column.setMaxWidth(20);
  column.setResizable(false);

  column = getColumnModel().getColumn(1);
  column.setResizable(false);

Set this to true. This might solve your resize problems,
since for now the JTable has the problem, that according
to the ColumnModel it is not allowed to resize but the container
of the JTable donates it more spaces. Thus the JTable streches
the columns on its own.

--
Christian Pesch - Software Engineer
[EMAIL PROTECTED] - fon +49.40.325587.505  fax .999
CoreMedia AG - www.coremedia.com - 0700-COREMEDIA
Erste Brunnenstraße 1, 20459 Hamburg, Germany

CoreMedia - Think ahead! We're there.




___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: [Advanced-java] Create javadocs

2001-06-18 Thread Christian Pesch

Deepesh Bhargava schrieb:

 I have 20 files in various packages. Whenever I create javadocs I do not get
 package structures on the left frame. In this case all my source files are in
 a separate directory which are the same as their package.
 When I put all the source files in the dir structure corresponding to their
 packages it works file.

 Is it a shortcoming of javadoc utility or I am missing something. Any
 suggestions?

You have to enumerate all packages from which you want
to generate javadoc from.

 I use following command:
 javadoc -private -author -version -sourcepath c:\src *.java

Instead of *.java use my.package.A my.package.B my.package.C etc.
Or write a script which collects all packages from the directories:

#!/bin/bash
#
# Searches through the source directory tree and collects
# directories, which contain Java source files. Converts
# the name of the directories into Java package names.
#
# @author Christian Pesch

DIRS=`find $INSTALL_DIR/classes -type d`
for i in $DIRS; do
 # gnu find: FILES=`find $i -name \*.java -type f -maxdepth 1`
 FILES=`find $i/* -type d -prune -o -name \*.java -type f -print`
 if [ -n $FILES ]; then
 # gnu awk: echo $i | awk -- 'BEGIN { FS = classes/ } { print $2 }' | sed
-e s/\//./g ;
 echo $i | sed 's|'$INSTALL_DIR/classes/'||g' | tr / .
 fi
done

If saved as collect-packages.sh and run

[cpesch@dwarf liveserver]$ sbin/collect-packages.sh
com.coremedia.cloudscape
com.coremedia.publisher.client
com.coremedia.publisher.client.impl
com.coremedia.publisher.server.replicator
com.coremedia.publisher.server.replicator.test
com.coremedia.publisher.importer
com.coremedia.watchdog
com.coremedia.beanparser
com.coremedia.servlet.tomcat
[..]

It prints out all package names below $INSTALL_DIR/classes. The
output may be included in a javadoc call as the package list.

--
Christian Pesch - Software Engineer
[EMAIL PROTECTED] - fon +49.40.325587.505  fax .999
CoreMedia AG - www.coremedia.com - 0700-COREMEDIA
Erste Brunnenstraße 1, 20459 Hamburg, Germany

CoreMedia - Think ahead! We're there.



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Design guidelines

2002-02-12 Thread Christian Pesch

Amit Rana schrieb:

1.Can anyone give some guidelines or points to remember while
 designing/scheduling a Swing project.

- Make use cases before designing your gui
- Get user feedback as early as possible

2.Points to remember to get better performance and better memory
 utilization?

- Do not assume, memory gets freed automatically
- Always remove your listeners
- Finalizers are not the way to free memory
- Put long-lasting actions into separate threads
- Never forget to switch to the AWT Eventqueue before modifying the GUI.

--
Christian Pesch - Software Engineer
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA
___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Design guidelines

2002-02-13 Thread Christian Pesch

Amit Rana schrieb:

1.Can anyone give some guidelines or points to remember while
 designing/scheduling a Swing project.

- Make use cases before designing your gui
- Get user feedback as early as possible

2.Points to remember to get better performance and better memory
 utilization?

- Do not assume, memory gets freed automatically
- Always remove your listeners
- Finalizers are not the way to free memory
- Put long-lasting actions into separate threads
- Never forget to switch to the AWT Eventqueue before modifying the GUI.

--
Christian Pesch - Software Engineer
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Automated Testing

2002-04-02 Thread Christian Pesch

Sean McCauliff wrote:

 What version are you using?

7.0.1 with appropriate Java Add-in for JDK 1.3.1


-Original Message-
From: Christian Pesch
To: Sean McCauliff; [EMAIL PROTECTED]
Sent: 3/28/02 11:37 AM
Subject: Re: Automated Testing

Sean McCauliff wrote:

What tools (if any) do people use for automated testing
of Swing GUIs?  My company has something from Mercury
Interactive, but it seems buggy.

We have no problems with Mercurys WinRunner here. It had
the best (not perfect ;-) concept for testing internationalized
gui applications. May you need an updated version.



-- 
Christian Pesch - Software Engineer
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: JTabbedPane repaint

2002-08-28 Thread Christian Pesch

Pallika Haridas Kanani wrote:

Hi all,

I have a JTabbedPane where each panel is used for input to a database and also 
displays data from the database. Now i want that everytime a panel gets displayed 
(i.e. corresponding tab gets focus) the panel should be repainted (so that it has the 
updated data). Any suggestions?

There is JTabbedPane#addChangeListener. As far
as the API docs say, it fires a ChangeEvent every
time a tab is selected.

-- 
Christian Pesch - Product Maturity Manager
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: JTextArea is a memory hog!

2003-01-09 Thread Christian Pesch
Joe Consumer wrote:


I can't believe this exists in Swing, but I've found
that when I loaded a 2MB file into JTextArea it
creates literally 394,000+ java.lang.ref.Finalizer
objects that hang around event after the JTextArea is
released.  What's worse is my memory usage spikes to 
65MB!  That's 30 times the size of the text string!  I
don't know what java.lang.ref.Finalizer object is, or
why it gets created. 

Its an Object that encapsulates Objects, that
have to be finalized by the Finalizer thread.

A short grep shows 3 finalize() methods in the
swing text package:

cd /opt/jdk/src/javax/swing/text/
grep -n finalize *java /dev/null
AbstractDocument.java:1461: * would call this in its finalize method.
AbstractDocument.java:1567:protected void finalize() throws Throwable {
GapContent.java:264: protected void finalize() throws Throwable {
StringContent.java:324:protected void finalize() throws Throwable {
StyleContext.java:390: * references.  This would typically be called 
by the finalize method

grep finished (5 matches found) at Thu Jan  9 12:33:00

I have a feeling it's wrapped up in AbstractDocument
code
not being very effecient in it's object allocation,
but I don't know.



No, its a huge amount of AbstractElement
objects, that have to be finalized. And the
finalizer thread is not fast enough.

This hasn't changed since early Swing days,
although the JVM supports alternatives like
WeakReferences for ages.

Until WebStart, one could patch the classes
and remove the finalize() methods. That has
some legal implications if you distribute,
but customers do not care, if their product
runs. 

--
Christian Pesch - Product Maturity Manager
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing


Re: JTextArea is a memory hog!

2003-01-13 Thread Christian Pesch
Joe Consumer [EMAIL PROTECTED]Joe Consumer wrote:


Christain,

Thanks for the info.  THe problem seems to be that
OptimizeIt doesn't seem to show these objects being
GC'ed even at a slow pace.


The finalizer thread runs at a low priority
in the hot spot vm.


What is the fix? 

Do not use AbstractDocument :-)


How do you patch AbstractDocument so
that it doesn't create all these AbstractElements? 

You can't avoid creating the elements. But
you can avoid them to be finalized by removing
the finalize() method.

/**
* Finalizes an AbstractElement.
*/
// ## patched
// protected void finalize() throws Throwable {
// AttributeContext context = getAttributeContext();
// context.reclaim(attributes);
// }


My tests showed, that the memory impact of not
executing the finalizers is very low compared
to the objects hanging around.


You could still patch this because you could simply
implement the Document interface.  Is it creating them
in createElement().


This means rewriting the complete javax.swing.text
package.


 Why does it create them and then
all of a sudden ditch them?  

May, the view creates a default document and the you set
another (your) document. The the default document is not
used anymore. Use a constructor which immediately sets your
document.


Shouldn't it create them
and hang onto them while the JTextArea is in use?


IMHO it does until the document changes. See scenario above

--
Christian Pesch - Product Maturity Manager
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: knowing when JComboBox's data has changed

2003-01-28 Thread Christian Pesch
Aleksandr Kravets wrote:


Hello,
I have a custom JComboBox class where I set a ToolTip for each item. It
works in times when I send a populated vector to the class. However,
sometimes I need to send an empty vector and populate it later. How can I
find out in custom JCB class when my vector has changed in number of
elements?


You should wrap a ComboBoxModel around your Vector
or subclass DefaultComboBoxModel. As ComboBoxModel
is a ListModel, it informs about changes. So if
you populate your Vector later, you have to fire
(at least) intervalAdded() notifications.

--
Christian Pesch - Product Maturity Manager
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing