protected boolean setDir(JTextField txf, String strValue) {
    String strTxt = txf.getText();
    String strName = txf.getName();
    boolean bSet = false;

    if ((strTxt == null || strTxt.trim().length() == 0 || strTxt.equals(INFOSTR))
        && strName.equalsIgnoreCase("value")) {
      if (timer != null) {
        timer.cancel();
        txf.setForeground(Color.black);
      }

      bSet = true;
      txf.setText(strValue);
      txf.grabFocus();
    }
    return bSet;
  }
  void bPronadji_actionPerformed(ActionEvent e) {
    if (txtOznakaBanke.getText().equals("")) {
      JOptionPane.showMessageDialog(null, "Oznaka banke mora biti uneta");
      txtOznakaBanke.grabFocus();
    } else {
      Vector filijale = DBF.getFilijale(txtOznakaBanke.getText());
      if (!filijale.isEmpty()) {

        ((TModelPrijave) tabBanke.getModel()).rejoinData(filijale);

        String adresa = DBF.getadresaB(txtOznakaBanke.getText());
        jLadresaBanke.setText(adresa);

        jLnazivBanke.setText(DBF.getnazivB(txtOznakaBanke.getText()));

      } else {
        JOptionPane.showMessageDialog(null, "Nije pronadjena ni jedna filijala");
      }
    }
  }
Exemple #3
1
  MainWindow() {
    home.setSize(450, 400);
    home.setLocation(0, 0);
    home.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    error.setForeground(Color.red);
    home.add(error, "North");

    ipAddress.setEditable(true);
    f.setEditable(true);
    b.setEditable(true);
    l.setEditable(true);
    r.setEditable(true);

    start.addActionListener(this);
    help.addActionListener(this);
    quit.addActionListener(this);
    start.addMouseMotionListener(this);
    help.addMouseMotionListener(this);
    quit.addMouseMotionListener(this);

    JPanel homePanel = new JPanel();
    homePanel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.5;
    c.weighty = 0.5;

    // first col
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    homePanel.add(ip, c);

    c.gridy = 1;
    ipAddress.grabFocus();
    ipAddress.selectAll();
    homePanel.add(ipAddress, c);

    c.gridy = 2;
    homePanel.add(timeUnit, c);

    c.gridwidth = 1;
    c.gridy = 3;
    homePanel.add(forward, c);

    c.gridy = 4;
    homePanel.add(f, c);

    c.gridy = 5;
    homePanel.add(left, c);

    c.gridy = 6;
    homePanel.add(l, c);

    // second col
    c.ipadx = 50;
    c.gridx = 1;
    c.gridy = 0;
    homePanel.add(pinLabel, c);

    c.gridy = 1;
    homePanel.add(pin, c);

    c.gridy = 3;
    homePanel.add(reverse, c);

    c.gridy = 4;
    homePanel.add(b, c);

    c.gridy = 5;
    homePanel.add(right, c);

    c.gridy = 6;
    homePanel.add(r, c);

    // third col
    c.ipadx = 0;
    c.gridx = 2;
    c.gridy = 4;
    homePanel.add(start, c);

    c.gridy = 5;
    homePanel.add(help, c);

    c.gridy = 6;
    homePanel.add(quit, c);

    homePanel.setBackground(Color.white);
    homePanel.setOpaque(true);

    home.add(homePanel, "Center");
    home.setVisible(true);
  }
Exemple #4
0
  // Checks the current state and sets the enables/disables
  // accordingly
  public void run() {
    switch (connectionStatus) {
      case DISCONNECTED:
        connectButton.setEnabled(true);
        disconnectButton.setEnabled(false);
        ipField.setEnabled(true);
        portField.setEnabled(true);
        hostOption.setEnabled(true);
        guestOption.setEnabled(true);
        chatLine.setText("");
        chatLine.setEnabled(false);
        statusColor.setBackground(Color.red);
        break;

      case DISCONNECTING:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(false);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        hostOption.setEnabled(false);
        guestOption.setEnabled(false);
        chatLine.setEnabled(false);
        statusColor.setBackground(Color.orange);
        break;

      case CONNECTED:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(true);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        hostOption.setEnabled(false);
        guestOption.setEnabled(false);
        chatLine.setEnabled(true);
        statusColor.setBackground(Color.green);
        break;

      case BEGIN_CONNECT:
        connectButton.setEnabled(false);
        disconnectButton.setEnabled(false);
        ipField.setEnabled(false);
        portField.setEnabled(false);
        hostOption.setEnabled(false);
        guestOption.setEnabled(false);
        chatLine.setEnabled(false);
        chatLine.grabFocus();
        statusColor.setBackground(Color.orange);
        break;
    }

    // Make sure that the button/text field states are consistent
    // with the internal states
    ipField.setText(hostIP);
    portField.setText((new Integer(port)).toString());
    hostOption.setSelected(isHost);
    guestOption.setSelected(!isHost);
    statusField.setText(statusString);
    chatText.append(toAppend.toString());
    toAppend.setLength(0);

    mainFrame.repaint();
  }