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.


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

Results 1 to 2 of 2

Thread: Java JList box alignment code? Does this require setHorizontolAlignment()?

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Thanked 0 Times in 0 Posts

    Question Java JList box alignment code? Does this require setHorizontolAlignment()?

    Is there any possible way that I can align a JList box within a panel. To the left side, right side, center side, or bottom side. If so, then how can I implement this?

    Can someone give me example coding? And, does this method require you to use the setHorizontalAlignment()?

    Thank you,

  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    United Kingdom
    My Mood
    Thanked 294 Times in 227 Posts
    Blog Entries

    Default Re: Java JList Alignment Question?

    Hey antitru5t,

    What type of layout are you using?

    You could try:

    Panel myPanel = new Panel();
    myPanel.setLayout(new BorderLayout());
    myPanel.add(new JList(), BorderLayout().CENTER);
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Replies: 10
    Last Post: June 22nd, 2009, 07:45 AM
  2. [SOLVED] How to narrow down the range of input in java?
    By big_c in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 20th, 2009, 11:38 AM
  3. [SOLVED] JAVA JList Problem in visual images
    By antitru5t in forum AWT / Java Swing
    Replies: 4
    Last Post: April 15th, 2009, 03:09 PM
  4. How to show 2D array using combobox and radiobutton?
    By Broken in forum Loops & Control Statements
    Replies: 1
    Last Post: March 10th, 2009, 06:01 AM
  5. Dropping to graphic element dragged from JList
    By tua1 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 29th, 2008, 08:22 AM