Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Positioning/Resizing JList Help

  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    32
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Positioning/Resizing JList Help

    I have a JList that lists files in a certain directory, i cannot get it to setLocation or setSize.

    import java.awt.*;
    import java.swing.*;
     
    public class b extends JFrame
     
    ...
     
    ...Gets what the list disaplys....
     
    <initiated JList>
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSize(575, 375); //no matter what parameters i put in its always center
    list.setVisibleRowCount(15);
    add (new JScrollPane(list));

    its the same way with a button...


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Positioning/Resizing JList Help

    What Layout Manager are you using? Recommended reading: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    Also, have you tried setting the size of the JScrollPane instead?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3

    Default Re: Positioning/Resizing JList Help

    Usually to set the size and position of an element, you need to set the layout manager of the container that you are putting it in to null.
    Kenneth Walter
    Software Developer
    http://kennywalter.com

Similar Threads

  1. [SOLVED] jsplipane and resizing
    By dabdi in forum Java Theory & Questions
    Replies: 9
    Last Post: June 7th, 2011, 12:10 PM
  2. button positioning
    By pds8475 in forum Java Theory & Questions
    Replies: 1
    Last Post: January 29th, 2011, 09:35 AM
  3. Positioning elements. Is it possible without layouts?
    By goodguy in forum AWT / Java Swing
    Replies: 6
    Last Post: January 21st, 2011, 02:24 PM
  4. The positioning and alignment of the text on the paper to be printed
    By java_fledgeling in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: June 8th, 2010, 08:54 PM
  5. Content positioning on the screen
    By Drakenmul in forum AWT / Java Swing
    Replies: 1
    Last Post: July 27th, 2009, 09:02 AM