Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. package eu.darkbot.wakatoa.tasks.ggspinner;
  2.  
  3. import com.github.manolo8.darkbot.config.tree.ConfigField;
  4. import com.github.manolo8.darkbot.gui.tree.OptionEditor;
  5. import net.miginfocom.swing.MigLayout;
  6.  
  7. import javax.swing.*;
  8. import java.awt.*;
  9. import java.util.Map;
  10.  
  11. public class JStatsComponent extends JPanel implements OptionEditor {
  12.  
  13.     public JStatsComponent(SpinnerConfiguration config){
  14.         super(new MigLayout("ins 0, wrap 2, fillx", "[grow]10px[grow]"));
  15.  
  16.         setOpaque(false);
  17.         setPreferredSize(new Dimension(450, 440));
  18.  
  19.         JLabel statusField = new JLabel();
  20.         statusField.setText("Status: Bot initialized... waiting for user action...");
  21.         add(statusField, "span 2, gaptop 5px");
  22.         config.STATUS_UPDATE.add(info -> SwingUtilities.invokeLater(() -> statusField.setText("Status: " + info)));
  23.  
  24.         int counter = 0;
  25.         for (Map.Entry<String, Integer> entry : config.STATS_INFO.entrySet()) {
  26.             JLabel lbl = new JLabel(entry.getKey() + ": " + entry.getValue());
  27.             config.STATS_INFO_UPDATE.get(entry.getKey()).add(info -> SwingUtilities.invokeLater(() -> lbl.setText(entry.getKey() + ": " + entry.getValue())));
  28.  
  29.             counter++;
  30.             if(counter < 4){
  31.                 add(lbl, "span 2");
  32.             }
  33.             else if(counter == 4){
  34.                 add(lbl, "gaptop 10px");
  35.             }
  36.             else{
  37.                 add(lbl);
  38.             }
  39.         }
  40.         GateInfoTable gateInfoTable = new GateInfoTable(config);
  41.  
  42.         add(gateInfoTable.getComponent(), "span 2, gaptop 10px");
  43.     }
  44.  
  45.     @Override
  46.     public JComponent getComponent() {
  47.         return this;
  48.     }
  49.  
  50.     @Override
  51.     public void edit(ConfigField configField) {
  52.     }
  53.  
  54.     @Override
  55.     public String toString(){
  56.         return "Display not available in no-editor-mode";
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement