how to insert a new line in a jlabel???
800425Sep 19 2007 — edited Sep 19 2007hi everyone
i have a panel that have a jlabel... my problem is that i can make this label show line feeds even though im adding the "\n" escape character...
please help
thanks in advance
this is my code
<code>
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Test extends JFrame{
private String message = "This tool is used to set the database path\n" +
"If the database is on the local machine, you should use \"localhost\" or \"127.0.0.1\"\n" +
"If the database is on a networked machine, you should use the IP address of that machine\n";
private JLabel help = new JLabel(message);
private JPanel mPanel = new JPanel();
private JPanel hPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
public Test() {
setTitle("Database Path Updater");
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setSize(450,350);
setLocation(100,100);
setResizable(false);
setupComponents();
initializeGUI();
}
private void setupComponents() {
mPanel.setLayout(new BoxLayout(mPanel, BoxLayout.Y_AXIS));
}
private void initializeGUI() {
add(mPanel);
hPanel.add(help);
mPanel.add(hPanel);
}
public static void main(String[] args){
new Test().setVisible(true);
}
}
</code>