i would like to display multiple lines to the text area in the JEditorPane. I am comfortable with displaying one item to the text area, but how do I display multiple lines to the text area? I am new to swing. Any direction is greatly appreciated. ResultSet rs5 = stmt5.executeQuery(SQLstmt5); while (rs5.next()){ String operName = rs5.getString("name"); String operName_NoSpc = operName.trim(); //HtmlPane.setText(operName_NoSpc);//one item at a time allPages[z] = operName_NoSpc; z++; } rs5.close();
Jennifer Garrett
Greenhorn
Joined: Oct 31, 2001
Posts: 13
posted
0
if you use HTML (setContentType("text/html") then you just insert some or between the lines and you only call setText once with all the lines and the or line separators.
Jennifer Garrett
Greenhorn
Joined: Oct 31, 2001
Posts: 13
posted
0
oops, I forgot how to write > and < in html. I was trying to say insert some <p> and <br> to the text before doing setText().
Charlotte Shearrill
Ranch Hand
Joined: Dec 07, 2001
Posts: 34
posted
0
thank you. next question... would i be able to use this with the array, allPages, that i have defined in my above code?
Jennifer Garrett
Greenhorn
Joined: Oct 31, 2001
Posts: 13
posted
0
You could do something like this, since you already have a while loop. You don't need the array allPages, but if you really want to use it you can. You could loop through all the elements in the array and append them to the stringbuffer, but it might be easier to do it this way:
StringBuffer newText = new StringBuffer(""); ResultSet rs5 = stmt5.executeQuery(SQLstmt5); while (rs5.next()){ String operName = rs5.getString("name"); String operName_NoSpc = operName.trim(); newText.append(operName_NoSpc); // HtmlPane.setText(operName_NoSpc); //one item at a time allPages[z] = operName_NoSpc; z++; } HtmlPane.setText(newText.toString()); rs5.close();
Jennifer Garrett
Greenhorn
Joined: Oct 31, 2001
Posts: 13
posted
0
StringBuffer newText = new StringBuffer(""); ResultSet rs5 = stmt5.executeQuery(SQLstmt5); while (rs5.next()){ String operName = rs5.getString("name"); String operName_NoSpc = operName.trim(); newText.append(operName_NoSpc); newText.append("<br>"); // HtmlPane.setText(operName_NoSpc); //one item at a time allPages[z] = operName_NoSpc; z++; } HtmlPane.setText(newText.toString()); rs5.close();