List of usage examples for javax.swing AbstractListModel AbstractListModel
AbstractListModel
From source file:org.signserver.admin.gui.ViewCertificateFrame.java
private void viewCertificate(final X509Certificate certificate) { this.certificate = certificate; if (certificate == null) { fields = null;//from w w w. j a va 2 s .c o m } else { fields = new ArrayList<Field>(); fields.add(new Field("Version", String.valueOf(certificate.getVersion()))); fields.add(new Field("Serial Number", certificate.getSerialNumber().toString(16))); fields.add(new Field("Certificate Signature Algorithm", String.valueOf(certificate.getSigAlgName()))); fields.add(new Field("Issuer", String.valueOf(certificate.getIssuerDN()))); fields.add(new Field("Validity Not Before", String.valueOf(certificate.getNotBefore()))); fields.add(new Field("Validity Not After", String.valueOf(certificate.getNotAfter()))); fields.add(new Field("Subject", String.valueOf(certificate.getSubjectDN()))); fields.add(new Field("Subject Public Key Algorithm", String.valueOf(certificate.getPublicKey().getAlgorithm()))); fields.add(new Field("Subject's Public Key", new String(Hex.encode(certificate.getPublicKey().getEncoded())))); if (certificate.getCriticalExtensionOIDs() != null) { for (String extensionOid : certificate.getCriticalExtensionOIDs()) { fields.add(new Field("Critical extension: " + extensionOid, "<Not supported yet>")); } } if (certificate.getNonCriticalExtensionOIDs() != null) { for (String extensionOid : certificate.getNonCriticalExtensionOIDs()) { fields.add(new Field("Non critical extension: " + extensionOid, "<Not supported yet>")); } } fields.add(new Field("Certificate Signature Algorithm", String.valueOf(certificate.getSigAlgName()))); fields.add( new Field("Certificate Signature Value", new String(Hex.encode(certificate.getSignature())))); fieldsList.setModel(new AbstractListModel() { @Override public int getSize() { return fields.size(); } @Override public Object getElementAt(int index) { return fields.get(index); } }); } }
From source file:fs.MainWindow.java
public void GenerateTable(Object[][] data, String title, String subtitle, final String[] titles) { JFrame window = new JFrame(title); window.setLayout(new java.awt.BorderLayout(5, 5)); JLabel label = new JLabel(subtitle); label.setFont(new java.awt.Font("Tahoma", 1, 12)); label.setForeground(new java.awt.Color(0, 0, 255)); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setOpaque(true);/*from ww w . ja v a2 s. co m*/ label.setPreferredSize(new java.awt.Dimension(50, 30)); ListModel lm = new AbstractListModel() { String headers[] = titles; @Override public int getSize() { return headers.length; } @Override public Object getElementAt(int index) { return headers[index]; } }; // String[] titles = getClasses(); JList rowHeader = new JList(lm); rowHeader.setFixedCellWidth(50); JTable jTable = new JTable(data, titles); rowHeader.setFixedCellHeight(jTable.getRowHeight()); rowHeader.setCellRenderer(new RowHeaderRenderer(jTable)); JScrollPane scroll = new JScrollPane(jTable); scroll.setRowHeaderView(rowHeader); getContentPane().add(scroll, BorderLayout.CENTER); jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTable.setAlignmentX(JTable.CENTER_ALIGNMENT); window.add(label, java.awt.BorderLayout.NORTH); window.add(scroll, java.awt.BorderLayout.CENTER); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); window.setBounds((screenSize.width - 800) / 2, (screenSize.height - 270) / 2, 800, 270); window.setVisible(true); }