Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Creating A Special Type of Swing List Display

Reply
Thread Tools

Creating A Special Type of Swing List Display

 
 
Hal Vaughan
Guest
Posts: n/a
 
      01-16-2007
I want to use something like a list, but with a few changes. I'm hoping
there's an easy way to do this that I don't know about or that is so
obvious I've overlooked it. I essentially want a list with multi-line
items that can be scrolled in discrete increments. Each list item is a
name and address, like this:

John Doe
221B Baker St
New York, NY, 12345

(This has to fit in a legacy app, so I can't use a single line long enough
to fit all the info on one line.)

When scrolling, I'd like to scroll one complete address at a time, so moving
up or down won't scroll part way up to show the street or city on the top
line and part of the next item on the following line.

I know I can set the height for each item by pixels, but then I have to deal
with possible fonts and problems like that.

I've considered just using a text box and a scroll bar, getting the value of
the scroll bar and using that to figure out which item to display, and have
my code pick that item and put it in the text box. Is there an easier way
to work with discrete items that are multiple lines?

Any suggestions?

Hal
 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      01-16-2007

Hal Vaughan wrote:
> I want to use something like a list, but with a few changes. I'm hoping
> there's an easy way to do this that I don't know about or that is so
> obvious I've overlooked it. I essentially want a list with multi-line
> items that can be scrolled in discrete increments. Each list item is a
> name and address, like this:
>
> John Doe
> 221B Baker St
> New York, NY, 12345
>
> (This has to fit in a legacy app, so I can't use a single line long enough
> to fit all the info on one line.)
>
> When scrolling, I'd like to scroll one complete address at a time, so moving
> up or down won't scroll part way up to show the street or city on the top
> line and part of the next item on the following line.
>
> I know I can set the height for each item by pixels, but then I have to deal
> with possible fonts and problems like that.
>
> I've considered just using a text box and a scroll bar, getting the value of
> the scroll bar and using that to figure out which item to display, and have
> my code pick that item and put it in the text box. Is there an easier way
> to work with discrete items that are multiple lines?
>
> Any suggestions?
>
> Hal


Its generally considered a feature that you can scroll part way, its
easier for human eyes to follow. You might just want to put a better
seperator between the entries.

 
Reply With Quote
 
 
 
 
Hal Vaughan
Guest
Posts: n/a
 
      01-16-2007
Daniel Pitts wrote:

>
> Hal Vaughan wrote:
>> I want to use something like a list, but with a few changes. I'm hoping
>> there's an easy way to do this that I don't know about or that is so
>> obvious I've overlooked it. I essentially want a list with multi-line
>> items that can be scrolled in discrete increments. Each list item is a
>> name and address, like this:
>>
>> John Doe
>> 221B Baker St
>> New York, NY, 12345
>>
>> (This has to fit in a legacy app, so I can't use a single line long
>> enough to fit all the info on one line.)
>>
>> When scrolling, I'd like to scroll one complete address at a time, so
>> moving up or down won't scroll part way up to show the street or city on
>> the top line and part of the next item on the following line.
>>
>> I know I can set the height for each item by pixels, but then I have to
>> deal with possible fonts and problems like that.
>>
>> I've considered just using a text box and a scroll bar, getting the value
>> of the scroll bar and using that to figure out which item to display, and
>> have
>> my code pick that item and put it in the text box. Is there an easier
>> way to work with discrete items that are multiple lines?
>>
>> Any suggestions?
>>
>> Hal

>
> Its generally considered a feature that you can scroll part way, its
> easier for human eyes to follow. You might just want to put a better
> seperator between the entries.


Generally, yes, but in this case, due to restricted space available (I can't
do anything about that), I can fit one address in easily and I want to
avoid any confusion by making it move in discrete units.

Hal
 
Reply With Quote
 
Daniel Dyer
Guest
Posts: n/a
 
      01-16-2007
On Tue, 16 Jan 2007 17:16:21 -0000, Hal Vaughan <>
wrote:

> When scrolling, I'd like to scroll one complete address at a time, so
> moving
> up or down won't scroll part way up to show the street or city on the top
> line and part of the next item on the following line.


You probably want to look into the javax.swing.Scrollable interface. This
is already implemented by JList so over-riding one or more of the methods
may be able to achieve your desired effect.

Dan.

--
Daniel Dyer
https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      01-16-2007

Hal Vaughan wrote:
> Daniel Pitts wrote:
>
> >
> > Hal Vaughan wrote:
> >> I want to use something like a list, but with a few changes. I'm hoping
> >> there's an easy way to do this that I don't know about or that is so
> >> obvious I've overlooked it. I essentially want a list with multi-line
> >> items that can be scrolled in discrete increments. Each list item is a
> >> name and address, like this:
> >>
> >> John Doe
> >> 221B Baker St
> >> New York, NY, 12345
> >>
> >> (This has to fit in a legacy app, so I can't use a single line long
> >> enough to fit all the info on one line.)
> >>
> >> When scrolling, I'd like to scroll one complete address at a time, so
> >> moving up or down won't scroll part way up to show the street or city on
> >> the top line and part of the next item on the following line.
> >>
> >> I know I can set the height for each item by pixels, but then I have to
> >> deal with possible fonts and problems like that.
> >>
> >> I've considered just using a text box and a scroll bar, getting the value
> >> of the scroll bar and using that to figure out which item to display, and
> >> have
> >> my code pick that item and put it in the text box. Is there an easier
> >> way to work with discrete items that are multiple lines?
> >>
> >> Any suggestions?
> >>
> >> Hal

