【发布时间】:2015-07-03 11:30:16
【问题描述】:
这是处理中的.gif
这里是initial.png
这是输出
这里是代码。 processing.gif 正在其他位置工作,例如在JTabbedPane 的选项卡中。在JTable 的列中,它没有显示。有什么解释和解决办法吗? processing.gif 是一个移动图标,表示正在加载某些内容。
import javax.swing.*;
import javax.swing.table.*;
public class TableIcon extends JFrame
{
public TableIcon()
{
ImageIcon initial = new ImageIcon(getClass().getResource("initial.png"));
ImageIcon processing = new ImageIcon(getClass().getResource("processing.gif"));
String[] columnNames = {"Picture", "Description"};
Object[][] data =
{
{initial, "initial"},
{processing, "processing"}
};
DefaultTableModel model = new DefaultTableModel(data, columnNames);
JTable table = new JTable( model )
{
public Class getColumnClass(int column)
{
return getValueAt(0, column).getClass();
}
};
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane( table );
getContentPane().add( scrollPane );
}
public static void main(String[] args)
{
TableIcon frame = new TableIcon();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.pack();
frame.setVisible(true);
}
}
【问题讨论】:
-
当然,正如我所说,它在 JTabbedPane 中工作
-
intial.png 正在显示,它与 processing.gif 位于同一位置。这不是这里的问题。我很困惑为什么不能在 JTable 中显示移动的 .gif
-
附上图片
-
你可以下载上图试试
标签: swing user-interface jtable icons gif