Exemplo n.º 1
0
 private static void initGui() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception exception) {
     exception.printStackTrace();
   }
   JFrame frame = new JFrame("DarkBot");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLayout(new GridBagLayout());
   Insets noInsets = new Insets(0, 0, 0, 0);
   final JToggleButton sessionsButton = new JToggleButton("Login (0)");
   frame.add(
       sessionsButton,
       new GridBagConstraints(
           0, 0, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   sessionsButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           sessions.set(sessionsButton.isSelected());
           synchronized (sessions) {
             sessions.notifyAll();
           }
         }
       });
   final JToggleButton joinsButton = new JToggleButton("Join (0)");
   frame.add(
       joinsButton,
       new GridBagConstraints(
           0, 1, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   joinsButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           joins.set(joinsButton.isSelected());
           synchronized (joins) {
             joins.notifyAll();
           }
         }
       });
   final JTextField field = new JTextField();
   frame.add(
       field,
       new GridBagConstraints(
           0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   final JButton button = new JButton("Start");
   frame.add(
       button,
       new GridBagConstraints(
           1, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   button.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           if (button.getText().startsWith("Start")) {
             field.setEnabled(false);
             spamMessage = field.getText();
             button.setText("Stop");
           } else {
             spamMessage = null;
             button.setText("Start");
             field.setEnabled(true);
           }
         }
       });
   Timer timer =
       new Timer(
           500,
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
               sessionsButton.setText(
                   sessionsButton.getText().split(" ")[0]
                       + " ("
                       + Integer.toString(sessionCount.get())
                       + ")");
               joinsButton.setText(
                   joinsButton.getText().split(" ")[0]
                       + " ("
                       + Integer.toString(amountJoined.get())
                       + ")");
             }
           });
   timer.setRepeats(true);
   timer.start();
   frame.pack();
   frame.setSize(500, frame.getHeight());
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
Exemplo n.º 2
0
  public PanelSpec(SmedAction dia) {
    dlg = dia;
    setLayout(null);
    add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP));
    add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP));
    add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP));
    add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP));
    add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP));
    add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP));
    add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP));
    add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT));
    add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP));
    add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP));
    add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP));
    add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP));

    categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER);
    categoryLabel.setBounds(new Rectangle(5, 125, 160, 18));
    add(categoryLabel);
    categoryBox = new JComboBox();
    categoryBox.setBounds(new Rectangle(5, 142, 160, 18));
    add(categoryBox);
    categoryBox.setVisible(true);
    categoryBox.addActionListener(alCategoryBox);
    addCatItem("", Cat.NOCAT);
    addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN);
    addCatItem(Messages.getString("Warning"), Cat.SPM_WARN);
    addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF);
    addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT);
    addCatItem(Messages.getString("Cable"), Cat.SPM_CABL);
    addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL);
    addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS);
    addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN);
    addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR);
    addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY);
    addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG);
    addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC);
    addCatItem(Messages.getString("TSS"), Cat.SPM_TSS);
    addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL);
    addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE);
    addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY);
    addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH);
    mooringBox = new JComboBox();
    mooringBox.setBounds(new Rectangle(5, 142, 160, 18));
    add(mooringBox);
    mooringBox.setVisible(false);
    mooringBox.addActionListener(alMooringBox);
    addMorItem("", Cat.NOCAT);
    addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN);
    addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN);
    addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD);
    addMorItem(Messages.getString("Wall"), Cat.MOR_WALL);
    addMorItem(Messages.getString("Post"), Cat.MOR_POST);
    addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR);
    addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE);
    addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO);
    addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY);
    addMorItem(Messages.getString("CALM"), Cat.INB_CALM);
    addMorItem(Messages.getString("SBM"), Cat.INB_SBM);

    topmarkButton.setBounds(new Rectangle(136, 0, 34, 32));
    topmarkButton.setToolTipText(Messages.getString("Topmark"));
    topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder());
    topmarkButton.addActionListener(alTop);
    add(topmarkButton);

    //		noticeButton.setBounds(new Rectangle(136, 32, 34, 32));
    //		noticeButton.setToolTipText(Messages.getString("Notice"));
    //		noticeButton.setBorder(BorderFactory.createLoweredBevelBorder());
    //		noticeButton.addActionListener(alNotice);
    //		add(noticeButton);

    mooringButton.setBounds(new Rectangle(136, 64, 34, 32));
    mooringButton.setToolTipText(Messages.getString("Mooring"));
    mooringButton.setBorder(BorderFactory.createLoweredBevelBorder());
    mooringButton.addActionListener(alMooring);
    add(mooringButton);
  }
