Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1004993 // Try JTable with images [spike, works]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2688L/19K/64K).

1  
!752
2  
3  
p {
4  
  ImageIcon icon1 = imageIcon("#1004350");
5  
  ImageIcon icon2 = imageIcon("#1004351");
6  
  
7  
  String[] columnNames = {"Picture", "Description"};
8  
  Object[][] data = {
9  
    {icon1, "Bla 1"},
10  
    {icon2, "Bla 2"},
11  
  };
12  
13  
  DefaultTableModel model = new DefaultTableModel(data, columnNames);
14  
  JTable table = new JTable(model) {
15  
    //  Returning the Class of each column will allow different
16  
    //  renderers to be used based on Class.
17  
    //  Default to String if null
18  
    public Class getColumnClass(int column) {
19  
      return or(getValueAt(0, column).getClass(), S.class);
20  
    }
21  
  };
22  
  //table.setPreferredScrollableViewportSize(table.getPreferredSize());
23  
  table.setRowHeight(100);
24  
  
25  
  showFrame(table);
26  
}

Author comment

stuff taken from http://stackoverflow.com/questions/4941372/how-to-insert-image-into-jtable-cell

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004993
Snippet name: Try JTable with images [spike, works]
Eternal ID of this version: #1004993/1
Text MD5: ee7bcbb231f6aa0861ad203742e92add
Transpilation MD5: bc01bb5bc1a308f3c5fb51ac681a4589
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-14 01:04:29
Source code size: 739 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 552 / 615
Referenced in: [show references]