• Post Reply Bookmark Topic Watch Topic
  • New Topic

Code to chage the JTable Height

 
aadhar sharma
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to change the height of a JTable which is inside a JTable

i have followed the following approach but doesnt seem to work

help required

Thanks and Regards

Aadhar Sharma


class TblRenderer extends JScrollPane implements TableCellRenderer {

private static final long serialVersionUID = -3116775877820006868L;

TblRenderer(ConstructionRoutingJWThreadModel jwTableModel) {
setViewportView(getTable(jwTableModel));
}

public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
//synchronized (isHeightChanging) {
//if (!isHeightChanging) {
//isHeightChanging = true;
//
//table.setRowHeight(row, (table.getRowHeight() * table
//.getRowCount())
//+ table.getRowMargin()
//+ table.getTableHeader().getHeight());
//isHeightChanging = false;
//}
//}

return this;
}
}

class ScrollEditor extends JScrollPane implements TableCellEditor {

private static final long serialVersionUID = -3225224759139894282L;

ScrollEditor(ConstructionRoutingJWThreadModel jwTableModel) {
setViewportView(getTable(jwTableModel));
}

public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {

//synchronized (isHeightChanging) {
//if (!isHeightChanging) {
//isHeightChanging = true;
//
//table.setRowHeight(row, (table.getRowHeight() * table
//.getRowCount())
//+ table.getRowMargin()
//+ table.getTableHeader().getHeight());
//isHeightChanging = false;
//}
//}

return this;
}

public void cancelCellEditing() {
}

public boolean stopCellEditing() {
return true;
}

public Object getCellEditorValue() {
return null;
}

public boolean isCellEditable(EventObject anEvent) {
return true;
}

public boolean shouldSelectCell(EventObject anEvent) {
return true;
}

public void addCellEditorListener(CellEditorListener l) {
}

public void removeCellEditorListener(CellEditorListener l) {
}
}

private static JTable getTable(ConstructionRoutingJWThreadModel jwTableModel) {
String header[] = { "Top Thread", "Top /nThread Qty", "Under Thread",
"Under/n Thread Qty", "Other Thread", "Other\n Thread Qty " };
Object data[][] = new Object[6][header.length];
JTable table = new JTable(data, header);

table.setModel(jwTableModel);
return table;
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!