| Author |
Help With JTabbed Pane
|
Abdul Hameed
Greenhorn
Joined: Dec 28, 2006
Posts: 1
|
|
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.
|
 |
Craig Wood
Ranch Hand
Joined: Jan 14, 2004
Posts: 1535
|
|
For an easy way see the menu code and discussion for the DragPictureDemo2 example in the How to Use Drag and Drop and Data Transfertutorial: last section Adding Cut/Copy/Paste Support. If you decide to do it on your own you might consider the TextAction class. It has a handy getFocusedComponent method that returns the focused JTextComponent.
|
 |
 |
|
|
subject: Help With JTabbed Pane
|
|
|