I want to render a table in message dialog in which the table should be scroll able. I'm able to achieve most of my requirements but the scrollbar is not visible.
Also I want the size of the message dialog box to be fixed and if the table content doesn't fit the vertical scrollbar should appear.
import javax.swing.*;
public class SystemTrayDemo
{
public static void main(String[] args)
{
String[][] data = {
{"1","2"},{"2","2"}
};
String[] lg = {"x","y"};
JTable table = new JTable(data,lg);
JScrollPane jScrollPane = new JScrollPane();
jScrollPane.getViewport().add(table);
JOptionPane.showMessageDialog(null,jScrollPane);
System.exit(0);
}
}
I'm getting this from the code above: