Need help with JPanels and JLabels
Hey,
Just a quick question about working with JLabels inside JPanels. I have a 2D array of JPanels (called squares) and would like to put a JLabel with text in some of them. However, when the text is too long to fit in one line of the box, it cuts off. I tried to put in "\n" in order to create a new line but when I ran the program java seemed to completely ignore it. Does anyone know how to either create new lines inside a JLabel or to make it start a new line once it has reached the edge of its display area? I have posted one example of a method in my program below just to clarify. Any help/advice is much appreciated!
public void display(){
squares[2][8].removeAll();
playerMoney = new JLabel(playerOne.getName() + " has: $" + playerOne.getCash() + "\n" + playerTwo.getName() + " has: $" + playerTwo.getCash());
squares[2][8].add(playerMoney);
squares[2][8].validate();
}