use of org.concord.energy3d.util.ClipImage in project energy3d by concord-consortium.
the class EventString method showGui.
public void showGui() {
final JDialog dialog = new JDialog(MainFrame.getInstance(), "Event String", true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
final JPanel contentPane = new JPanel(new BorderLayout());
dialog.setContentPane(contentPane);
final JMenuBar menuBar = new JMenuBar();
dialog.setJMenuBar(menuBar);
final JMenu menu = new JMenu("Export");
menuBar.add(menu);
JMenuItem mi = new JMenuItem("Copy Colored String");
mi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
html.selectAll();
final ActionEvent ae = new ActionEvent(html, ActionEvent.ACTION_PERFORMED, "copy");
if (ae != null) {
html.getActionMap().get(ae.getActionCommand()).actionPerformed(ae);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "The string is now ready for pasting.", "Copy String", JOptionPane.INFORMATION_MESSAGE);
html.select(0, 0);
}
}
});
menu.add(mi);
mi = new JMenuItem("Copy Plain String");
mi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(eventString), null);
JOptionPane.showMessageDialog(MainFrame.getInstance(), "The string is now ready for pasting.", "Copy String", JOptionPane.INFORMATION_MESSAGE);
}
});
menu.add(mi);
mi = new JMenuItem("Copy Image");
mi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
new ClipImage().copyImageToClipboard(EventString.this);
}
});
menu.add(mi);
final JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
contentPane.add(panel, BorderLayout.CENTER);
panel.add(this, BorderLayout.CENTER);
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
contentPane.add(buttonPanel, BorderLayout.SOUTH);
final JButton button = new JButton("Close");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
dialog.dispose();
}
});
buttonPanel.add(button);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
dialog.dispose();
}
});
dialog.pack();
dialog.setLocationRelativeTo(MainFrame.getInstance());
dialog.setVisible(true);
}
Aggregations