Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

JList item rename

Thread view: 
a - 27 Nov 2005 03:04 GMT
Hi,
In Windows environment, to rename a file, the user can just select the name
of the icon displayed on the window explorer, then click on the name. The
file name field will become a text box and the user can rename the file
there.
I use JList and my own ListModel to show the data.
I would like to modify the data displayed on the JList.
How can I have the similar function for rename the file as the windows
explorer?
Thanks a lot
zero - 27 Nov 2005 12:50 GMT
> Hi,
> In Windows environment, to rename a file, the user can just select the
[quoted text clipped - 6 lines]
> explorer?
> Thanks a lot

Unfortunately there is no such thing as a list editor.  Still, you have
several options here:

- rethink your GUI and use a JTable (eg with one column) or a JTree to
allow users to edit the nodes
- subclass JList to create your own editable list (you can use the JTable
or JTree source for ideas)
- add a popup menu to the JList, which allows you to edit the currently
selected item
- ...

An example using a one-column JTable:
http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/atomiccontrols/jlist
/jlisteditable.html

An example subclassing JList:
http://www.jroller.com/page/santhosh/20050607

The second example looks very good indeed.  I haven't tested or examined
it thoroughly, but it looks very promising.  And since Santhosh Kumar did
all the hard work for you, it should be easy to implement.

Signature

Beware the False Authority Syndrome

a - 27 Nov 2005 19:40 GMT
I have subclass JList and I have a popup menu for my JList, how this allows
me to edit the selected item?
Thanks

"zero" <zero@this.hi> ¼¶¼g©ó¶l¥ó·s»D
:Xns971B8CD8724CBzerothishi@195.130.132.70...
>
[quoted text clipped - 30 lines]
> it thoroughly, but it looks very promising.  And since Santhosh Kumar did
> all the hard work for you, it should be easy to implement.
zero - 27 Nov 2005 22:21 GMT
> "zero" <zero@this.hi> ¼¶¼g©ó¶l¥ó·s»D
>:Xns971B8CD8724CBzerothishi@195.130.132.70...
[quoted text clipped - 25 lines]
> allows me to edit the selected item?
> Thanks

Did you look at the examples?  The second example clearly shows how to
create an editable list.  You can even run it using webstart:

http://www.jroller.com/resources/s/santhosh/EditableJList.jnlp

If you want to use a popup menu, just make it create a separate JFrame
that will let you enter new info, and then substitute that in the list.

But the easiest is just to take Santhosh Kumar's code.  You can copy this
into a file, create a GUI that shows a JListMutable, compile, and you're
done.

Signature

Beware the False Authority Syndrome



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.