Swing/PinTabbedPane のバックアップ差分(No.1)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/PinTabbedPane へ行く。
- 1 (2011-12-05 (月) 14:18:41)
- 2 (2011-12-05 (月) 17:45:02)
- 3 (2012-12-14 (金) 13:48:12)
- 4 (2012-12-15 (土) 04:28:59)
- 5 (2014-12-09 (火) 21:06:19)
- 6 (2016-03-10 (木) 15:21:32)
- 7 (2017-07-21 (金) 13:40:25)
- 8 (2018-07-20 (金) 16:50:01)
- 9 (2018-10-30 (火) 16:35:46)
- 10 (2020-10-30 (金) 02:00:29)
- 11 (2022-08-30 (火) 21:05:22)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:JTabbedPaneのタブを固定する #navi(../) RIGHT:Posted by [[aterai]] at 2011-12-05 *JTabbedPaneのタブを固定する [#j14c1072] JTabbedPaneにJPopupMenuを追加して、指定したタブのタイトルと位置を変更し、タブの固定を行います。 -&jnlp; -&jar; -&zip; //#screenshot #ref(https://lh4.googleusercontent.com/-QqKPFV0ZzIc/TttWYFUshII/AAAAAAAABFk/6HcCBI_bg-0/s800/PinTabbedPane.png) **サンプルコード [#k9852cde] #code{{ JCheckBoxMenuItem pinTabMenuItem = new JCheckBoxMenuItem(new AbstractAction("pin tab") { @Override public void actionPerformed(ActionEvent e) { JTabbedPane t = (JTabbedPane)getInvoker(); JCheckBoxMenuItem check = (JCheckBoxMenuItem)e.getSource(); int idx = t.getSelectedIndex(); Component cmp = t.getComponentAt(idx); Component tab = t.getTabComponentAt(idx); Icon icon = t.getIconAt(idx); String tip = t.getToolTipTextAt(idx); boolean flg = t.isEnabledAt(idx); int i; if(check.isSelected()) { for(i=0;i<idx;i++) { String s = t.getTitleAt(i); if(s==null || s.length()==0) continue; break; } }else{ for(i=t.getTabCount()-1;i>idx;i--) { String s = t.getTitleAt(i); if(s!=null && s.length()>0) continue; break; } } t.remove(idx); t.insertTab(check.isSelected()?"":tip, icon, cmp, tip, i); t.setTabComponentAt(i, tab); t.setEnabledAt(i, flg); if(flg) t.setSelectedIndex(i); } }); }} **解説 [#yfe02b48] - タブを固定 -- タブタイトルを空にする -- タブの位置を左に移動 -- 固定したタブは削除しない - タブの固定を解除 -- タブタイトルをTooltipTextから復元する -- タブの位置を固定されていないタブの右側に移動 - 注 -- TabPlacement: LEFT, RIGHT は考慮していない //**参考リンク **コメント [#bdee84c0] #comment