private void doRowData() { tableModel.removeAllRows(); for (int i = 0, j = font.getStartIndex(); i < font.getCharCount(); i++, j++) { FontCharacter fc = font.getCharacter(i); String hexVal = (Integer.toHexString(j)).toUpperCase(); if (hexVal.length() == 1) hexVal = "0" + hexVal; String asciiC = ""; if (j >= 32 && j < 127) { asciiC = "" + (char) j; } Object[] tableData = {"" + j, "0x" + hexVal, asciiC, "" + fc.getWidth(), fc.getComment()}; tableModel.addRow(tableData); } charTable.setRowSelectionInterval(0, 0); }
public CharTable(Font font, FontEditor parent) { this.font = font; this.parent = parent; popup = new CharTablePopupMenu(this); columnModel = new DefaultTableColumnModel(); TableColumn num = new TableColumn(0, 30); num.setHeaderValue("Dec"); columnModel.addColumn(num); TableColumn hex = new TableColumn(1, 35); hex.setHeaderValue("Hex"); columnModel.addColumn(hex); TableColumn ascii = new TableColumn(2, 37); ascii.setHeaderValue("ASCII"); columnModel.addColumn(ascii); TableColumn width = new TableColumn(3, 37); width.setHeaderValue("Width"); columnModel.addColumn(width); TableColumn desc = new TableColumn(4, 93); desc.setHeaderValue("Comment"); columnModel.addColumn(desc); tableModel = new CharTableModel(); tableModel.setColumnCount(5); charTable = new JTable(tableModel, columnModel); charTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); charTable.setMinimumSize(new Dimension(225, 100)); charTable.addKeyListener(this); charTable.addMouseListener(this); charTable.addPropertyChangeListener(this); doRowData(); }