By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,826 Members | 815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,826 IT Pros & Developers. It's quick & easy.

About JList

P: 539
I came from List in awt....

Im currently having an experiment about JList....

say like 140,280 ( h,w )

i have 4 values that have been set on JList

using addElement from DefaultListModel....

"r03XXXX", "JoshAH", "BigDaddy", and "me"......

The JList obviously will not be full ( i mean, the scrollbar not appear ) for just those values.....

i think it needs approximately 10 values to be added so that the scrollbar will start to appear....

So now, as i clicked those values, well, highlighted ofcourse.....

If im try to click those blank values... i mean, those empty spaces in the JList,
i want the current choosen value to be not highlighted.....

for example, i will click "me".... "me" will be highlighted, and by clicking the empty space, i like to unhighlight the "me" value.....

Is it possible?

What can you advice me experts?

What event should i first read?

waiting for your replies,
Apr 21 '08 #1
Share this Question
Share on Google+
8 Replies

Expert 10K+
P: 11,448
When a JList doesn't fill up the entire available space it implies that the space
beneath a list belongs to something else (a JPanel mayhap?). You can add a
MouseListener overthere that deselects everything in the JList or add a Focus-
listener to the JList that deselects everything if the component loses the focus.

kind regards,

Apr 21 '08 #2

Expert 100+
P: 1,216
What are you trying to do? What is your goal? What's the point to clicking on nothing?
Apr 21 '08 #3

P: 539
What are you trying to do? What is your goal? What's the point to clicking on nothing?
When it selects, it will automatically fill the fields ( the information ) that should be avoided. That was all for my phonebook.....

I have just 3 buttons...(Add, Edit/Update and Delete) when one value selected, it automatically fill all fields with information.....

For example, i've selected one, but i dont like to update the contact's info, so by just clicking on the empty space inside the JList or in other surface, all the fields should be clear in order to start a new contact (for adding) if i like to add.....

As for now, i have an idea how to deselects the list.... but the event i need WHEN i will click inside the emptyspace of that JList for me haven't exists....

I get stuck last night.....

I like this phonebook to be a USER FRIENDLY PROGRAM...... so, all posible scenario that might lead the user into an inconvenience way, should be avoided.....

I have activated all the events in JList and the JScrollpane last night hoping for some alternatives.... but failed to do so.....

I got the point of joshAH, but still i need the kind of event that should be triggered when i click an EMPTY space inside the JList.....

Is it possible?

That's the only problem im facing as of the moment......

So, any idea how to handle with this kind of handling?

waiting for your replies,
Apr 22 '08 #4

Expert 100+
P: 1,216
Expecting the user to know to click on the gap below the JList items is a bad idea. That's not a standard GUI gesture. And when happens when the list is full enough to be scrollable and it doesn't have that space? Don't do it, it's a bad idea. Have a "clear" or "reset" button instead.
Apr 22 '08 #5

Expert 10K+
P: 11,448
I'm a bit confused now: how can you click *in* the list on empty space? Do you
keep 'empty' record(s) in your list to click on? And then what?

kind regards,

Apr 22 '08 #6

P: 539
If the list is full(scrollbar starts to appear), then the user should not click inside the list, because,

if he/she wants to do that, Then any value will be selected and obviously my program would directly response ( retrieve the infos on all fields ).... so, better to click outside the list....

As of the moment, i have a mouselistener on other surfaces..... except inside the List and the textfields... that would clear the selection on the list when clicked......

I really had started a bad idea.....
I assumed that for just an example, the current data is still less than 10 were the list should not be full( scrollbar not appear ) and it leads me into wasting of time....

( i forgot, i have many friends here... i like to add them soon in this program )
If my mobile's memory is nearly full.....

And it is impossible that my list should not be full ( Scrollbar not appear ).... ....HOLY COW..... tsk2x

Thanks for the interests. :)
Sorry guys, i have wasted your time.... :(

best regards,
Apr 22 '08 #7

P: 539

I added a new operation at the search field.

Instead of (typing the keyword then press enter) and show the results at the list....

I prefer to autoupdate whatever text in the search field that matches any first value encountered...

For example, i have a list, more datas (Scrollbar appeared)... like 500.

As that new operation executes, it successfully points to the first data that regionMatches ( ignores the case ).

However, it doesn't lead me to automatically show the selected value.....
Instead, i must scroll the bar to see where is the selected value.....

A scenario:
I have 20 values, the list starts from the node 0, it only shows 10 values, using scrollbar to show the others below

When i search a data in the search field, and matches, i like the list to show me automatically the selected value. ( must be appear selected ).... below the current appeared values.

for example,

Programmer ------------------- start of the list
Turbo C
Solaris ------------------- end of the list ( not scrolled )

I like to show the "jump" value in the list... at my operations, it points. The problem is, it didn't automatically show me the "jump" value, it needs to be scroll down in order just to see that "jump" value.

I like it to be automatically show me the expected value.

What method should i use? I like to have an experiment about implementing the said operation.

Any advice about this experts?

waiting for your replies,
Apr 30 '08 #8

P: 539
Ok, i got it.....

ensureIndexIsVisible( node for "jump" value );
Apr 30 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.