• category: swing folder: IntercellSpacing title: JTableの罫線の有無とセルの内余白を変更 tags: [JTable] author: aterai pubdate: 2011-05-30T16:37:49+09:00 description: JTableの罫線の表示非表示とセルの内余白を変更します。 image: https://lh3.googleusercontent.com/-zDg_KUxGwU4/TeNHkhhJYGI/AAAAAAAAA8M/G5R8rKLVzUg/s800/IntercellSpacing.png

Summary

JTableの罫線の表示非表示とセルの内余白を変更します。

Source Code Examples

add(new JCheckBox(new AbstractAction("setShowVerticalLines") {
  @Override public void actionPerformed(ActionEvent e) {
    Dimension d = table.getIntercellSpacing();
    if (((JCheckBox) e.getSource()).isSelected()) {
      table.setShowVerticalLines(true);
      table.setIntercellSpacing(new Dimension(1, d.height));
    } else {
      table.setShowVerticalLines(false);
      table.setIntercellSpacing(new Dimension(0, d.height));
    }
  }
}));
add(new JCheckBox(new AbstractAction("setShowHorizontalLines") {
  @Override public void actionPerformed(ActionEvent e) {
    Dimension d = table.getIntercellSpacing();
    if (((JCheckBox) e.getSource()).isSelected()) {
      table.setShowHorizontalLines(true);
      table.setIntercellSpacing(new Dimension(d.width, 1));
    } else {
      table.setShowHorizontalLines(false);
      table.setIntercellSpacing(new Dimension(d.width, 0));
    }
  }
}));
View in GitHub: Java, Kotlin

解説

参考リンク

コメント