Answer the question
In order to leave comments, you need to log in
How to display pictures in javax.swing.JTable cells?
In general, there is a table in which, at the moment, the text is displayed. I need to display pictures from a file.
Now:
public class MyModel extends AbstractTableModel {<br>
<br>
private char[][] level = new char[10][20];<br>
....<br>
public Object getValueAt(int r, int c) {<br>
return this.level[r][c];<br>
}<br>
....<br>
}<br>
getValueAt
to display pictures?
Answer the question
In order to leave comments, you need to log in
Return an ImageIcon or Icon ( link ).
By the way, this is a model, not a view, i.e. if you want some new rendering method (for example, for a picture from an array of bytes), then you need to expose a new TableCellRenderer in the view object (in the case of Swing, a JTable). Read more - here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question