Friday, 9 August 2013

Java - How to setEnabled() on paste Action?

Java - How to setEnabled() on paste Action?

I am doing my own Notepad in Java. Basic part is almost done. But i have
big problem with JMenuItem which pastes words to JTextPane. It
works(pasting), but i want that JMenuItem reacts:
when is something in memory(copy - from anywhere) => JMenuItem will be
setEnabled(true)
when isnt something in memory > JMenuItem will be setEnabled(false)
private static JMenuItem editPaste; // atribut
editPaste = new JMenuItem(new DefaultEditorKit.PasteAction()); //in
private method
I have no idea, what I should listened(listener of what??) for this
action. I did not see that
anywhere(http://docs.oracle.com/javase/tutorial/uiswing/components/generaltext.html).

No comments:

Post a Comment