Hi Janak,
thank you for your hints, I could solve with this all my
requests.

to focus the previous component with ctrl+tab from ulctextarea i
did the following:
            Set backwardTraversalKeys = new HashSet();

backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
java.awt.event.KeyEvent.SHIFT_DOWN_MASK));

getBasicTextArea().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
 backwardTraversalKeys);
the similar way like your example:
....
      InputMap im = text.getInputMap(JTextArea.WHEN_FOCUSED);
             KeyStroke tabForward =
KeyStroke.getKeyStroke(KeyEvent.VK_TAB
,java.awt.event.KeyEvent.SHIFT_DOWN_MASK);
             Action tabAction = new TabAction();
             table.getActionMap().put(im.get(tab),
tabAction);......
 did not work, because the actionperformed-Event did not fire,
but anyway it's running with the code above.
-------
for ulctable i did the same
----------
to disable the pageUp/down key from ulctextarea i did the
following:
            InputMap map = (InputMap)
UIManager.get("TextArea.focusInputMap");
            javax.swing.KeyStroke keyStrokePageUp =
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_UP,
 0);
            map.remove(keyStrokePageUp);
            javax.swing.KeyStroke keyStrokePageDown =
javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_DOWN,
 0);
            map.remove(keyStrokePageDown);
with this i have the right behaviour to scroll the whole
scrollpane and not the ulctextarea.
------------
"
>Is there a property or sth like this to scroll a scrollpane
>automatically down when the user goes down the page by tab?"
With this i have this behaviour:

ULCComponent.addFocusListener(new
com.ulcjava.base.application.event.IFocusListener() {
      public void
focusGained(com.ulcjava.base.application.event.FocusEvent e) {
                  ULCComponent.scrollToVisible();

      }
      public void
focusLost(com.ulcjava.base.application.event.FocusEvent e) {
      }
});

Thanks and Greetings,
Marco




                                                                 
             "Janak                                              
             Mulani"                                             
             <janak.mulani                                    An 
             @canoo.com>            <[EMAIL PROTECTED]>   
                                                           Kopie 
             09.03.2007             <[EMAIL PROTECTED] 
             21:25                  om>                          
                                                           Thema 
                                    RE: [ULC-developer] textarea 
                 Bitte              focustraversalkeys           
             antworten an           valueChangedEvent ,          
             <ulc-develope          scrollpane autoscroll        
             [EMAIL PROTECTED]                                       
                 .com>                                           
                                                                 
                                                                 
                                                                 
                                                                 




Hi Marco,

>Has anybody an advice for my previous problem?
>http://lists.canoo.com/mailman/private/ulc-developer/2007/005345.html


>I want to leave the textarea with tab instead of using ctrl+tab,

>Is there a way to disable the page up/down keys for the
textarea,

For all of the above, see the snippet below.

>Is there a way to disable the page up/down keys for the
textarea,
>because i want to scroll always the whole pane and not the
>textarea.

>Is there a property or sth like this to scroll a scrollpane
>automatically down when the user goes down the page by tab?

Please explain the above.

Thanks and regards,

Janak


>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of
>[EMAIL PROTECTED]
>Sent: Thursday, March 01, 2007 10:59 AM
>To: [email protected]
>Subject: [ULC-developer] textarea focustraversalkeys
valueChangedEvent ,
>scrollpane autoscroll
>
>
>
>Hi all,
>i have another navigation problem:
>
>I want to leave the textarea with tab instead of using ctrl+tab,
>therefore i have implemented following client-extension:
>
>public class UIDachBasicTextArea extends UITextArea {
>
>      protected Object createBasicObject(Object [] args){
>
>
>          return new DachBasicTextArea();
>      }
>
>      protected void postInitializeState(){
>
>            //leave textarea ONLY with tab or shift-tab
>
>getBasicTextArea().setFocusTraversalKeys(KeyboardFocusManager.FORWA

>RD_TRAVERSAL_KEYS,
> null);
>
>getBasicTextArea().setFocusTraversalKeys(KeyboardFocusManager.BACKW

>ARD_TRAVERSAL_KEYS,
> null);
>      }
>
>      public class DachBasicTextArea extends BasicTextArea{
>
>            public DachBasicTextArea() {
>                  super();
>                  // TODO Auto-generated constructor stub
>            }
>      }
>}
>
>The problem is that the valueChangedEvent is not fireing
anymore.
>has anybody a suggestion?
>
>Is there a way to disable the page up/down keys for the
textarea,
>because i want to scroll always the whole pane and not the
>textarea.
>
>Has anybody an advice for my previous problem?
>http://lists.canoo.com/mailman/private/ulc-developer/2007/005345.html

>
>Is there a property or sth like this to scroll a scrollpane
>automatically down when the user goes down the page by tab?
>
>Thx and greetings
>marco
-----------------------------
package tabkeyintable;

