Search code examples
javaswingbulletedlist

How to make bulleted list in swing in netbeans


In my application, I'd like to create a bullet ed list of data in a label. How can i do this?

When i searched, I found Styled Text bullet ed list with SWT. How can i do the same with Swing?


Solution

  • Wrap you String in a html tag and build away...

    Bullet List

    JLabel label = new JLabel("<html><ul>" +
            "<li>Bananas are yellow</li>" +             
            "<li>Oranges are orange</li>" + 
            "<li>Strewberries are red</li>" + 
            "</ul><html>");
    

    How to give events to these items in label

    Given the fact that wasn't part of your original question, that changes the answer, instead, you should be using something like a series of JRadioButtons, see How to Use Buttons, Check Boxes, and Radio Buttons

    Radio buttons and check boxes

    RadioButtonsCheckBox