Swing/InternalFrameLayoutTitlePaneAtOrigin のバックアップソース(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/InternalFrameLayoutTitlePaneAtOrigin へ行く。
- 1 (2022-10-24 (月) 03:57:12)
- 2 (2024-05-07 (火) 22:58:33)
--- category: swing folder: InternalFrameLayoutTitlePaneAtOrigin title: JInternalFrameのタイトルパネルをフレーム原点から描画する tags: [JInternalFrame, LookAndFeel, UIManager] author: aterai pubdate: 2022-10-24T03:44:45+09:00 description: JInternalFrameのタイトルパネルをフレーム原点から描画するかBorderを考慮した配置にするかを切り替えます。 image: https://drive.google.com/uc?id=1_RXTVB4CXv1uNAlIn03U3C2adWtAa1w1 --- * 概要 [#summary] JInternalFrameのタイトルパネルをフレーム原点から描画するかBorderを考慮した配置にするかを切り替えます。 #download(https://drive.google.com/uc?id=1_RXTVB4CXv1uNAlIn03U3C2adWtAa1w1) * サンプルコード [#sourcecode] #code(link){{ String key = "InternalFrame.layoutTitlePaneAtOrigin"; JDesktopPane desktop = new JDesktopPane(); boolean b = UIManager.getBoolean(key); JCheckBox check = new JCheckBox("InternalFrame TitlePane layout", b) { @Override public void updateUI() { super.updateUI(); boolean b = UIManager.getLookAndFeelDefaults().getBoolean(key); setSelected(b); UIManager.put(key, b); SwingUtilities.updateComponentTreeUI(desktop); } }; check.addActionListener(e -> { UIManager.put(key, ((JCheckBox) e.getSource()).isSelected()); SwingUtilities.updateComponentTreeUI(desktop); }); check.setOpaque(false); addFrame(desktop, 0, true); addFrame(desktop, 1, false); }} * 解説 [#explanation] - `BasicLookAndFeel`、`MetalLookAndFeel`、`MotifLookAndFeel`、`NimbusLookAndFeel`のデフォルトは`false` -- `MetalLookAndFeel`でこの設定を`true`にするとタイトルパネルが`JInternalFrame`の`Border`を考慮せずに原点から幅全体が描画されて不自然なレイアウトのタイトルパネルになってしまう -- `MotifLookAndFeel`でこの設定を`true`にするとタイトルパネルが`JInternalFrame`の`Border`を考慮せずに原点から幅全体を占めるようレイアウトされる -- `NimbusLookAndFeel`でこの設定を`true`にするとフレーム化されている場合は変化なしだが、アイコン化されている場合はその高さが変化する場合がある - `WindowsLookAndFeel`、`GTKLookAndFeel`のデフォルトは`true` -- `WindowsLookAndFeel`でこの設定を`false`にするとタイトルパネルが`JInternalFrame`の`Border`を考慮して縮小して描画されて不自然なレイアウトのタイトルパネルになってしまう -- `GTKLookAndFeel`でこの設定を`false`にするとタイトルパネルアイコンがタイトル文字列にかぶったり最大化、最小化、閉じるボタンが`JInternalFrame`の内側に移動して不自然なレイアウトのタイトルパネルになってしまう * 参考リンク [#reference] - [https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/plaf/basic/BasicInternalFrameUI.html#getNorthPane-- BasicInternalFrameUI#getNorthPane() (Java Platform SE 8)] * コメント [#comment] #comment #comment