Results 1 to 7 of 7
  1. #1
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Basic GUI questions

    Solved my problems, sorry if my question was a bit confusing/unclear, I didn't want to give huge code dumps. I will probably need help soon with the searching lists action event.
    Last edited by sunde887; 02-11-2011 at 06:59 PM.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Quote Originally Posted by sunde887 View Post
    What kind of command can I add to the event to close the window?
    What class is the "window"? What methods does it have? Dispose and setVisible come to mind.

    And How can I update the JList? Also, is there a way to change the size of JLists?
    Not that familiar with JLists you may have to create a new JList each time. Alternative you can just write the data from your ArrayList to a text area and not use a JList.

    I am thinking of using some kind of set to make sure I do not get duplicate people stored. I am not quite sure how exactly to override HashCode
    I'm sure a google search will provide some info. Meanwhile a quick and dirty option is to just return the length of a String such as a persons name.

  3. #3
    rp181 is offline Member
    Join Date
    Mar 2009
    Posts
    70
    Rep Power
    0

    Default

    For JLists, use a ListModel for dynamic applications. Very to use (e.g model.add(""); )
    How to Use Lists (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    Closing a window, by default, will close your entire applciation. do: setVisible(false); and the GC should take care of it.

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

    Default

    Quote Originally Posted by rp181 View Post
    Closing a window, by default, will close your entire applciation. do: setVisible(false); and the GC should take care of it.
    Not if it's a JDialog or a JFrame with the setDefaultCloseOperation method called properly (though in this situation I prefer to use the dialog).

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Quote Originally Posted by rp181 View Post
    setVisible(false); and the GC should take care of it.
    Using setVisible(false) does not make a component eligible for GC.

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I ended up going with frame.dispose() and setVisible(false)

  7. #7
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    Using setVisible(false) does not make a component eligible for GC.
    Quote Originally Posted by sunde887 View Post
    I ended up going with frame.dispose() and setVisible(false)
    Don't forget to set the frame to null in order for it to be garbage collected, although I don't know why you'd bother, because if the frame's closed, the app's probably about to shut down anyway.

Similar Threads

  1. VERY basic Java questions
    By hayden06f4i in forum New To Java
    Replies: 6
    Last Post: 11-10-2010, 09:09 PM
  2. Need really basic help!
    By anthonyalaan in forum New To Java
    Replies: 9
    Last Post: 09-12-2010, 02:43 PM
  3. Some Basic file handling questions
    By alacn in forum New To Java
    Replies: 1
    Last Post: 06-22-2010, 12:24 AM
  4. Basic Image Questions
    By DaRancor in forum AWT / Swing
    Replies: 6
    Last Post: 11-22-2009, 01:20 AM
  5. Basic Help
    By robjames in forum New To Java
    Replies: 3
    Last Post: 02-09-2009, 03:58 AM

Posting Permissions

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