Swing/TableCellRenderer のバックアップ(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- Swing/TableCellRenderer へ行く。
- 1 (2004-10-08 (金) 06:26:51)
- 2 (2004-11-04 (木) 10:12:36)
- 3 (2005-04-28 (木) 04:33:10)
- 4 (2005-06-16 (木) 03:14:48)
- 5 (2005-07-05 (火) 22:10:07)
- 6 (2005-09-21 (水) 21:54:39)
- 7 (2006-02-27 (月) 16:56:25)
- 8 (2006-06-22 (木) 17:20:47)
- 9 (2006-11-10 (金) 03:38:35)
- 10 (2007-03-13 (火) 19:47:04)
- 11 (2007-03-15 (木) 14:21:24)
- 12 (2007-05-17 (木) 18:06:02)
- 13 (2008-02-14 (木) 14:14:38)
- 14 (2008-05-08 (木) 18:25:18)
- 15 (2010-10-25 (月) 14:23:41)
- 16 (2010-12-10 (金) 10:12:40)
- 17 (2010-12-10 (金) 13:50:58)
- 18 (2010-12-10 (金) 17:43:28)
- 19 (2011-04-26 (火) 14:14:05)
- 20 (2013-04-10 (水) 16:08:52)
- 21 (2014-11-22 (土) 03:59:58)
- 22 (2015-01-07 (水) 16:17:40)
- 23 (2015-01-13 (火) 11:19:07)
- 24 (2016-07-19 (火) 22:24:33)
- 25 (2016-09-02 (金) 12:11:11)
- 26 (2017-10-12 (木) 13:39:11)
- 27 (2019-04-09 (火) 15:48:24)
- 28 (2021-01-23 (土) 21:36:28)
- 29 (2023-12-14 (木) 10:20:14)
#navi(contents-page-name): No such page: ST
Terai Atsuhiro 2023-12-14 (木) 10:20:14
class MyJLabel extends JLabel { private GlyphVector gvtext; public MyJLabel() {super();} protected void paintComponent(Graphics g){ //super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; int WRAPPING_WIDTH = getWidth()-getInsets().left-getInsets().right; FontRenderContext frc = g2.getFontRenderContext(); gvtext = getWrappedGlyphVector(getText(), WRAPPING_WIDTH, getFont(), frc); g2.setPaint(getBackground()); g2.fillRect(0, 0, getWidth(), getHeight()); g2.setPaint(getForeground()); g2.drawGlyphVector(gvtext, getInsets().left, getFont().getSize()+getInsets().top); } private GlyphVector getWrappedGlyphVector(String str, float Wrapping, Font font, FontRenderContext frc){ Point2D gmPos = new Point2D.Double(0.0d, 0.0d); GlyphVector gv = font.createGlyphVector(frc, str); float lineheight = (float) (gv.getLogicalBounds().getHeight()); float xpos = 0.0f; float advance = 0.0f; int lineCount = 0; GlyphMetrics gm; for(int i=0;i<gv.getNumGlyphs();i++){ gm = gv.getGlyphMetrics(i); advance = gm.getAdvance(); if(xpos<Wrapping && Wrapping<=xpos+advance){ lineCount++; xpos = 0.0f; } gmPos.setLocation(xpos, lineheight*lineCount); gv.setGlyphPosition(i, gmPos); xpos = xpos + advance; } return gv; } } class TestRenderer extends MyJLabel implements TableCellRenderer{ public TestRenderer(){
ST/GlyphVector?
class MyCellRenderer extends JTextArea implements TableCellRenderer { MyCellRenderer() { super(); setLineWrap(true); } public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ setText((value == null) ? "" : value.toString()); return this; } }