About JList

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #1

    About JList

    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 DefaultListMode l....

    "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,
    sukatoa
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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,

    Jos

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      What are you trying to do? What is your goal? What's the point to clicking on nothing?

      Comment

      • sukatoa
        Contributor
        • Nov 2007
        • 539

        #4
        Originally posted by BigDaddyLH
        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,
        sukatoa

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          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.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            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,

            Jos

            Comment

            • sukatoa
              Contributor
              • Nov 2007
              • 539

              #7
              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,
              sukatoa

              Comment

              • sukatoa
                Contributor
                • Nov 2007
                • 539

                #8
                Ok.....

                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
                Java
                C++
                Turbo C
                Pascal
                Python
                Perl
                Windows
                Linux
                Solaris ------------------- end of the list ( not scrolled )
                Unix
                RedHat
                The
                quick
                brown
                fox
                jump
                over
                the
                lazy


                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,
                sukatoa

                Comment

                • sukatoa
                  Contributor
                  • Nov 2007
                  • 539

                  #9
                  Ok, i got it.....

                  ensureIndexIsVi sible( node for "jump" value );

                  Comment

                  Working...