Swing/KeyBinding のバックアップ差分(No.3)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/KeyBinding へ行く。
- 1 (2008-08-18 (月) 11:17:11)
- 2 (2008-08-18 (月) 13:33:02)
- 3 (2008-08-19 (火) 12:09:32)
- 4 (2008-09-03 (水) 01:13:27)
- 5 (2011-06-03 (金) 13:32:20)
- 6 (2012-09-05 (水) 23:14:11)
- 7 (2013-11-02 (土) 01:11:59)
- 8 (2015-01-20 (火) 15:42:21)
- 9 (2016-04-27 (水) 17:43:53)
- 10 (2017-03-30 (木) 14:06:49)
- 11 (2017-04-04 (火) 14:17:08)
- 12 (2018-03-09 (金) 13:14:04)
- 13 (2018-09-26 (水) 13:52:43)
- 14 (2020-09-26 (土) 17:31:01)
- 15 (2022-05-26 (木) 16:22:04)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:JComponentのKeyBinding一覧を取得する #navi(../) *JComponentのKeyBinding一覧を取得する [#cb69954b] Posted by [[terai]] at 2008-08-18 #contents **概要 [#g0619870] JComponentから、ActionMap、InputMapを取得し、KeyBindingの一覧表を作成します。[[Mapper.java>ftp://ftp.oreilly.de/pub/examples/english_examples/jswing2/code/goodies/Mapper.java]]を改変しています。 JComponentから、ActionMap、InputMapを取得し、KeyBindingの一覧表を作成します。[[Mapper.java>ftp://ftp.oreilly.de/pub/examples/english_examples/jswing2/code/goodies/Mapper.java]]をベースにしてUIを変更しています。 -&jnlp; -&jar; -&zip; #screenshot **サンプルコード [#a816ad41] #code{{ final List<Integer> focusType = Arrays.asList( JComponent.WHEN_FOCUSED, JComponent.WHEN_IN_FOCUSED_WINDOW, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); table.setAutoCreateRowSorter(true); JPanel p = new JPanel(new GridLayout(2,1,5,5)); p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); p.add(componentChoices); p.add(new JButton(new AbstractAction("show") { public void actionPerformed(ActionEvent e) { model.setRowCount(0); JComponent c = ((JComponentType)componentChoices.getSelectedItem()).component; for(Integer f:focusType) { loadBindingMap(f, c.getInputMap(f), c.getActionMap()); } } })); }} **解説 [#i5cf507a] 上記のサンプルでは、JComboBoxで選択されたコンポーネントに割り当てられているデフォルトのKeyBindingを、JTableに表示することができます。 **参考リンク [#md8e3446] - [[Mapper.java>ftp://ftp.oreilly.de/pub/examples/english_examples/jswing2/code/goodies/Mapper.java]] - [[How to Use Key Bindings (The Java™ Tutorials)>http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]] **コメント [#icc0b15a] - properties.xml の、compile.source を1.5にして、MainPanel.java の table.setAutoCreateRowSorter(true); をコメントアウトすれば、JDK 1.5 でも動作するはず。 -- [[terai]] &new{2008-08-18 (月) 11:17:11}; #comment