Truncate overflowing strings

This commit is contained in:
Downforce Agent 2024-07-30 15:10:55 -05:00
parent a75f1ad06c
commit ca36fadad1
3 changed files with 20 additions and 7 deletions

View File

@ -209,12 +209,14 @@ public class Suggs implements ActionListener, ListSelectionListener {
} }
} else } else
if (actionEvent.getSource() == spDeleteBtn) { if (actionEvent.getSource() == spDeleteBtn) {
dSTitle.setToolTipText(null);
dSTitle.setText("no track"); dSTitle.setText("no track");
dSSize.setText("no size"); dSSize.setText("no size");
sptrack = null; sptrack = null;
spDeleteBtn.setVisible(false); spDeleteBtn.setVisible(false);
} else } else
if (actionEvent.getSource() == mpDeleteBtn) { if (actionEvent.getSource() == mpDeleteBtn) {
dMTitle.setToolTipText(null);
dMTitle.setText("no track"); dMTitle.setText("no track");
dMSize.setText("no size"); dMSize.setText("no size");
mptrack = null; mptrack = null;
@ -337,7 +339,8 @@ public class Suggs implements ActionListener, ListSelectionListener {
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile(); File selectedFile = fileChooser.getSelectedFile();
sptrack = selectedFile; 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"); dSSize.setText(selectedFile.length() + " B");
if (selectedFile.length() > 1023) { if (selectedFile.length() > 1023) {
dSSize.setText((selectedFile.length() / 1024) + " KB"); dSSize.setText((selectedFile.length() / 1024) + " KB");
@ -355,7 +358,8 @@ public class Suggs implements ActionListener, ListSelectionListener {
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile(); File selectedFile = fileChooser.getSelectedFile();
mptrack = selectedFile; 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"); dMSize.setText(selectedFile.length() + " B");
if (selectedFile.length() > 1023) { if (selectedFile.length() > 1023) {
dMSize.setText((selectedFile.length() / 1024) + " KB"); dMSize.setText((selectedFile.length() / 1024) + " KB");

View File

@ -90,7 +90,9 @@
<grid id="b015e" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="b015e" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="4" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<maximum-size width="500" height="-1"/>
</grid>
</constraints> </constraints>
<properties> <properties>
<opaque value="false"/> <opaque value="false"/>
@ -99,7 +101,7 @@
<children> <children>
<component id="18770" class="javax.swing.JLabel" binding="fOutpath"> <component id="18770" class="javax.swing.JLabel" binding="fOutpath">
<constraints> <constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="0" indent="0" use-parent-layout="false"/> <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<font name="Exo 2"/> <font name="Exo 2"/>
@ -109,7 +111,7 @@
</component> </component>
<component id="fa1ee" class="javax.swing.JButton" binding="fOutpathChangebtn"> <component id="fa1ee" class="javax.swing.JButton" binding="fOutpathChangebtn">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<background color="-2271221"/> <background color="-2271221"/>

View File

@ -67,7 +67,7 @@ public class Waldorf implements ActionListener {
dwnSDKbtn.addActionListener(this); dwnSDKbtn.addActionListener(this);
fOutpathChangebtn.addActionListener(this); fOutpathChangebtn.addActionListener(this);
fOutpath.setText(Main.outpath); updateDOutpath(Main.outpath);
checkUpdatesToggle.setSelected(Main.checkUpdates); checkUpdatesToggle.setSelected(Main.checkUpdates);
frame.setVisible(true); 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 @Override
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
if (actionEvent.getSource() == cancelbtn) { if (actionEvent.getSource() == cancelbtn) {
@ -147,7 +154,7 @@ public class Waldorf implements ActionListener {
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
if (fileChooser.getSelectedFile().isDirectory()) { if (fileChooser.getSelectedFile().isDirectory()) {
tOutPath = fileChooser.getSelectedFile().getAbsolutePath()+"/"; tOutPath = fileChooser.getSelectedFile().getAbsolutePath()+"/";
fOutpath.setText(tOutPath); updateDOutpath(tOutPath);
} }
} }
} }