JLabel supports html 3.2 (roughly).
Another option is to make up your own JDialog for this.
// intiialize your_components
// add listeners as needed
JDialog dialog = new JDialog(new Frame());
dialog.getContentPane().add(your_components)
dialog.pack();
dialog.setLocation(...)
dialog.setVisible(true);
// carry on as desired..
import javax.swing.*;
import java.util.Arrays; // j2se 1.5+
public class OptionsTest {
public static void main(String[] args) {
int[] data = { 2, 3, 4, 5 };
int[] squares = getSquares(data);
int[] cubes = getCubes(data);
System.out.printf("squares = %s%n", Arrays.toString(squares));
System.out.printf("cubes = %s%n", Arrays.toString(cubes));
String s = formatResults(data, squares, cubes);
JOptionPane.showMessageDialog(null, new JLabel(s), "Results",
JOptionPane.PLAIN_MESSAGE);
}
static private int[] getSquares(int[] input) {
int[] out = new int[input.length];
for(int j = 0; j < input.length; j++) {
out[j] = input[j]*input[j];
}
return out;
}
static private int[] getCubes(int[] input) {
int[] out = new int[input.length];
for(int j = 0; j < input.length; j++) {
out[j] = input[j]*input[j]*input[j];
}
return out;
}
static String formatResults(int[] input, int[] one, int[] two) {
// StringBuffer is the legacy alternative for j2se 1.4-.
StringBuilder sb = new StringBuilder("<html>");
for(int j = 0; j < input.length; j++) {
sb.append("Number: " + input[j] + "<br>");
sb.append("Result for equation no.1: " + one[j] + "<br>");
sb.append("Result for equation no.2: " + two[j] + "<br><br>");
}
return sb.toString();
}
}