From ca36fadad1048474064d6f7b57266f677981a807 Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Tue, 30 Jul 2024 15:10:55 -0500 Subject: [PATCH] Truncate overflowing strings --- firestar/src/main/java/Suggs.java | 8 ++++++-- firestar/src/main/java/Waldorf.form | 8 +++++--- firestar/src/main/java/Waldorf.java | 11 +++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/firestar/src/main/java/Suggs.java b/firestar/src/main/java/Suggs.java index 267c540..b22cacb 100644 --- a/firestar/src/main/java/Suggs.java +++ b/firestar/src/main/java/Suggs.java @@ -209,12 +209,14 @@ public class Suggs implements ActionListener, ListSelectionListener { } } else if (actionEvent.getSource() == spDeleteBtn) { + dSTitle.setToolTipText(null); dSTitle.setText("no track"); dSSize.setText("no size"); sptrack = null; spDeleteBtn.setVisible(false); } else if (actionEvent.getSource() == mpDeleteBtn) { + dMTitle.setToolTipText(null); dMTitle.setText("no track"); dMSize.setText("no size"); mptrack = null; @@ -337,7 +339,8 @@ public class Suggs implements ActionListener, ListSelectionListener { if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); sptrack = selectedFile; - dSTitle.setText(selectedFile.getName()); + dSTitle.setText(selectedFile.getName().substring(0, Math.min(selectedFile.getName().length(), 20))); + if (selectedFile.getName().length() > 20) {dSTitle.setToolTipText(selectedFile.getName());} dSSize.setText(selectedFile.length() + " B"); if (selectedFile.length() > 1023) { dSSize.setText((selectedFile.length() / 1024) + " KB"); @@ -355,7 +358,8 @@ public class Suggs implements ActionListener, ListSelectionListener { if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); mptrack = selectedFile; - dMTitle.setText(selectedFile.getName()); + dMTitle.setText(selectedFile.getName().substring(0, Math.min(selectedFile.getName().length(), 20))); + if (selectedFile.getName().length() > 20) {dMTitle.setToolTipText(selectedFile.getName());} dMSize.setText(selectedFile.length() + " B"); if (selectedFile.length() > 1023) { dMSize.setText((selectedFile.length() / 1024) + " KB"); diff --git a/firestar/src/main/java/Waldorf.form b/firestar/src/main/java/Waldorf.form index a021a5c..e0e79d7 100644 --- a/firestar/src/main/java/Waldorf.form +++ b/firestar/src/main/java/Waldorf.form @@ -90,7 +90,9 @@ - + + + @@ -99,7 +101,7 @@ - + @@ -109,7 +111,7 @@ - + diff --git a/firestar/src/main/java/Waldorf.java b/firestar/src/main/java/Waldorf.java index 318f03d..af60ece 100644 --- a/firestar/src/main/java/Waldorf.java +++ b/firestar/src/main/java/Waldorf.java @@ -67,7 +67,7 @@ public class Waldorf implements ActionListener { dwnSDKbtn.addActionListener(this); fOutpathChangebtn.addActionListener(this); - fOutpath.setText(Main.outpath); + updateDOutpath(Main.outpath); checkUpdatesToggle.setSelected(Main.checkUpdates); frame.setVisible(true); @@ -81,6 +81,13 @@ public class Waldorf implements ActionListener { }); } + private void updateDOutpath(String path) { + String s = path; + if (s.startsWith(System.getProperty("user.home"))) {s = "~" + s.substring(System.getProperty("user.home").length());} + if (s.length() > 50) {s = s.substring(0, Math.min(path.length(), 46)) + "...";fOutpath.setToolTipText(path);} else {fOutpath.setToolTipText(null);} + fOutpath.setText(s); + } + @Override public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource() == cancelbtn) { @@ -147,7 +154,7 @@ public class Waldorf implements ActionListener { if (result == JFileChooser.APPROVE_OPTION) { if (fileChooser.getSelectedFile().isDirectory()) { tOutPath = fileChooser.getSelectedFile().getAbsolutePath()+"/"; - fOutpath.setText(tOutPath); + updateDOutpath(tOutPath); } } }