Search in sources :

Example 11 with ClipImage

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);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) ClipImage(org.concord.energy3d.util.ClipImage) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) StringSelection(java.awt.datatransfer.StringSelection) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) JMenuItem(javax.swing.JMenuItem) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

ActionEvent (java.awt.event.ActionEvent)11 ActionListener (java.awt.event.ActionListener)11 JMenuItem (javax.swing.JMenuItem)11 ClipImage (org.concord.energy3d.util.ClipImage)11 JMenu (javax.swing.JMenu)10 BorderLayout (java.awt.BorderLayout)8 FlowLayout (java.awt.FlowLayout)8 WindowAdapter (java.awt.event.WindowAdapter)8 WindowEvent (java.awt.event.WindowEvent)8 JButton (javax.swing.JButton)8 JDialog (javax.swing.JDialog)8 JMenuBar (javax.swing.JMenuBar)8 JPanel (javax.swing.JPanel)8 ItemEvent (java.awt.event.ItemEvent)5 ItemListener (java.awt.event.ItemListener)5 MenuEvent (javax.swing.event.MenuEvent)5 MenuListener (javax.swing.event.MenuListener)5 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)4 HashMap (java.util.HashMap)3 OperationEvent (org.concord.energy3d.agents.OperationEvent)3