N
N
Nikita Kolosov2012-05-24 14:52:50
Java
Nikita Kolosov, 2012-05-24 14:52:50

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>


How can I edit getValueAtto display pictures?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serso, 2012-05-24
@Anexroid

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 question

Ask a Question

731 491 924 answers to any question