Diamond Grid Overview Begin | Previous | Next
JTable への Drop-in replacement | 簡単なスタイルの追加

JTable への Drop-in replacement
Diamond Grid (DsGrid) は、builtin JTable を拡張するので、JTable を使用している既存のアプリケーションを簡単に、 コードの 1 行を変更することによって、Diamond Grid の詳細機能をすべて使用できる DSGrid に変換します。たとえば、次のような場合:
JTable table = new JTable();
以下のように変換します
DsGrid table = new DsGrid();

既存のコードは変わらず動作し、追加した新しい機能を使用できます。JTable の新たな機能として、基本的な JTable の実装によって提供される DsGrid の機能が以下のようにあります:

  • 行の高さの設定 (各行と均一のサイズ)
  • 列の幅の設定
  • 列の高さの設定
  • セルのレンダおよびセルのエディタを使用して、データの表示をカスタマイズ
  • 縦/横のグリッド線の表示と色の変更
強力でかつ簡単にデータにスタイルを追加します
grid.getColumns( 0, 0 ).setForeground( Color.blue );
grid.getRows( 1, 1 ).setFontBold( true );
grid.getCellAt( 0, 0 ).setFont( new Font( "serif", Font.ITALIC, 14 ) );
grid.getCellAt( 2, 0 ).setFontStrikeThrough( true );
grid.getCellAt( 3, 0 ).setFontUnderline( DsConstants.SINGLE );
grid.spanCells( 2, 1, 1, 2 );
grid.getCellAt( 2, 1 ).setBackground( Color.yellow );
grid.getCellAt( 2, 1 ).setHorizontalAlignment( DsCell.CENTER );
grid.getCellAt( 3, 1 ).setWordWrap( true );
grid.getCellAt( 3, 1 ).setValue( "Word wrap is available" );
Color c1 = new Color( 180, 235, 255 );
Color c2 = new Color( 130, 180, 250 );
GradientPaint p = new GradientPaint( 0, 0, c1, 0, 15, c2, true );
grid.getCellAt( 3, 1 ).setBackground( p );
grid.setRowHeight( 3, 30 );
grid.setColumnWidth( 1, 80 );
grid.setColumnHorizontalAlignment( 2, DsGrid.RIGHT );
grid.getCells( 0, 1, 1, 2 ).outline( Color.green, DsConstants.DASH, 2 );
grid.getCellAt( 3, 2 ).setBorderStyle( DsCell.DOUBLE_LINE );
grid.getCellAt( 3, 2 ).setBorderLineColor( Color.red );
grid.getCellAt( 3, 2 ).setBorderLineWidth( 2 );
grid.getCellAt( 3, 2 ).setBorderLines( DsCell.BORDER_OUTLINE );
grid.getCellAt( 3, 0 ).setBorderStyle( DsCell.ETCHED );
grid.getCellAt( 3, 0 ).setBackground( Color.lightGray );
grid.getCellAt( 3, 0 ).setHorizontalAlignment( DsCell.CENTER );
grid.getCellAt( 3, 0 ).setVerticalAlignment( DsCell.CENTER );

Font f = new Font("Dialog", Font.BOLD, 14);
grid.getColumnHeader().getProperties().setTextStyle( DsGrid.RAISED );
grid.getColumnHeader().getProperties().setFont( f );
grid.getRowHeader().getProperties().setTextStyle( DsGrid.RAISED );
grid.getRowHeader().getProperties().setFont( f );
Copyright © 1998-2002 XLsoft Corporation. All Rights Reserved.