Skip to content

Commit

Permalink
turn progressbar red on plot failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nybbs2003 committed Nov 3, 2023
1 parent 1fbb7c0 commit dcb1082
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public void onProgress(Type type, float progress, String rate, String ETA) {
}
}, mem_field.getText());
} catch (Exception x) {
model.setValueAt(-1F, _i, 1);
UIUtil.displayMessage(x.getClass().getSimpleName(), x.getMessage(), MessageType.ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hk.zdl.crypto.pearlet.ui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JProgressBar;
Expand All @@ -14,9 +15,16 @@ public class ProgressBarTableCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof Float) {
var val = (int) (float) value;
var bar = new JProgressBar(0, 100);
bar.setValue((int) Float.parseFloat(value.toString()));
bar.setString(bar.getValue() + "%");
if (val < 0) {
bar.setValue(100);
bar.setString("ERROR");
bar.setForeground(Color.red.darker());
} else {
bar.setValue(val);
bar.setString(bar.getValue() + "%");
}
bar.setStringPainted(true);
bar.setFont(table.getFont());
bar.setBorder(super.getBorder());
Expand Down

0 comments on commit dcb1082

Please sign in to comment.