Results 1 to 11 of 11
  1. #1
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default Different components in an AWT list

    Hi All

    I am trying to do some enhancements to a legacy AWT application and basically I need to create a list of addable/removable rows where each row has a button in column 1, 2 radio-buttons/check-boxes in col2, 2 text boxes in cols 3&4 and then a drop down list in col 5 and then a button again in col 6.

    Is there a component in AWT that i can make use of?

    Also it would be very difficult for me to use 3rd party components/libraries so if you can point me in the right direction whether it be examples or existing components your help would be much appreciated.

    ps: I have created a prototype of what I want to do in MS Paint and have attached with this post.
    many thanks in advance :)
    Attached Thumbnails Attached Thumbnails Different components in an AWT list-samplelistcomponent.jpg  

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default

    If your layout is rows and columns:
    Have you looked at either of the Gridxxx layout managers?

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I would also consider using a JTable here. You can set up your editors and renderers to behave like buttons, collections of radio buttons, and drop down lists.

  4. #4
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default

    The number of rows can grow dynamically and several components in each row will have events registered against them(button clicks, drop down selection changes etc). Not sure how I would create event handlers for dynamically generated components.

    I had a discussion with a colleague and he suggested using a panel to represent a row and then create a RowClass which returns a panel to its caller with all the components and their respective event handlers all encapsulated in that RowClass . I have a feeling with this method the formatting might become a nightmare....

  5. #5
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default

    Sorry cant use any Swing(JTable ) components :(

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default

    number of rows can grow dynamically
    This is while the program is running? Then there is a GUI problem to update the display to show the new rows as they are added.

    dynamically generated components
    What are "dynamically generated components"? All components are created by using new.
    How would these differ from any other?

    I don't know why the event handlers would be a problem. As the new GUI components are created and added to the GUI, the event handlers could be added to those components.

  7. #7
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default

    Hi Norm

    Cheers for your replies....

    If you look at the snapshot that I have attached with this post there is an add row button on the gui. And the user will start off with a single row but could keep adding rows dynamically.

    In which case say if I want to have an event handler method registered for the button click in column7 then how would I find out which row the button was clicked in ? say if I need to use the value entered in the corresponding text box in column 4

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default

    how would I find out which row the button was clicked in
    Extend the button class and have a variable in the class with its row number.
    Or a more structured approach would have an object for each row that the components on the row could access to get at its fellow components on that row.

  9. #9
    karthi66 is offline Member
    Join Date
    Aug 2010
    Posts
    4
    Rep Power
    0

    Default

    Moderator edit: - deleted -
    Last edited by Fubarable; 08-07-2010 at 02:46 PM.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  11. #11
    alinaqvi90 is offline Member
    Join Date
    May 2010
    Posts
    32
    Rep Power
    0

    Default resolved

    Hi

    I created flowlayout panel and added all my components in it. And made it a RowClass. And all the event handling etc for every individual component is done inside it.

    If any one needs any more help on it give us a shout :)

    cheers

Similar Threads

  1. Replies: 2
    Last Post: 11-22-2009, 06:24 PM
  2. Replies: 3
    Last Post: 11-21-2009, 06:48 PM
  3. how to create list of list in java ???
    By ilayaraja in forum Advanced Java
    Replies: 1
    Last Post: 10-26-2009, 05:30 PM
  4. Linked List integer list
    By igniteflow in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 09:53 PM
  5. How to access ArrayList in List of List?
    By alvations in forum New To Java
    Replies: 5
    Last Post: 10-08-2008, 01:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •