@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JButton b = new JButton( "<html><body>" + SwingTranslator.R("PPuse") + ":<i> " + value + "</i></body></html>"); return b; }
// intentionlaly not generic to avoid failue on systems without buffered image class private void waitForEnter(List l) { model.stop(); System.out.println(SwingTranslator.R("TuiPause")); int i = 0; while (true) { try { String s = br.readLine().trim(); s = s.toLowerCase(); if (s.startsWith("s")) { skip(); skip(); break; } if (s.startsWith("b")) { // hm not working:( back(); back(); back(); break; } if (s.startsWith("p")) { i--; if (i < 0) { i = 0; } } if (l != null && !l.isEmpty()) { if (s.startsWith("n")) { i++; if (i >= l.size()) { i = l.size() - 1; } } if (s.startsWith("n") || s.startsWith("p")) { ConsoleImageViewer.doJob((BufferedImage) l.get(i)); } } if (s.isEmpty()) { break; } } catch (Exception ex) { System.out.println(ex); break; } } model.go(); }
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BorderLayout()); this.setTitle(SwingTranslator.R("PPkp")); final JTable t = new JTable(); PluginlistProvider.LoadedPlugins l = PluginlistProvider.obtain(); List<PluginlistProvider.ParsedLine> r = l.getResult(); DefaultTableModel dt = new DefaultTableModel( new Object[] { SwingTranslator.R("PPstate"), SwingTranslator.R("PPdesc"), SwingTranslator.R("PPhomePage"), SwingTranslator.R("PPlink"), }, 0) { @Override public boolean isCellEditable(int row, int column) { return false; } }; for (PluginlistProvider.ParsedLine parsedLine : r) { dt.addRow( new Object[] { parsedLine.getState(), parsedLine.getDescription(), parsedLine.getHomePage().toExternalForm(), parsedLine.getUrl().toExternalForm(), }); } t.setModel(dt); t.getColumnModel().getColumn(0).setCellRenderer(new ColoredLabelRenderer()); t.getColumnModel().getColumn(2).setCellRenderer(new UnderscoredButtonRenderer()); t.getColumnModel().getColumn(3).setCellRenderer(new ButtonRenderer()); t.addMouseListener( new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { int row = t.rowAtPoint(evt.getPoint()); int col = t.columnAtPoint(evt.getPoint()); if (row >= 0 && col >= 0) { Object val = t.getValueAt(row, col); if (col == 2) { try { Desktop.getDesktop().browse(new URI((String) val)); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); } } if (col == 3) { master.setPluginUrl((String) val); KnownPlugins.this.setVisible(false); KnownPlugins.this.dispose(); } } } }); this.add(new JScrollPane(t)); this.add(new JLabel(l.getSource().getResolution()), BorderLayout.NORTH); pack(); }