import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.InputMap;
import javax.swing.JScrollBar;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCComponent;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.ULCTextArea;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.event.IListSelectionListener;
import com.ulcjava.base.application.event.IValueChangedListener;
import com.ulcjava.base.application.event.ListSelectionEvent;
import com.ulcjava.base.application.event.ValueChangedEvent;
import com.ulcjava.base.application.table.DefaultTableModel;
import com.ulcjava.base.application.table.ITableModel;
import com.ulcjava.base.client.UITable;
import com.ulcjava.base.client.UITextArea;
import com.ulcjava.base.development.DevelopmentRunner;

public class DisableTabInTableAndTextAreaSnippet extends
AbstractApplication
{

    protected ULCComponent createContent() {
        ULCTable table = new MyULCTable(new DefaultTableModel(new
Object[][]
{ { "0", "0" }, { "1", "1" } },
                new String[] { "Col1", "Col2" }));
        table.addActionListener(new IActionListener() {
            public void actionPerformed(ActionEvent event) {
                System.out.println("Action event");
            }
        });


table.getColumnModel().getSelectionModel().addListSelectionListener(

new IListSelectionListener() {
            public void valueChanged(ListSelectionEvent event) {
                System.out.println("Selection event");
            }
        });

        ULCScrollPane spane = new ULCScrollPane(table);
        return spane;
    }

    public void start() {
        ULCFrame frame = new
ULCFrame("ULCTableFocusGainedSnippet");

frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);

        ULCBoxPane content = new ULCBoxPane(true);

        ULCButton but1 = new ULCButton("Button1");
        content.add(ULCBoxPane.BOX_CENTER_TOP, but1);
        content.add(ULCBoxPane.BOX_EXPAND_EXPAND,
createContent());

        ULCTextArea textArea = new MyULCTextArea();
        textArea.addValueChangedListener(new
IValueChangedListener() {
            public void valueChanged(ValueChangedEvent event) {
                System.out.println("Value Changed");
            }
        });
        ULCScrollPane textScroll = new ULCScrollPane(textArea);
        content.add(ULCBoxPane.BOX_EXPAND_EXPAND, textScroll);
        frame.add(content);
        frame.setSize(200, 300);
        frame.setVisible(true);
    }

    public static void main(String[] args) {

DevelopmentRunner.setApplicationClass(DisableTabInTableAndTextAreaSn

ippet.class);
        DevelopmentRunner.main(args);
    }

    public static class MyULCTable extends ULCTable {
        public MyULCTable(ITableModel model) {
            super(model);
        }

        protected String typeString() {
            return MyUITable.class.getName();
        }
    }

    public static class MyUITable extends UITable {
        protected void postInitializeState() {
            super.postInitializeState();

            JTable table = getBasicTable();
            table.setFocusTraversalKeysEnabled(true);

            InputMap im =
table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
            KeyStroke tab =
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
            Action tabAction = new TabAction();
            table.getActionMap().put(im.get(tab), tabAction);
        }

        public static class TabAction extends AbstractAction {
            public TabAction() {
                super();
            }

            public void
actionPerformed(java.awt.event.ActionEvent e) {
                JTable table = (JTable)e.getSource();
                Container cycleRoot =
table.getFocusCycleRootAncestor();
                FocusTraversalPolicy policy =
table.getFocusTraversalPolicy();
                if (policy == null && cycleRoot != null) {
                    policy = cycleRoot.getFocusTraversalPolicy();
                }

                Component target =
policy.getComponentAfter(cycleRoot,
table);

                if (target != null)
                    target.requestFocusInWindow();
            }
        }
    }

    public static class MyULCTextArea extends ULCTextArea {
        protected String typeString() {
            return MyUITextArea.class.getName();
        }
    }

    public static class MyUITextArea extends UITextArea {
        protected void postInitializeState() {
            super.postInitializeState();

            JTextArea text = getBasicTextArea();
            text.setFocusTraversalKeysEnabled(true);

            InputMap im =
text.getInputMap(JTextArea.WHEN_FOCUSED);
            KeyStroke tab =
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
            KeyStroke pgup =
KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0);
            KeyStroke pgdn =
KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN,
0);

            Action tabAction = new TextTabAction();
            text.getActionMap().put(im.get(tab), tabAction);

            text.getActionMap().put(im.get(pgup), new
AbstractAction() {
                public void
actionPerformed(java.awt.event.ActionEvent e) {
                }
            });
            text.getActionMap().put(im.get(pgdn), new
AbstractAction() {
                public void
actionPerformed(java.awt.event.ActionEvent e) {
                }
            });
        }

        public static class TextTabAction extends AbstractAction
{

            public TextTabAction() {
                super();
            }

            public void
actionPerformed(java.awt.event.ActionEvent e) {
                JTextArea text = (JTextArea)e.getSource();
                Container cycleRoot =
text.getFocusCycleRootAncestor();
                FocusTraversalPolicy policy =
text.getFocusTraversalPolicy();
                if (policy == null && cycleRoot != null) {
                    policy = cycleRoot.getFocusTraversalPolicy();
                }

                Component target =
policy.getComponentAfter(cycleRoot,
text);

                while ((target instanceof JScrollBar)) {
                    target = policy.getComponentAfter(cycleRoot,
target);
                }
                if (target != null)
                    target.requestFocusInWindow();
            }
        }
    }
}





_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to