Swing/Gradient のバックアップ差分(No.18)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/Gradient へ行く。
- 1 (2004-03-29 (月) 04:50:14)
- 2 (2004-03-30 (火) 11:00:47)
- 3 (2004-06-02 (水) 09:56:08)
- 4 (2004-08-31 (火) 12:12:31)
- 5 (2004-10-08 (金) 06:22:46)
- 6 (2004-11-04 (木) 10:08:05)
- 7 (2005-04-28 (木) 04:32:53)
- 8 (2005-06-23 (木) 06:49:49)
- 9 (2005-06-27 (月) 06:45:18)
- 10 (2005-11-10 (木) 01:56:37)
- 11 (2006-02-27 (月) 15:58:35)
- 12 (2007-01-11 (木) 11:47:47)
- 13 (2007-09-20 (木) 20:41:37)
- 14 (2008-04-11 (金) 14:31:46)
- 15 (2008-04-12 (土) 00:32:18)
- 16 (2012-08-02 (木) 16:16:50)
- 17 (2013-04-05 (金) 18:00:52)
- 18 (2014-11-14 (金) 14:54:03)
- 19 (2015-12-12 (土) 02:17:14)
- 20 (2017-06-08 (木) 13:22:53)
- 21 (2017-08-22 (火) 15:24:04)
- 22 (2018-08-24 (金) 13:58:59)
- 23 (2020-08-19 (水) 13:26:35)
- 24 (2022-01-14 (金) 07:56:54)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:Separatorのグラデーション #navi(../) #tags() RIGHT:Posted by &author(aterai); at 2004-03-29 *Separatorのグラデーション [#m51f3588] --- title: Separatorのグラデーション tags: [JSeparator, GradientPaint] author: aterai pubdate: 2004-03-29T04:50:14+09:00 description: グラデーションするセパレータを作ってみます。 --- * 概要 [#m51f3588] グラデーションするセパレータを作ってみます。 -&jnlp; -&jar; -&zip; #download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTNgUSWNnI/AAAAAAAAAa4/92SfYb-Z3zs/s800/Gradient.png) //#screenshot #ref(http://lh4.ggpht.com/_9Z4BYR88imo/TQTNgUSWNnI/AAAAAAAAAa4/92SfYb-Z3zs/s800/Gradient.png) **サンプルコード [#z73fe6d9] * サンプルコード [#z73fe6d9] #code(link){{ class GradientSeparatorUI extends BasicSeparatorUI{ public static ComponentUI createUI(JComponent c) { return new GradientSeparatorUI(); } private Color bgc,ssc,shc; private void updateColors(JComponent c) { Color uc = UIManager.getColor("Panel.background"); bgc = (uc instanceof ColorUIResource)? uc:c.getBackground(); uc = UIManager.getColor("Separator.shadow"); ssc = (uc instanceof ColorUIResource)? uc:c.getBackground().brighter(); uc = UIManager.getColor("Separator.highlight"); shc = (uc instanceof ColorUIResource)? uc:c.getBackground().darker(); } @Override public void installUI(JComponent c) { super.installUI(c); updateColors(c); } @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D)g; Dimension s = c.getSize(); if(((JSeparator)c).getOrientation()==JSeparator.VERTICAL) { g2.setPaint(new GradientPaint(0, 0, ssc, 0, s.height, bgc, true)); g2.fillRect(0, 0, 1, s.height); g2.setPaint(new GradientPaint(0, 0, shc, 0, s.height, bgc, true)); g2.fillRect(1, 0, 1, s.height); }else{ g2.setPaint(new GradientPaint(0, 0, ssc, s.width, 0, bgc, true)); g2.fillRect(0, 0, s.width, 1); g2.setPaint(new GradientPaint(0, 0, shc, s.width, 0, bgc, true)); g2.fillRect(0, 1, s.width, 1); } } } }} **解説 [#u88fd1d8] 上記のサンプルでは下のJSeparatorの描画にGradientPaintを使用し、グラデーションさせています。 * 解説 [#u88fd1d8] 上記のサンプルでは下の`JSeparator`の描画に`GradientPaint`を使用し、グラデーションさせています。 JSeparatorにsetBorder()すると、セパレータが見えなくなる場合があるのですこし注意が必要です。 `JSeparator`に`setBorder()`すると、セパレータが見えなくなる場合があるのですこし注意が必要です。 //**参考リンク **コメント [#x0186bae] - JSeparator.VERTICAL に対応。 -- [[aterai]] &new{2008-04-11 (金) 14:32:04}; //* 参考リンク * コメント [#x0186bae] #comment - `JSeparator.VERTICAL`に対応。 -- &user(aterai); &new{2008-04-11 (金) 14:32:04}; #comment