Skip to content

Commit

Permalink
decimal formating
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmipt committed Dec 18, 2024
1 parent 9ca6e70 commit 10a122f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/studio/ui/chart/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void notifyValueChanged() {
}
}

protected final JTextField txtValue = new JTextField();
protected final JTextField txtValue = new JTextField(15);

private double value = Double.NaN;

Expand Down
5 changes: 4 additions & 1 deletion src/studio/ui/chart/NumericEditor.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package studio.ui.chart;

import java.text.DecimalFormat;

public class NumericEditor extends Editor {
private static final DecimalFormat df7 = new DecimalFormat("#.#######");

protected void refresh() {
txtValue.setText("" + getValue());
txtValue.setText(df7.format(getValue()));
}

@Override
Expand Down
5 changes: 4 additions & 1 deletion src/studio/ui/chart/TimespanEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

import javax.swing.*;
import java.awt.*;
import java.text.DecimalFormat;
import java.time.temporal.ChronoUnit;

public class TimespanEditor extends Editor {

private static final DecimalFormat df5 = new DecimalFormat("#.#####");

private final KType unitType;
private K.KTimespan timespan = K.KTimespan.NULL;
private final JComboBox<ChronoUnit> comboUnit =
Expand Down Expand Up @@ -56,7 +59,7 @@ public double getValue() {
}

protected void refresh() {
txtValue.setText("" + timespan.toUnitValue((ChronoUnit) comboUnit.getSelectedItem()));
txtValue.setText(df5.format(timespan.toUnitValue((ChronoUnit) comboUnit.getSelectedItem())));
}

@Override
Expand Down

0 comments on commit 10a122f

Please sign in to comment.