我有默认(矩形或正方形)结构的 jTable。我想将 jTable 的角弄圆。
有什么方法或途径可以实现吗?
我已经检查了JTable API但我没有找到任何有用的东西。
作为引用,我附上了这张图片。
图像描述 -
我想让突出显示的区域更圆。
最佳答案
public class JtableExample {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },
{ "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
Object columnNames[] = { "Column One", "Column Two", "Column Three" };
JTable table = new JTable(rowData, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
Border roundedBorder = new LineBorder(Color.black, 5, true); // the third parameter - true, says it's round
scrollPane.setBorder(roundedBorder);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
关于java - 不同结构的Jtable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15402673/