posted 17 years ago
Hi Ranchers,
I have a JTabbedPane with 5 JPanels added to it. Each JPanel has its own components like text field, TextArea , JTable etc....
I am trying to implement Cut, Copy, Paste functionality for all these Jpanels. Ctrl+x, Ctrl+v, ctrl+c works fine as it is inbuilt with windows but when i try to implement with event hadler i am facing the problem.
i6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent h)
{
JScrollPane scrollPane = (JScrollPane)p1.getSelectedComponent();
JTextPane textPane = (JTextPane)scrollPane.getViewport().getView();
textPane.copy();
}
});
would work fine provided JScrollPane is the only component in th my JPanel but that is not the case how do i find out what is the component he is copying from(may be TextArea, JTable, etc)..
Otherway i tried is using getText() method that is there in textArea but again the same proble comes that is textArea is not the only component in my JPanel.
In short i would like to copy everything that is selected by the mouse irespective of the component.
Please help me.