Here is the .gif handler
Here is the initial.png
Here is the conclusion
Here is the code. processing.gif works elsewhere, such as on a tab JTabbedPane. Here in column a JTableit is not displayed. Any explanations and solutions? processing.gif is a moving icon indicating that something is loading.
JTabbedPane
JTable
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); } }
Animated gifs by default do not work in JTable. But there is an easy way to fix this, use the class AnimatedIconthat can be found here
AnimatedIcon
, Icon, , , gif , .
Icon
, ImageObserver , gif, .
, GIF JTable, , , . , JTabbedPane. TableIcon:
TableIcon
getContentPane().add(new JLabel(processing), BorderLayout.SOUTH);
: GIF . GIF . , . , , , ( TableIcon):
final Timer animationTimer = new Timer(100, e -> table.repaint()); animationTimer.start();
Source: https://habr.com/ru/post/1584550/More articles:JavaFx ObservableList sorted() vs sorted (Comparator. naturalOrder()) - javaScale Height Data Scale - c #Random number generation in parallel programs - pythonSetting the width in a series of columns: using dotNetCharting - c #Long Look notification: dynamic interface not showing, only static interface - iosChecking the types of infix operators in the compiler - compiler-constructionController initialization logic doesn't hit when user returns - javascriptChecking passwords at user login - c ++Python Authomatic with local user / user database? - pythonJava Jersey HTTPS GET request with authentication header - javaAll Articles