Swing/AuxiliaryLookAndFeel のバックアップソース(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/AuxiliaryLookAndFeel へ行く。
- 1 (2012-04-09 (月) 14:26:00)
- 2 (2012-12-12 (水) 19:10:43)
- 3 (2014-11-01 (土) 00:46:09)
- 4 (2014-12-11 (木) 15:00:56)
- 5 (2015-05-21 (木) 19:40:31)
- 6 (2016-06-14 (火) 20:09:15)
- 7 (2016-06-30 (木) 18:52:34)
- 8 (2017-04-04 (火) 14:13:45)
- 9 (2017-09-24 (日) 15:22:21)
- 10 (2017-11-02 (木) 15:34:40)
- 11 (2019-03-15 (金) 17:17:38)
- 12 (2019-05-22 (水) 19:35:38)
- 13 (2021-01-01 (金) 17:25:01)
- 14 (2022-08-20 (土) 22:15:25)
- 15 (2022-10-21 (金) 11:54:59)
TITLE:AuxiliaryLookAndFeelを追加する #navi(../) RIGHT:Posted by [[aterai]] at 2012-04-09 *AuxiliaryLookAndFeelを追加する [#ua0f3e60] AuxiliaryLookAndFeelを追加して、WindowsLookAndFeelの場合の動作を変更します。 -&jnlp; -&jar; -&zip; //#screenshot #ref(https://lh4.googleusercontent.com/-SxIyCqWRFhk/T4JxXw96NSI/AAAAAAAABLQ/gM_5mjZPn1o/s800/AuxiliaryLookAndFeel.png) **サンプルコード [#lc13bf97] #code{{ JCheckBox check = (JCheckBox)e.getSource(); String lnf = UIManager.getLookAndFeel().getName(); if(check.isSelected() && lnf.contains("Windows")) { UIManager.addAuxiliaryLookAndFeel(auxLookAndFeel); }else{ UIManager.removeAuxiliaryLookAndFeel(auxLookAndFeel); } SwingUtilities.updateComponentTreeUI(MainPanel.this); }} **解説 [#r33184aa] WindowsLookAndFeelの場合、JComboBoxのドロップダウンリストで右クリックを無効にするようなBomboBoxUIを追加しています。 #code{{ public class AuxiliaryWindowsComboBoxUI extends WindowsComboBoxUI { public static ComponentUI createUI(JComponent c) { return new AuxiliaryWindowsComboBoxUI(); } @Override protected ComboPopup createPopup() { return new BasicComboPopup2(comboBox); } @Override public void addEditor() { removeEditor(); ComboBoxEditor cbe = comboBox.getEditor(); if(cbe != null) { editor = cbe.getEditorComponent(); if(editor != null) { configureEditor(); comboBox.add(editor); if(comboBox.isFocusOwner()) { editor.requestFocusInWindow(); } } } } //Override all UI-specific methods your UI classes inherit. @Override public void removeEditor() {} @Override protected void configureEditor() {} @Override protected void unconfigureEditor() {} @Override public void update(Graphics g, JComponent c) {} @Override public void paint(Graphics g, JComponent c) {} //... }} - 注 -- LookAndFeelをNimbusにするとClassCastExceptionが発生する --- [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6631956 Bug ID: 6631956 Nimbus: ClassCastException when running with MultiLookAndFeel] -- UIManager.addPropertyChangeListener(new PropertyChangeListener() {...});を追加して、WindowsLookAndFeel以外の場合は、UIManager.removeAuxiliaryLookAndFeel(auxLookAndFeel); -- 編集可能なJComboBoxの場合、NullPointerExceptionが発生する ---WindowsComboBoxUI#addEditor()をオーバーライド **参考リンク [#ybc6bf3b] - [http://docs.oracle.com/javase/7/docs/api/javax/swing/plaf/multi/doc-files/multi_tsc.html Using the Multiplexing Look and Feel] **コメント [#nd54a516] #comment