> >
> > Its generally considered a feature that you can scroll part way, its
> > easier for human eyes to follow. You might just want to put a better
> > seperator between the entries.

>
> Generally, yes, but in this case, due to restricted space available (I can't
> do anything about that), I can fit one address in easily and I want to
> avoid any confusion by making it move in discrete units.
>
> Hal

Then perhaps a list (or scrollable component of any sort) isn't the way
to go, but instead have a component that displays a single address, and
two buttons that change the address being displayed.

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      01-16-2007
Hal Vaughan wrote:
> Generally, yes, but in this case, due to restricted space available (I can't
> do anything about that), I can fit one address in easily and I want to
> avoid any confusion by making it move in discrete units.


This isn't exactly a list idiom that you describe - more of a viewport that
shows exactly one frame of information at a time. Perhaps a next/previous
idiom is more natural for your purpose?

- Lew
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      01-16-2007

Lew wrote:
> Hal Vaughan wrote:
> > Generally, yes, but in this case, due to restricted space available (I can't
> > do anything about that), I can fit one address in easily and I want to
> > avoid any confusion by making it move in discrete units.

>
> This isn't exactly a list idiom that you describe - more of a viewport that
> shows exactly one frame of information at a time. Perhaps a next/previous
> idiom is more natural for your purpose?
>
> - Lew


You are about 8 minutes to late

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      01-16-2007
Lew wrote:
>> Perhaps a next/previous idiom is more natural for your purpose?


Daniel Pitts wrote:
> You are about 8 minutes too late


(eight minutes earlier
>> Then perhaps a list (or scrollable component of any sort) isn't the way
>> to go, but instead have a component that displays a single address, and
>> two buttons that change the address being displayed.


Events that appear time-distinct in one frame of reference may be simultaneous
in another, if the interval between the events is less than the information
latency between the frames.

In other words, I hadn't refreshed from the newsgroup yet.

I feel validated that my analysis concurred with yours. You can take home the
Golden Keyboard.

- Lew
 
Reply With Quote
 
Hal Vaughan
Guest
Posts: n/a
 
      01-18-2007
Daniel Pitts wrote:

>
> Hal Vaughan wrote:
>> Daniel Pitts wrote:
>>
>> >
>> > Hal Vaughan wrote:
>> >> I want to use something like a list, but with a few changes. I'm
>> >> hoping there's an easy way to do this that I don't know about or that
>> >> is so
>> >> obvious I've overlooked it. I essentially want a list with multi-line
>> >> items that can be scrolled in discrete increments. Each list item is
>> >> a name and address, like this:
>> >>
>> >> John Doe
>> >> 221B Baker St
>> >> New York, NY, 12345
>> >>
>> >> (This has to fit in a legacy app, so I can't use a single line long
>> >> enough to fit all the info on one line.)
>> >>
>> >> When scrolling, I'd like to scroll one complete address at a time, so
>> >> moving up or down won't scroll part way up to show the street or city
>> >> on the top line and part of the next item on the following line.
>> >>
>> >> I know I can set the height for each item by pixels, but then I have
>> >> to deal with possible fonts and problems like that.
>> >>
>> >> I've considered just using a text box and a scroll bar, getting the
>> >> value of the scroll bar and using that to figure out which item to
>> >> display, and have
>> >> my code pick that item and put it in the text box. Is there an easier
>> >> way to work with discrete items that are multiple lines?
>> >>
>> >> Any suggestions?
>> >>
>> >> Hal
>> >
>> > Its generally considered a feature that you can scroll part way, its
>> > easier for human eyes to follow. You might just want to put a better
>> > seperator between the entries.

>>
>> Generally, yes, but in this case, due to restricted space available (I
>> can't do anything about that), I can fit one address in easily and I want
>> to avoid any confusion by making it move in discrete units.
>>
>> Hal

> Then perhaps a list (or scrollable component of any sort) isn't the way
> to go, but instead have a component that displays a single address, and
> two buttons that change the address being displayed.


Okay -- you did what I could not and basically described what I want to do.
(Sometimes a big problem to being self taught is not knowing the best ways
to express what I'm trying to do -- I can visualize it, but can't always
explain it properly.)

I can't find any components or objects that do this without putting them
together on my own. Is there a way to do that easily without having to
link either a scroll bar, a slider, or next/prev buttons with an array or
linked list and a component to display them? I can do it from scratch, but
thought it worth asking if there is something already set up to handle that
kind of setup.

Hal

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      01-18-2007
Hal Vaughan wrote:
> Daniel Pitts wrote:

....
> >> ...due to restricted space available ..., I can fit one address
> >> in easily and I want..
> >> to avoid any confusion by making it move in discrete units.

...
> > Then perhaps a list (or scrollable component of any sort) isn't the way
> > to go, but instead have a component that displays a single address, and
> > two buttons that change the address being displayed.

>
> Okay -- you did what I could not and basically described what I want to do.

....
> I can't find any components or objects that do this without putting them
> together on my own.


Have a look at JComboBox. With an appropriate renderer,
it might suit the requirement (as I currently understand it).

Andrew T.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Swing is dead! Long live Swing. Knute Johnson Java 32 02-29-2012 05:10 PM
Why not using javax.swing.event with swing? S.T Java 2 05-25-2007 12:10 AM
javax.swing.Popup, javax.swing.PopupFactory lizard Java 0 01-30-2006 09:34 PM
Swing Model Classes Updating Swing Components on a Thread Other Than AWT mkrause Java 0 05-06-2005 04:32 PM
Java 1.2 Swing vs. Java 1.5 Swing Big Daddy Java 2 04-16-2005 01:14 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57