Results 1 to 2 of 2
  1. #1
    skania is offline Member
    Join Date
    Jun 2013
    Rep Power

    Default Cannot get tabs to be correctly displayed in JScrollPane [GUI]

    Hey guys. I'm still newish to Java, and I'm tinkering with something I haven't found a solution for.

    Basically, this program has a JList of a Vector of a data that contains 2 pieces of data, a name and a grade - both strings.
    I take this list, and put it in a JScrollPane. Then update the vector using a ListSelectionListener.

    To the question:

    The toString() function of my class that is made and placed in the Vector looks like:

    Java Code:
    	public String toString(){
    		return	name + "\t\t\t" + grade;
    But when I run the program, it displays like this for instance:


    Instead of what I expected:

    Alice 10
    Bobby 20

    Here is the body of my program if needed:
    Java Code:
    Vector<Person> people = new Vector<Person>();
    for(int i = 0; i < names.length; i++){
    	people.add(new Person(names[i], i));
    JList nameList = new JList(people);
    SelectListener sl = new SelectListener(nameList, people);
    JScrollPane scroller = new JScrollPane(nameList);
    Anyone know how I can get the JList to appear formatted correctly in the JScrollPane? Any help is greatly appreciated

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Cannot get tabs to be correctly displayed in JScrollPane [GUI]

    You could use html.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. Adding tabs in webview
    By saif in forum Android
    Replies: 0
    Last Post: 03-17-2013, 08:59 AM
  2. Problem with Ajax Tabs
    By amma2009 in forum Advanced Java
    Replies: 0
    Last Post: 02-24-2010, 03:56 PM
  3. setSelectedIndex (How to move between tabs)
    By lolshooter in forum New To Java
    Replies: 4
    Last Post: 02-02-2010, 03:15 PM
  4. Replies: 4
    Last Post: 11-19-2009, 06:03 AM
  5. SWT tabs with Draw2d
    By garyscarter in forum SWT / JFace
    Replies: 0
    Last Post: 07-07-2009, 03:31 PM

Tags for this Thread

Posting Permissions

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