forked from KNEMC/KLALB
V1.0
This commit is contained in:
@@ -36,7 +36,7 @@ public class TPanel extends JPanel{
|
||||
add(tname, BorderLayout.WEST);
|
||||
|
||||
targ = new JLabel();
|
||||
targ.setFont(new Font("ËÎÌå", Font.PLAIN, 14));
|
||||
targ.setFont(new Font("ËÎÌå", Font.PLAIN, 13));
|
||||
targ.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
targ.setForeground(Color.YELLOW);
|
||||
add(targ, BorderLayout.CENTER);
|
||||
@@ -45,28 +45,39 @@ public class TPanel extends JPanel{
|
||||
setSize(570, 30);
|
||||
setPreferredSize(getSize());
|
||||
}
|
||||
private long up,down,delay;
|
||||
private long up,down,ups,downs,delay;
|
||||
|
||||
public long getUp() {
|
||||
return up;
|
||||
}
|
||||
public void setUp(long up) {
|
||||
this.up = up;
|
||||
targ.setText(up+"\u2191 "+down+"\u2193 "+delay/1000000+"ms");
|
||||
}
|
||||
public long getDown() {
|
||||
return down;
|
||||
}
|
||||
public void setDown(long down) {
|
||||
this.down = down;
|
||||
targ.setText(up+"\u2191 "+down+"\u2193 "+delay/1000000+"ms");
|
||||
}
|
||||
public long getDelay() {
|
||||
return delay;
|
||||
}
|
||||
public void setDelay(long delay) {
|
||||
this.delay = delay;
|
||||
targ.setText(up+"\u2191 "+down+"\u2193 "+delay/1000000+"ms");
|
||||
updateText();
|
||||
}
|
||||
private void updateText() {
|
||||
targ.setText(bytesUnit(up)+"\u2191 "+bytesUnit(down)+"\u2193 "+bytesUnit(ups)+"/s\u2191 "+bytesUnit(downs)+"/s\u2193 "+delay/1000000+"ms");
|
||||
}
|
||||
private String bytesUnit(long v) {
|
||||
if(v>=1024L*1024*1024*1024*1024) {
|
||||
return String.format("%.1f", v/(1024.0*1024.0*1024.0*1024.0*1024.0))+"PB";
|
||||
}else if(v>=1024L*1024*1024*1024) {
|
||||
return String.format("%.1f", v/(1024.0*1024.0*1024.0*1024.0))+"TB";
|
||||
}else if(v>=1024L*1024*1024) {
|
||||
return String.format("%.1f", v/(1024.0*1024.0*1024.0))+"GB";
|
||||
}else if(v>=1024L*1024) {
|
||||
return String.format("%.1f", v/(1024.0*1024.0))+"MB";
|
||||
}else if(v>=1024L) {
|
||||
return String.format("%.1f", v/(1024.0))+"KB";
|
||||
}else {
|
||||
return v+"B";
|
||||
}
|
||||
}
|
||||
public void setTraffic(long up2, long down2, long ups, long downs) {
|
||||
up=up2;
|
||||
down=down2;
|
||||
this.ups=ups;
|
||||
this.downs=downs;
|
||||
updateText();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user