Comments for Java Tips Weblog https://tips4java.wordpress.com Sun, 30 Nov 2025 19:25:41 +0000 hourly 1 http://wordpress.com/ Comment on List Editor by Anonymous https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13076 <![CDATA[Anonymous]]> Sun, 30 Nov 2025 19:25:41 +0000 http://tips4java.wordpress.com/?p=125#comment-13076 <![CDATA[In reply to <a href="https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13072">Anonymous</a>. <!-- wp:paragraph --> <p><strong>EditListAction</strong></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p><em>If you which to use a different model or different data</em><br>If you wish to use a different model or different data,</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>In case you'd like to "modernize" the ActionListener:<br>/*<br>* Create the popup editor<br>*/<br>private void createEditPopup()<br>{ ....<br> editTextField.addActionListener(e -></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>(Typing code looks horrible, so I drop the rest.)</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p><strong>ListAction</strong></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p><em>By default the Enter will will be used to invoke the Action</em><br>By default the Enter key will be used to invoke the Action</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p><em>from the keyboard although you can specify and KeyStroke you wish.</em><br>from the keyboard, although you can specify any KeyStroke you wish.</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p></p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>All the best</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>Jörg</p> <!-- /wp:paragraph -->]]> <![CDATA[

In reply to Anonymous.

EditListAction

If you which to use a different model or different data
If you wish to use a different model or different data,

In case you’d like to “modernize” the ActionListener:
/*
* Create the popup editor
*/
private void createEditPopup()
{ ….
editTextField.addActionListener(e ->

(Typing code looks horrible, so I drop the rest.)

ListAction

By default the Enter will will be used to invoke the Action
By default the Enter key will be used to invoke the Action

from the keyboard although you can specify and KeyStroke you wish.
from the keyboard, although you can specify any KeyStroke you wish.

All the best

Jörg

]]>
Comment on List Editor by Anonymous https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13075 <![CDATA[Anonymous]]> Sun, 30 Nov 2025 19:01:13 +0000 http://tips4java.wordpress.com/?p=125#comment-13075 <![CDATA[In reply to <a href="https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13073">Rob Camick</a>. <!-- wp:paragraph --> <p>Thanks for the explanation.</p> <!-- /wp:paragraph -->]]> <![CDATA[

In reply to Rob Camick.

Thanks for the explanation.

]]>
Comment on List Editor by Rob Camick https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13073 <![CDATA[Rob Camick]]> Sat, 29 Nov 2025 01:18:54 +0000 http://tips4java.wordpress.com/?p=125#comment-13073 <![CDATA[In reply to <a href="https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13072">Anonymous</a>. <!-- wp:paragraph --> <p>When creating a JList with a String array a simple anonymous inner class is used for the model and only contains getSize() and getElementAt(...) methods. There are no methods to update the model, which is why the simple implementation requires the DefaultListModel.</p> <!-- /wp:paragraph -->]]> <![CDATA[

In reply to Anonymous.

When creating a JList with a String array a simple anonymous inner class is used for the model and only contains getSize() and getElementAt(…) methods. There are no methods to update the model, which is why the simple implementation requires the DefaultListModel.

]]>
Comment on List Editor by Anonymous https://tips4java.wordpress.com/2008/10/19/list-editor/#comment-13072 <![CDATA[Anonymous]]> Fri, 28 Nov 2025 23:52:54 +0000 http://tips4java.wordpress.com/?p=125#comment-13072 <![CDATA[<!-- wp:paragraph --> <p>Hello Rob,</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>thanks for the code. I just tested under java 25 and found that EditListAction doesn't work if a String array is passed to the JList constructor. Maybe that's what you meant when writing <em>you must use the DefaultListModel</em>.<em> </em>Still I thought that if <em>only String data will be saved</em> I could use a String[] parameter. So I would prefer the JList creation in the example implementation code to look like <code>JList list = new JList(myDefaultListModel);</code> to prevent any misunderstanding.</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>Thanks again</p> <!-- /wp:paragraph --> <!-- wp:paragraph --> <p>Jörg</p> <!-- /wp:paragraph -->]]> <![CDATA[

