use of jmri.jmrit.mailreport.ReportContext in project JMRI by JMRI.
the class ReportContextAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent ev) {
// JmriJFrame to ensure fits on screen
final JFrame frame = new JmriJFrame(Bundle.getMessage("TitleContext"));
final Clipboard clipboard = frame.getToolkit().getSystemClipboard();
pane = new JTextArea();
// add a little space at top
pane.append("\n");
pane.setEditable(false);
pane.setLineWrap(true);
pane.setWrapStyleWord(true);
pane.setColumns(120);
JScrollPane scroll = new JScrollPane(pane);
frame.add(scroll, BorderLayout.CENTER);
ReportContext r = new ReportContext();
addString(r.getReport(true));
// add a little space at bottom
pane.append("\n");
// Add button to allow copy to clipboard
JPanel p = new JPanel();
JButton copy = new JButton(Bundle.getMessage("ButtonCopyClip"));
copy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
StringSelection text = new StringSelection(pane.getText());
clipboard.setContents(text, text);
}
});
p.add(copy);
JButton close = new JButton(Bundle.getMessage("ButtonClose"));
close.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
frame.setVisible(false);
frame.dispose();
}
});
p.add(close);
frame.add(p, BorderLayout.SOUTH);
frame.pack();
// start scrolled to top
pane.setCaretPosition(0);
JScrollBar b = scroll.getVerticalScrollBar();
b.setValue(b.getMaximum());
// show
frame.setVisible(true);
}
Aggregations