If you want a dropdown field in your table, you could do it like it is done here. Then, this will be the part where you create the JComboBox:
public void setUpSportColumn(JTable table,
TableColumn sportColumn) {
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Knitting");
comboBox.addItem("Speed reading");
comboBox.addItem("Pool");
comboBox.addItem("None of the above");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
}
And if that is not what you want, but just the content of the dropdown-cell when you hover your mouse over the cell, and all the elements nice in a column, you just have to use html-tags in the string you are passing to setToolTipText-method. Like this:
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
String newLine = "<br>";
String toolTipText = "<html>Snowboarding"+newLine+"Rowing"+newLine+"Knitting"+newLine+"Speed reading"+newLine+"Pool"+newLine+"None of the above</html>";
renderer.setToolTipText(toolTipText);
sportColumn.setCellRenderer(renderer);
I found that answer here: Multi-line tooltips in Java?