我有一个JTable并且无法看到行之间的行或者可能没有行,我不确定。这是我的JTable:
我怎样才能让它看起来像这样?
这是我的代码:
public class NodePropertyWindow extends JFrame{
public NodePropertyWindow(CytoVisProject cytoVisProject, CyNode node){
this.cytoVisProject = cytoVisProject;
this.adapter = cytoVisProject.getAdapter();
this.node = node;
this.setMinimumSize(new Dimension(400, 400));
this.setPreferredSize(new Dimension(400,400));
this.setTitle("Node Property Window");
this.setVisible(true);
this.initializeTable();
}
public void initializeTable(){
CyApplicationManager manager = this.adapter.getCyApplicationManager();
CyNetworkView networkView = manager.getCurrentNetworkView();
CyNetwork network = networkView.getModel();
CyTable cyTable = network.getDefaultNodeTable();
FilterUtil filterUtil = new FilterUtil(network, cyTable);
Map<String, Object> sampleRow = cyTable.getAllRows().get(filterUtil.findIndex(filterUtil.getAllNodes(), node)).getAllValues();
Collection<Object> values = sampleRow.values();
Set<String> attributeNames = sampleRow.keySet();
String[] columnNames = {"Attribute Name", "Value"};
this.data = new Object[values.size()][2];
Object[] attributeNamesObjects = attributeNames.toArray();
Iterator iterator = values.iterator();
for(i=0; i<values.size(); i++){
this.data[i][0] = attributeNamesObjects[i];
Object object = iterator.next();
this.data[i][1] = object;
}
// Above part is about the content of JTable
TableModel model = new DefaultTableModel(this.data, columnNames){
public boolean isCellEditable(int row, int column){
return false;
}
};
this.table = new JTable(this.data, columnNames);
this.table.setModel(model);
this.table.setPreferredScrollableViewportSize(new Dimension(500,300));
this.table.setFillsViewportHeight(true);
this.table.setLayout(new BorderLayout());
Container container = new Container();
container.setLayout(new BorderLayout());
container.add(table.getTableHeader(), BorderLayout.PAGE_START);
container.add(table, BorderLayout.CENTER);
this.add(container);
}
}
这部分是在扩展JFrame的类中。
答案 0 :(得分:0)
只要把这一个。我选择黑色,因为Jtable网格线是白色作为默认颜色。
table.setGridColor(Color.BLACK)