I have a JPanel (and I've tried a JTextArea as well) that I would like to have text on it. The text needs to be
- Centered
- Have word wrap
- Use a custom font from a .ttf file that I am currently using that is not installed on the computer. I have already solved this problem, and the font works fine. It does not, however, work when placed in tags as I have seen as a possible solution for my problem.
I can generally get two of these rules to work, but cannot get all three to work at once. I've tried html tags, JLabels, JTextAreas, but none satisfy all conditions. Any suggestions?
static JTextArea quesLbl;
quesLbl = new JTextArea("");
quesLbl.setWrapStyleWord(true);
quesLbl.setLineWrap(true);
quesLbl.setEditable(false);
quesLbl.setFont(qFont);
quesLbl.setOpaque(true);
quesLbl.setForeground(Color.WHITE);
quesLbl.setBackground(Color.BLUE);
This code results in the text being word wrapped, and the font working, but not being centered.