Hello Rob,

thanks for the code. I just tested under java 25 and found that EditListAction doesn’t work if a String array is passed to the JList constructor. Maybe that’s what you meant when writing you must use the DefaultListModel. Still I thought that if only String data will be saved I could use a String[] parameter. So I would prefer the JList creation in the example implementation code to look like JList list = new JList(myDefaultListModel); to prevent any misunderstanding.

Thanks again

Jörg

]]>
Comment on Wrap Layout by Marty Lamb https://tips4java.wordpress.com/2008/11/06/wrap-layout/#comment-13071 <![CDATA[Marty Lamb]]> Tue, 10 Jun 2025 12:23:35 +0000 http://tips4java.wordpress.com/?p=194#comment-13071 <![CDATA[<!-- wp:paragraph --> <p>It's 2025 and this is still helping folks. It just saved me a ton of time and pulled me out of some rabbit holes where I was exploring other solutions. Thanks!<br></p> <!-- /wp:paragraph -->]]> <![CDATA[

It’s 2025 and this is still helping folks. It just saved me a ton of time and pulled me out of some rabbit holes where I was exploring other solutions. Thanks!

]]>
Comment on Text Prompt by Anonymous https://tips4java.wordpress.com/2009/11/29/text-prompt/#comment-13069 <![CDATA[Anonymous]]> Sat, 29 Mar 2025 00:47:46 +0000 http://tips4java.wordpress.com/?p=1250#comment-13069 <![CDATA[<!-- wp:paragraph --> <p>Mi mas sincero agradecimiento a quien compartió su trabajo de manera altruista, eso ya no se ve, soy un programador que esta aprendiendo el lenguaje y me ayudo MUCHISIMO, gracias de nuevo al autor</p> <!-- /wp:paragraph -->]]> <![CDATA[

Mi mas sincero agradecimiento a quien compartió su trabajo de manera altruista, eso ya no se ve, soy un programador que esta aprendiendo el lenguaje y me ayudo MUCHISIMO, gracias de nuevo al autor

]]>
Comment on Text and New Lines by vaxacex https://tips4java.wordpress.com/2009/02/07/text-and-new-lines/#comment-13068 <![CDATA[vaxacex]]> Fri, 21 Mar 2025 11:50:15 +0000 http://tips4java.wordpress.com/?p=529#comment-13068 <![CDATA[<!-- wp:paragraph --> <p>Thank you, man! After 16 years, I found this article and saved myself thousands of headaches and hours</p> <!-- /wp:paragraph -->]]> <![CDATA[

Thank you, man! After 16 years, I found this article and saved myself thousands of headaches and hours

]]>
Comment on Wrap Layout by Anthony K https://tips4java.wordpress.com/2008/11/06/wrap-layout/#comment-13066 <![CDATA[Anthony K]]> Wed, 15 Jan 2025 03:28:47 +0000 http://tips4java.wordpress.com/?p=194#comment-13066 <![CDATA[This was grreat to read]]> <![CDATA[

This was grreat to read

]]>
Comment on Text Area Scrolling by Marissa Hunt https://tips4java.wordpress.com/2008/10/22/text-area-scrolling/#comment-13062 <![CDATA[Marissa Hunt]]> Tue, 29 Oct 2024 07:48:40 +0000 http://tips4java.wordpress.com/?p=135#comment-13062 <![CDATA[Great reading your blogg]]> <![CDATA[

Great reading your blogg

]]>
Comment on Swing and Java 8 by markwilliams211992 https://tips4java.wordpress.com/2015/04/05/swing-and-java-8/#comment-13029 <![CDATA[markwilliams211992]]> Mon, 26 Feb 2024 12:42:01 +0000 http://tips4java.wordpress.com/?p=1998#comment-13029 <![CDATA[Thanks for sharing such knowledge.]]> <![CDATA[

Thanks for sharing such knowledge.

]]>