participate


New To Java - About JList
<<   Back to Forum  |   Give us Feedback
This topic has 4 replies on 1 page.
doubtinswing
Posts:22
Registered: 6/20/06
About JList   
Jun 22, 2006 2:08 AM

 
Hello all,
Now i am adding the items into the list,
and i have to track while adding the items into the list.
How can I find out wheher the items are adding to the list or not?
any listener i have to add to the list. what listener and how can i use it?
I can find the items are added or not?
but i want to find the status after the addition started and before the addition completed

Any body help me?.
 
Michael_Dunn
Posts:7,727
Registered: 8/17/03
Re: About JList   
Jun 22, 2006 2:30 AM (reply 1 of 4)  (In reply to original post )

 
How can I find out wheher the items are adding to the list or not?

check the size of the listModel
 
  raindrop
Posts:464
Registered: 4/11/06
Re: About JList   
Jun 22, 2006 2:33 AM (reply 2 of 4)  (In reply to #1 )

 
Hello all,
Now i am adding the items into the list,
and i have to track while adding the items into the
list.
How can I find out wheher the items are
adding to the list or not?

See java API specification
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html
and
http://java.sun.com/docs/books/tutorial/uiswing/components/list.html


// Create a JList that displays the strings in data[]
 
 String[] data = {"one", "two", "three", "four"};
 JList dataList = new JList(data);
 
 // The value of the JList model property is an object that provides
 // a read-only view of the data.  It was constructed automatically.
 
 for(int i = 0; i < dataList.getModel().getSize(); i++) {
     System.out.println(dataList.getModel().getElementAt(i));
     // you could compare your element with the elements
     // which are on the JList here
 }
 



any listener i have to add to the list. what
listener and how can i use it?

for example:
 final JList list = new JList(dataModel);
 MouseListener mouseListener = new MouseAdapter() {
     public void mouseClicked(MouseEvent e) {
         if (e.getClickCount() == 2) {
             int index = list.locationToIndex(e.getPoint());
             System.out.println("Double clicked on Item " + index);
          }
     }
 };
 list.addMouseListener(mouseListener);
 
doubtinswing
Posts:22
Registered: 6/20/06
Re: About JList   
Jun 22, 2006 3:15 AM (reply 3 of 4)  (In reply to #2 )

 
Hello ,
we can find the item added or not by the method of size() of the list.

But I want to know status of the list

before the addition -- if size of the list is zero

after the addition -- if size of the list >0

during the addition --- how can i find it?

any body; help me please
 
DrLaszloJamf
Posts:16,478
Registered: 10/23/03
Re: About JList   
Jun 22, 2006 5:56 AM (reply 4 of 4)  (In reply to #3 )

 
Perhaps if you described what you are trying to do, what your high-level goal is, then forum members could offer better advice.
 
This topic has 4 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums