/** * Copies the text of the output log to the clipboard. * * @param area The text area of the output log. */ public static void copy(final JTextArea area) { final String selectedText = area.getSelectedText(); if (selectedText == null) { ClipboardHelpers.copyToClipboard(area.getText()); } else { ClipboardHelpers.copyToClipboard(selectedText); } }
@Override public void actionPerformed(final ActionEvent event) { final int[] rows = table.getSelectedRows(); final int cols = table.getColumnCount(); final int[] maximums = new int[cols]; for (final int row : rows) { for (int i = 0; i < cols; i++) { if (table.getValueAt(row, i) != null) { final int maximum = table.getValueAt(row, i).toString().length(); if (maximum > maximums[i]) { maximums[i] = maximum; } } } } final StringBuffer sb = new StringBuffer(); for (final int row : rows) { for (int i = 0; i < cols; i++) { if (table.getValueAt(row, i) != null) { final String value = table.getValueAt(row, i).toString(); final int differenceToMaximum = maximums[i] - value.length(); sb.append(value); sb.append(Strings.repeat(" ", differenceToMaximum)); if (i != (cols - 1)) { sb.append(" "); } } } sb.append("\n"); } ClipboardHelpers.copyToClipboard(sb.toString()); }
@Override public void actionPerformed(final ActionEvent event) { ClipboardHelpers.copyToClipboard(m_value); }