2015-06-01 09:35:51 +00:00
|
|
|
package com.bytezone.diskbrowser.gui;
|
|
|
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.awt.event.KeyEvent;
|
2019-08-08 10:01:56 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2015-06-01 09:35:51 +00:00
|
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
|
import javax.swing.Action;
|
|
|
|
import javax.swing.JMenuItem;
|
|
|
|
import javax.swing.JTextArea;
|
|
|
|
import javax.swing.KeyStroke;
|
|
|
|
|
|
|
|
class LineWrapAction extends AbstractAction
|
|
|
|
{
|
2019-08-08 10:01:56 +00:00
|
|
|
List<JTextArea> listeners = new ArrayList<> ();
|
2015-06-01 09:35:51 +00:00
|
|
|
|
2019-08-08 10:01:56 +00:00
|
|
|
public LineWrapAction ()
|
2015-06-01 09:35:51 +00:00
|
|
|
{
|
|
|
|
super ("Line wrap");
|
|
|
|
putValue (Action.SHORT_DESCRIPTION, "Print the contents of the output panel");
|
|
|
|
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt W"));
|
|
|
|
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_W);
|
|
|
|
}
|
|
|
|
|
2019-08-08 10:01:56 +00:00
|
|
|
public void addListener (JTextArea listener)
|
|
|
|
{
|
|
|
|
if (!listeners.contains (listener))
|
|
|
|
listeners.add (listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-06-01 09:35:51 +00:00
|
|
|
public void actionPerformed (ActionEvent e)
|
|
|
|
{
|
2019-08-08 10:01:56 +00:00
|
|
|
for (JTextArea listener : listeners)
|
|
|
|
listener.setLineWrap (((JMenuItem) e.getSource ()).isSelected ());
|
2015-06-01 09:35:51 +00:00
|
|
|
}
|
|
|
|
}
|