0

I am trying to the text of my output jlabel to an array list in Netbeans 8.0.2. I am able to set the arraylist to the jlabel, but i need breaks in it so the whole thing isnt in one line. Anyone know how i can do this effectively?

import java.util.*;
public class CollectionAp extends javax.swing.JFrame {
ArrayList <String> CD = new ArrayList();
    /**
     * Creates new form CollectionAp
     */
    public CollectionAp() {
        initComponents();
    }
    private void InitializeClicked(){
        DisplayButton.setEnabled(true);
        AddButton.setEnabled(true);
        RemoveButton.setEnabled(true);
        InitializeButton.setEnabled(false);
        Collections.addAll(CD,"Three Days Grace - Human Race","Steven Wilson - Hand Cannot Erase","Beatcore - Far From Home", "Paris Blohm - Left Behinds","DEAF KEV - Invincible");
    }
    private void DisplayClicked(){
        String DisplayString = (CD.toString());
        OriginalOutput.setText("Original Order\n**********\n" + DisplayString);
  • 2
    Wrap the text in ``, make use of a layout manager which will use favor the `preferredSize` of the label so it will wrap properly, [for example](http://stackoverflow.com/questions/14737810/jlabel-show-longer-text-as-multiple-lines/14738193#14738193) – MadProgrammer Nov 22 '15 at 23:19
  • 1
    http://stackoverflow.com/questions/2152742/java-swing-multiline-labels – vlatkozelka Nov 22 '15 at 23:20
  • First of all variable names should NOT start with an upper case character. The forum thinks your variables are class names and it makes your code confusing to read Same with the method names. Don't use a JLabel. Its is mainly designed for a single line of text. Maybe use a JtextArea or a JList or to be even fancier use a JTable then you can display the Artist and Song in different columns. Check out the [Swing tutorial](http://docs.oracle.com/javase/tutorial/uiswing/components/componentlist.html) for examples of how to use these classes. – camickr Nov 22 '15 at 23:25

0 Answers0