Exemplo n.º 3
0
 public void setToolbarButton(JToggleButton tb) {
   this.toolbarButton = tb;
   tb.addActionListener(this);
 }
Exemplo n.º 4
0
  public void jbInit() throws Exception {
    this.setLayout(null);
    fContractPriceTextField.setFont(new java.awt.Font("Dialog", 1, 11));
    fContractPriceTextField.setDisabledTextColor(Color.black);
    fContractPriceTextField.setEditable(false);
    fContractPriceTextField.setHorizontalAlignment(SwingConstants.RIGHT);
    fContractPriceTextField.setBounds(new java.awt.Rectangle(285, 182, 55, 21));
    fContractVolumeTextField.setFont(new java.awt.Font("Dialog", 1, 11));
    fContractVolumeTextField.setDisabledTextColor(Color.black);
    fContractVolumeTextField.setEditable(false);
    fContractVolumeTextField.setHorizontalAlignment(SwingConstants.RIGHT);
    fContractVolumeTextField.setBounds(new java.awt.Rectangle(285, 238, 55, 21));
    fContractVolumeLabel.setText(fRb.getString("CONTRACT_VOLUME"));
    fContractVolumeLabel.setForeground(Color.black);
    fContractVolumeLabel.setBounds(new java.awt.Rectangle(272, 218, 99, 17));
    fContractPriceLabel.setBounds(new java.awt.Rectangle(272, 160, 92, 17));
    fContractPriceLabel.setText(fRb.getString("CONTRACT_PRICE"));
    fContractPriceLabel.setForeground(Color.black);

    fBoardGraph.setLayout(borderLayout1);
    fDay.setBounds(new java.awt.Rectangle(337, 87, 42, 21));
    fDayLabel.setText(fRb.getString("DAY") + ":");
    fDayLabel.setForeground(Color.black);
    fDayLabel.setBounds(new java.awt.Rectangle(267, 89, 67, 17));
    fBoardLabel.setText(fRb.getString("SESSION") + ":");
    fBoardLabel.setForeground(Color.black);
    fBoardLabel.setBounds(new java.awt.Rectangle(267, 121, 68, 17));
    fBoard.setBounds(new java.awt.Rectangle(337, 119, 42, 22));
    fPreviousBoardLabel.setFont(new java.awt.Font("Dialog", 1, 12));
    fPreviousBoardLabel.setText(fRb.getString("PREVIOUS_PRICING"));
    fPreviousBoardLabel.setForeground(Color.black);
    fPreviousBoardLabel.setBounds(new java.awt.Rectangle(85, 4, 99, 17));
    fXYToggleButton.setBorder(BorderFactory.createRaisedBevelBorder());
    fXYToggleButton.setText("Exchange X-Y");
    fXYToggleButton.setBounds(new java.awt.Rectangle(268, 43, 114, 25));
    fXYToggleButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fIsExchangeXY = fXYToggleButton.isSelected();
            fIsUpdated = true;
            gUpdate();
          }
        });

    this.setBorder(BorderFactory.createEtchedBorder());
    this.setBounds(new java.awt.Rectangle(325, 7, 387, 283));
    this.setLayout(null);
    fBoardGraph.setBorder(BorderFactory.createEtchedBorder());
    fBoardGraph.setBounds(new java.awt.Rectangle(5, 26, 257, 243));
    fBoardGraph.getGraph().add(new UGraphData(fSellName, fSellColor));
    fBoardGraph.getGraph().add(new UGraphData(fBuyName, fBuyColor));
    fBoardGraph.setLeftMargin(60);
    this.add(fBoardGraph, null);
    this.add(fContractVolumeTextField, null);
    this.add(fContractVolumeLabel, null);
    this.add(fContractPriceTextField, null);
    this.add(fContractPriceLabel, null);
    this.add(fBoardLabel, null);
    this.add(fDayLabel, null);
    this.add(fXYToggleButton, null);
    this.add(fPreviousBoardLabel, null);
    this.add(fDay, null);
    this.add(fBoard, null);
    fBoardGraph.setBackground(Color.white);
    fBoardGraph.setNumOfHorizontalLine(0);
    fBoardGraph.setNumOfVerticalLine(0);
    fBoardGraph.setFixedMaxX(1);
    fBoardGraph.setFixedMinX(0);
    fBoardGraph.setFixedMaxY(1);
    fBoardGraph.setFixedMinY(0);
    addComponentListener(
        new ComponentAdapter() {
          public void componentShown(ComponentEvent ce) {
            gUpdate();
          }
        });
  }