0
JTable을 가지고 행 사이에 선이 보이지 않거나 선이 보이지 않을 수도 있습니다. 확실하지 않습니다.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의를 확장하는 클래스의 내부 :
여기 내 코드입니다.
[테이블 사용 방법] (https://docs.oracle.com/javase/tutorial/uiswing/components/table.html)에서 시작하십시오. 나는 이것이 사용 된 모양과 느낌이라고 생각합니다. – AxelH
더 나은 도움을 더 빨리 얻으려면 [MCVE] 또는 [짧은, 자기 포함, 올바른 예] (http://www.sscce.org/)를 게시하십시오. –
@AxelH 고마워, 나는 그것을 읽었지만 대답을 찾을 수 없었다. – JollyRoger