Java Swing - 如何在JTable中配置網(wǎng)格線
我們想知道如何在JTable中配置網(wǎng)格線。
import java.awt.Color;
import javax.swing.JTable;
public class Main {
public static void main(String[] argv) throws Exception {
JTable table = new JTable();
table.setShowGrid(false);//Don't show any grid lines
//Show only vertical grid lines
table.setShowGrid(false);
table.setShowVerticalLines(true);
//Show only horizontal grid lines
table.setShowGrid(false);
table.setShowHorizontalLines(true);
//Set the grid color
table.setGridColor(Color.red);
//Show both horizontal and vertical grid lines (the default)
table.setShowGrid(true);
}
}