|
@@ -4,6 +4,7 @@ import javax.swing.JPanel;
|
|
|
import javax.swing.JLabel;
|
|
|
import java.awt.Font;
|
|
|
import java.awt.Dimension;
|
|
|
+import java.awt.Color;
|
|
|
|
|
|
public class FlexibleData extends JPanel {
|
|
|
private JLabel name_lbl;
|
|
@@ -11,8 +12,8 @@ public class FlexibleData extends JPanel {
|
|
|
private JLabel lblConsVal;
|
|
|
private JLabel lblProdConsVal;
|
|
|
public FlexibleData(String name, float prod, float cons) {
|
|
|
- setPreferredSize(new Dimension(400, 150));
|
|
|
- setMinimumSize(new Dimension(300, 200));
|
|
|
+ setPreferredSize(new Dimension(614, 100));
|
|
|
+ setMinimumSize(new Dimension(600, 150));
|
|
|
setLayout(null);
|
|
|
|
|
|
name_lbl = new JLabel();
|
|
@@ -22,36 +23,41 @@ public class FlexibleData extends JPanel {
|
|
|
add(name_lbl);
|
|
|
|
|
|
JLabel lblFlProd = new JLabel("Flex. Prod. :");
|
|
|
+ lblFlProd.setForeground(new Color(0, 128, 0));
|
|
|
lblFlProd.setBounds(31, 46, 65, 27);
|
|
|
add(lblFlProd);
|
|
|
|
|
|
JLabel lblFlexCons = new JLabel("Flex. Cons. :\r\n");
|
|
|
- lblFlexCons.setBounds(31, 72, 65, 27);
|
|
|
+ lblFlexCons.setForeground(new Color(255, 0, 0));
|
|
|
+ lblFlexCons.setBounds(181, 46, 65, 27);
|
|
|
add(lblFlexCons);
|
|
|
|
|
|
JLabel lblProdCons = new JLabel("Prod./Cons. :");
|
|
|
- lblProdCons.setBounds(31, 95, 65, 27);
|
|
|
+ lblProdCons.setForeground(new Color(218, 165, 32));
|
|
|
+ lblProdCons.setBounds(327, 46, 65, 27);
|
|
|
add(lblProdCons);
|
|
|
|
|
|
lblProdVal = new JLabel();
|
|
|
setProd(prod);
|
|
|
- lblProdVal.setBounds(100, 47, 125, 24);
|
|
|
+ lblProdVal.setBounds(100, 47, 72, 24);
|
|
|
add(lblProdVal);
|
|
|
|
|
|
lblConsVal = new JLabel();
|
|
|
setCons(cons);
|
|
|
- lblConsVal.setBounds(100, 73, 125, 24);
|
|
|
+ lblConsVal.setBounds(252, 47, 72, 24);
|
|
|
add(lblConsVal);
|
|
|
|
|
|
lblProdConsVal = new JLabel();
|
|
|
if(cons != 0 && prod != 0){
|
|
|
- lblProdConsVal.setText(Float.toString(prod/cons));
|
|
|
+ lblProdConsVal.setText(Float.toString((prod/cons)*(-1)));
|
|
|
+ }else if(prod == 0 && cons == 0){
|
|
|
+ lblProdConsVal.setText("not producing or consuming...");
|
|
|
}else if(prod == 0){
|
|
|
lblProdConsVal.setText("only consuming...");
|
|
|
}else if(cons == 0){
|
|
|
lblProdConsVal.setText("only producing...");
|
|
|
}
|
|
|
- lblProdConsVal.setBounds(100, 96, 125, 24);
|
|
|
+ lblProdConsVal.setBounds(402, 46, 173, 24);
|
|
|
add(lblProdConsVal);
|
|
|
}
|
|
|
|
|
@@ -63,11 +69,20 @@ public class FlexibleData extends JPanel {
|
|
|
lblConsVal.setText(Float.toString(c));
|
|
|
}
|
|
|
|
|
|
- public void setProdConsVal(float pc){
|
|
|
- lblProdConsVal.setText(Float.toString(pc));
|
|
|
+ public void setProdConsVal(float prod, float cons){
|
|
|
+ if(cons != 0 && prod != 0){
|
|
|
+ lblProdConsVal.setText(Float.toString((prod/cons)*(-1)));
|
|
|
+ }else if(prod == 0 && cons == 0){
|
|
|
+ lblProdConsVal.setText("not producing or consuming...");
|
|
|
+ }else if(prod == 0){
|
|
|
+ lblProdConsVal.setText("only consuming...");
|
|
|
+ }else if(cons == 0){
|
|
|
+ lblProdConsVal.setText("only producing...");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void setlblName(String name){
|
|
|
name_lbl.setText(name);
|
|
|
}
|
|
|
+
|
|
|
}
|