Swing/TabbedPaneWithText のバックアップ差分(No.8)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/TabbedPaneWithText へ行く。
- 1 (2005-12-26 (月) 12:36:53)
- 2 (2006-01-06 (金) 05:07:45)
- 3 (2006-02-27 (月) 16:57:08)
- 4 (2007-03-05 (月) 01:54:21)
- 5 (2007-09-27 (木) 01:20:23)
- 6 (2007-10-23 (火) 17:09:12)
- 7 (2011-05-05 (木) 08:27:15)
- 8 (2012-10-28 (日) 22:32:37)
- 9 (2013-03-18 (月) 19:29:57)
- 10 (2013-03-21 (木) 15:47:25)
- 11 (2013-09-06 (金) 15:31:52)
- 12 (2014-11-25 (火) 03:03:31)
- 13 (2015-02-04 (水) 18:53:38)
- 14 (2015-03-04 (水) 17:19:20)
- 15 (2017-01-20 (金) 13:20:23)
- 16 (2017-12-19 (火) 16:21:48)
- 17 (2019-02-14 (木) 12:45:11)
- 18 (2019-02-18 (月) 13:44:59)
- 19 (2020-12-05 (土) 16:18:33)
- 20 (2023-04-05 (水) 13:41:03)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:JTabbedPaneの余白に文字列を表示 #navi(../) RIGHT:Posted by [[aterai]] at 2005-12-26 RIGHT:Posted by &author(aterai); at 2005-12-26 *JTabbedPaneの余白に文字列を表示 [#d14a047c] JTabbedPaneの右側の余白に文字列を表示します。[http://forums.sun.com/thread.jspa?threadID=605786 Swing - JTabbedPane with non-tabbed text]の投稿からソースコードを引用しています。 -&jnlp; -&jar; -&zip; //#screenshot #ref(http://lh4.ggpht.com/_9Z4BYR88imo/TQTUTbAqf_I/AAAAAAAAAl0/APOrWdnvDko/s800/TabbedPaneWithText.png) **サンプルコード [#f6205526] #code{{ #code(link){{ tab = new JTabbedPane() { @Override public void paintComponent(Graphics g) { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); String text = "←ちょっとしたタブの説明など"; FontMetrics fm = getFontMetrics(getFont()); int stringWidth = fm.stringWidth(text)+10; int x = getSize().width-stringWidth; Rectangle lastTab = getUI().getTabBounds(this, getTabCount()-1); int tabEnd = lastTab.x + lastTab.width; if(x<tabEnd) x = tabEnd; g.drawString(text, x+5, 18); } }; }} **解説 [#t35e18f2] JTabbedPane#paintComponentメソッドをオーバーライドして、タブコンポーネントの右側の余白に文字列を描画しています。 右端に十分な余白が無く、文字列を描画するとタブ上に重なってしまう場合は、最後のタブの横から文字列を描画するようになっています。 **参考リンク [#w33aebb6] -[http://forums.sun.com/thread.jspa?threadID=605786 Swing - JTabbedPane with non-tabbed text] -[[JTabbedPaneの余白にJCheckBoxを配置>Swing/TabbedPaneWithCheckBox]] **コメント [#q1e57b08] #comment