Menu

Patch to improve JTable appearance in result window

Atri
2025-06-01
2025-06-02
  • Atri

    Atri - 2025-06-01

    Hi,
    I found that on my Linux system, which is set up with fonts scaled up by a factor of 1.25, the table in the result window was fairly un-readable due to the table row sizes being hard-coded in and not adapting to the increased size of fonts. I have attached a screen-shot to show what I mean.

    I wrote the following patch that adjusts the table row size with respect to the content font size (plus some default padding) and tested that this fixes the issue for me. Please let me know if this is the right fix for the issue or suggest improvements.

    Thanks for the great app.

    ---
     src/TableWindow.java |    8 ++++++++
     1 file changed, 8 insertions(+)
    
    Index: PlotDigitizer-2.6.11/src/TableWindow.java
    ===================================================================
    --- PlotDigitizer-2.6.11.orig/src/TableWindow.java
    +++ PlotDigitizer-2.6.11/src/TableWindow.java
    @@ -33,6 +33,8 @@ import java.awt.Container;
     import java.awt.Dimension;
     import java.awt.event.ActionEvent;
     import java.awt.event.WindowEvent;
    +import java.awt.Font;
    +import java.awt.Toolkit;
     import java.io.File;
     import java.io.FileOutputStream;
     import java.io.IOException;
    @@ -175,7 +177,12 @@ public class TableWindow extends JFrame
                 }
             };
    
    +        Font defaultTableFont = UIManager.getFont("Table.font");
    +        final int ROW_PADDING = 10;
    +        int rowHeight         = defaultTableFont.getSize() + ROW_PADDING;
    +
             JTable tableView = new JTable(dataModel);
    +        tableView.setRowHeight(rowHeight);
             tableView.setDefaultEditor(Float.class, decEditor);
             tableView.setDefaultRenderer(Float.class, decRenderer);
             tableView.setCellSelectionEnabled(true);
    @@ -191,6 +198,7 @@ public class TableWindow extends JFrame
             //  Create a menu bar for this window.
             JMenuBar menuBar = createMenuBar();
             this.setJMenuBar(menuBar);
    +        pack();
    
         }
    
     
  • Atri

    Atri - 2025-06-01

    Here is the screenshot after applying my patch.

     
  • Joseph A. Huwaldt

    This looks great. I'll roll this into my next release. Thanks for the great input! -- Joe

     
    • Atri

      Atri - 2025-06-02

      Thanks for your quick response.

      There are also some HiDPI issues on Linux (too small initial window; tiny, difficult to read about window) that I am looking at. Generally, minor cosmetic aspects apart, with the above patch applied, the app is very usable on my HiDPI Linux screen.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.