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).

!752

p {
  ImageIcon icon1 = imageIcon("#1004350");
  ImageIcon icon2 = imageIcon("#1004351");
  
  String[] columnNames = {"Picture", "Description"};
  Object[][] data = {
    {icon1, "Bla 1"},
    {icon2, "Bla 2"},
  };

  DefaultTableModel model = new DefaultTableModel(data, columnNames);
  JTable table = new JTable(model) {
    //  Returning the Class of each column will allow different
    //  renderers to be used based on Class.
    //  Default to String if null
    public Class getColumnClass(int column) {
      return or(getValueAt(0, column).getClass(), S.class);
    }
  };
  //table.setPreferredScrollableViewportSize(table.getPreferredSize());
  table.setRowHeight(100);
  
  showFrame(table);
}

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: 648 / 728
Referenced in: #1004996 - Try JTable with images 2 [using fillTableWithData, works]