git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 1/8] Set table row height for the glog JTable

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Sep 30, 2008, 23:53 UTC
Message-ID
<1222818823-22780-1-git-send-email-robin.rosenberg@dewire.com>

For some obscure reason JTable has a fixed default row size of 16 pixels. This doesn't work well outside the default look-and-feels shipped with the JRE, e.g. the GTK look and feel for Linux.

Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
 .../org/spearce/jgit/awtui/CommitGraphPane.java    |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java b/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java
index 2be0e95..4ab2136 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/awtui/CommitGraphPane.java
@@ -52,6 +52,7 @@
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.JTableHeader;
+import javax.swing.table.TableCellRenderer;
 import javax.swing.table.TableColumn;
 import javax.swing.table.TableColumnModel;
 import javax.swing.table.TableModel;
@@ -83,8 +84,18 @@ public CommitGraphPane() {
 		allCommits = new SwingCommitList();
 		configureHeader();
 		setShowHorizontalLines(false);
-		setRowMargin(0);
 		setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+		configureRowHeight();
+	}
+
+	private void configureRowHeight() {
+		int h = 0;
+		for (int i = 0; i<getColumnCount(); ++i) {
+			TableCellRenderer renderer = getDefaultRenderer(getColumnClass(i));
+			Component c = renderer.getTableCellRendererComponent(this, "ÅOj", false, false, 0, i);
+			h = Math.max(h, c.getPreferredSize().height);
+		}
+		setRowHeight(h + getRowMargin());
 	}
 
 	/**
-- 
1.6.0.1.310.gf789d0.dirty
Next: Robin Rosenberg
Message 1 of 13 in “Set table row height for the glog JTable”
  1. 1/8 Set table row height for the glog JTableRobin Rosenberg, Sep 30, 2008
  2. 2/8 Move AWTPlotRenderer to its own file.Robin Rosenberg, Sep 30, 2008
  3. 3/8 Dispose of allocated colors on finalize()Robin Rosenberg, Sep 30, 2008
  4. 4/8 Align commit text properly in jgit glogRobin Rosenberg, Sep 30, 2008
  5. Robin RosenbergOct 1, 2008
  6. Shawn O. PearceOct 1, 2008
  7. 0/3 jgit glog alignment fixesRobin Rosenberg, Oct 1, 2008
  8. 1/3 Set table row height for the glog JTableRobin Rosenberg, Oct 1, 2008
  9. 2/3 Move AWTPlotRenderer to its own file.Robin Rosenberg, Oct 1, 2008
  10. 3/3 Align commit text properly in jgit glogRobin Rosenberg, Oct 1, 2008
  11. Shawn O. PearceOct 1, 2008
  12. Robin RosenbergOct 1, 2008
  13. Shawn O. PearceOct 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.