/** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
Esempio n. 2
0
  /**
   * Clears and focuses the search field if it is not focused. Otherwise, cycles to the next search
   * type.
   */
  public void startSearch() {
    if (increment.isSelected() && incSearch) {
      repeatIncremental();
      return;
    }
    if (!searchField.hasFocus()) {
      // searchField.setText("");
      searchField.selectAll();
      searchField.requestFocus();
    } else {
      if (increment.isSelected()) {
        floatSearch.setSelected(true);
      } else if (floatSearch.isSelected()) {
        hideSearch.setSelected(true);
      } else if (hideSearch.isSelected()) {
        showResultsInDialog.setSelected(true);
      } else if (showResultsInDialog.isSelected()) {
        searchAllBases.setSelected(true);
      } else {
        increment.setSelected(true);
      }
      increment.revalidate();
      increment.repaint();

      searchField.requestFocus();
    }
  }
Esempio n. 3
0
  public void Update(String event) {
    if (event.equals("time")) {
      MODEL.time =
          "<html>Elapsed Time: <font color =\"GREEN\">"
              + MODEL.watch.getElapsedTimeSecs()
              + "</font> Seconds</html>";
      timeLab.setText(MODEL.time);
    } else if (event.equals("invalid")) {
      MODEL.answerInvalid();
      msg.setText(MODEL.msg);
    } else if (event.equals("correct")) {
      MODEL.answerCorrect();

      score.setText(MODEL.str);
      msg.setText(MODEL.msg);
      problem.setText(MODEL.prb);
      entry.setText("");
      entry.requestFocus();
    } else if (event.equals("wrong")) {
      MODEL.answerWrong();
      msg.setText(MODEL.msg);
    } else if (event.equals("replay")) {
      MODEL.gameReplay();

      problem.setText(MODEL.prb);
      score.setText(MODEL.str);
      msg.setText(MODEL.msg);
      timeLab.setText(MODEL.time);
    } else System.out.println("Invalid Update Command");
  }
Esempio n. 4
0
 void jListOnlineUsers_mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {
     jTextFieldTargetUser.setText(((HostItem) jListOnlineUsers.getSelectedValue()).name);
     Flasher.instance().flashBackground(jTextFieldTargetUser, Color.yellow, 2);
     jTextFieldSendMessages.requestFocus();
   }
 }
Esempio n. 5
0
  // Function use to Clear all TextFields of Window.
  void txtClear() {

    txtNo.setText("");
    txtName.setText("");
    txtDate.setText("");
    txtBal.setText("");
    txtNo.requestFocus();
  }
Esempio n. 6
0
  // Constructor
  public DeleteArchiveFrame(AmazonGlacierClient client, String vaultName, int region) {
    super("Delete Archive");

    int width = 200;
    int height = 170;

    Color wc = Color.WHITE;

    deleteClient = client;
    deleteVault = vaultName;

    JLabel label1 =
        new JLabel("ArchiveID to Delete from " + Endpoint.getTitleByIndex(region) + ":");
    jtfDeleteField = new JTextField(100);
    jbtDelete = new JButton("Delete");
    jbtBack = new JButton("Back");

    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout());
    p1.add(label1);
    p1.setBackground(wc);

    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(jtfDeleteField);
    jtfDeleteField.addMouseListener(new ContextMenuMouseListener());
    jtfDeleteField.setFocusable(true);
    p2.setBackground(wc);

    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout());
    p3.add(jbtDelete);
    jbtDelete.addActionListener(this);
    jbtDelete.setBackground(wc);
    p3.add(jbtBack);
    jbtBack.addActionListener(this);
    jbtBack.setBackground(wc);
    p3.setBackground(wc);

    JPanel p4 = new JPanel();
    p4.setLayout(new BorderLayout());
    p4.setBackground(wc);
    p4.add(p1, BorderLayout.NORTH);
    p4.add(p2, BorderLayout.CENTER);
    p4.add(p3, BorderLayout.SOUTH);

    setContentPane(p4);

    // Prepare for display
    pack();
    if (width < getWidth()) // prevent setting width too small
    width = getWidth();
    if (height < getHeight()) // prevent setting height too small
    height = getHeight();
    centerOnScreen(width, height);
    jtfDeleteField.setText("");
    jtfDeleteField.requestFocus();
  }
 /**
  * This will be called when the user clicks the "Send" button or presses return in the text-input
  * box. It posts the contents of the input box to the transcript. If the thread is not running, it
  * creates and starts a new thread.
  */
 public void actionPerformed(ActionEvent evt) {
   postMessage("SENT: " + input.getText());
   input.selectAll();
   input.requestFocus();
   if (running == false) {
     runner = new Thread(this);
     running = true;
     runner.start();
   }
 }
 /** Select the strategy for matching. */
 public void selectStrategy() {
   _currentStrategy = _strategies.get(_strategyBox.getSelectedIndex());
   removeListener();
   _pim.setStrategy(_currentStrategy);
   updateTextField();
   updateExtensionLabel();
   updateList();
   addListener();
   _textField.requestFocus();
 }
Esempio n. 9
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == jbtDelete) {
      if ((jtfDeleteField.getText().trim().equals(""))) {
        JOptionPane.showMessageDialog(
            null,
            "Enter the Archive ID of the file to be deleted.",
            "Error",
            JOptionPane.ERROR_MESSAGE);
      } else {

        try {
          String archiveId = jtfDeleteField.getText().trim();

          // Banish the extra chars printed in early logs.
          String sendThis = archiveId.replaceAll("[^\\p{Print}]", "");

          String vaultName = deleteVault;

          // Delete the archive.
          deleteClient.deleteArchive(
              new DeleteArchiveRequest().withVaultName(vaultName).withArchiveId(sendThis));

          JOptionPane.showMessageDialog(
              null, "Deleted archive successfully.", "Success", JOptionPane.INFORMATION_MESSAGE);

        } catch (AmazonServiceException k) {
          JOptionPane.showMessageDialog(
              null,
              "The server returned an error. Wait 24 hours after submitting an archive to attempt a delete. Also check that correct location of archive has been set on the previous page.",
              "Error",
              JOptionPane.ERROR_MESSAGE);
          System.out.println("" + k);
        } catch (AmazonClientException i) {
          JOptionPane.showMessageDialog(
              null,
              "Client Error. Check that all fields are correct. Archive not deleted.",
              "Error",
              JOptionPane.ERROR_MESSAGE);
        } catch (Exception j) {
          JOptionPane.showMessageDialog(
              null, "Archive not deleted. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE);
        }

        jtfDeleteField.setText("");
        jtfDeleteField.requestFocus();
      }

    } else if (e.getSource() == jbtBack) {
      this.setVisible(false);
      dispose();
    } else {
      JOptionPane.showMessageDialog(this, "Please choose a valid action.");
    }
  }
Esempio n. 10
0
  /**
   * Creates the terminal for interaction with client from server
   *
   * @param s
   */
  public Terminal(Server s) {
    mServer = s;

    TextFieldListener tfListener = new TextFieldListener();
    input.addActionListener(tfListener);

    Display = new javax.swing.JLayeredPane();

    input.setColumns(50);
    output.setColumns(50);
    output.setRows(30);
    output.setEditable(false);

    output.setBackground(Color.BLACK);
    output.setForeground(Color.WHITE);

    input.requestFocus(); // start with focus on this field

    output.setBounds(0, 0, 550, 310);
    Display.add(output, javax.swing.JLayeredPane.DEFAULT_LAYER);

    input.setBounds(0, 320, 550, 25);
    Display.add(input, javax.swing.JLayeredPane.DEFAULT_LAYER);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        Display,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        550,
                        javax.swing.GroupLayout.PREFERRED_SIZE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                Display,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                350,
                                javax.swing.GroupLayout.PREFERRED_SIZE))));

    pack();
  }
Esempio n. 11
0
 public void fokusniSe() {
   Container panel = null;
   for (Container comp = this; comp != null; comp = comp.getParent()) {
     if (comp instanceof JTabbedPane) {
       final JTabbedPane tabpane = (JTabbedPane) comp;
       tabpane.setSelectedComponent(panel);
       break;
     }
     panel = comp;
   }
   jtext.requestFocus();
 }
Esempio n. 12
0
 public void actionPerformed(ActionEvent event) {
   if (event.getSource() == okButton) {
     this.setVisible(false);
   } else if (event.getSource() == rightArrow) {
     try {
       araucaria
           .getArgument()
           .addOwnersToSelected(araucaria, ownerSourceTableModel.getSelectedOwners());
       ownerNodesTableModel.updateTable(araucaria.getArgument().getSelectedVertexOwners());
       araucaria.undoStack.push(new EditAction(araucaria, "adding owners"));
     } catch (Exception ex) {
       return;
     }
   } else if (event.getSource() == leftArrow) {
     // Delete owners only from selected vertices
     araucaria.getArgument().deleteOwners(ownerNodesTableModel.getSelectedOwners(), true);
     ownerNodesTableModel.updateTable(araucaria.getArgument().getSelectedVertexOwners());
     araucaria.undoStack.push(new EditAction(araucaria, "removing owners"));
   } else if (event.getSource() == addOwnerButton) {
     String newOwnerName = ownerText.getText();
     if (newOwnerName.length() == 0) {
       return;
     }
     ownerSourceTableModel.addOwner(newOwnerName);
     ownerText.setText("");
     ownerText.requestFocus();
   } else if (event.getSource() == deleteSourceButton) {
     Vector selected = null;
     try {
       selected = ownerSourceTableModel.getSelectedOwners();
     } catch (Exception ex) {
       return;
     }
     if (selected == null || selected.size() == 0) return;
     int action =
         JOptionPane.showConfirmDialog(
             this,
             "<html><center><font color=red face=helvetica><b>Delete selected owners?</b></font></center></html>",
             "Delete owners?",
             JOptionPane.YES_NO_OPTION,
             JOptionPane.WARNING_MESSAGE,
             null);
     if (action == 1) return;
     araucaria.getArgument().deleteOwners(selected);
     // Delete owners from ALL vertices
     araucaria.getArgument().deleteOwners(selected, false);
     ownerSourceTableModel.updateTable(araucaria.getArgument().getOwnerList());
     ownerNodesTableModel.updateTable(araucaria.getArgument().getSelectedVertexOwners());
   }
 }
Esempio n. 13
0
 void jTextFieldSendSubject_keyPressed(KeyEvent e) {
   if (e.getKeyCode() == e.VK_DOWN) {
     String s = subjectHistory.forward();
     if (s != null) {
       jTextFieldSendSubject.setText(s);
     }
   } else if (e.getKeyCode() == e.VK_UP) {
     String s = subjectHistory.back();
     if (s != null) {
       jTextFieldSendSubject.setText(s);
     }
   } else if (e.getKeyChar() == '\n') {
     jTextFieldSendMessages.requestFocus();
   }
 }
Esempio n. 14
0
  public BuilderConfigDialog(Window parent, BuilderConfig config) {
    super(parent, "Modpack Properties", ModalityType.DOCUMENT_MODAL);

    this.config = config;

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    initComponents();
    setResizable(false);
    pack();
    setLocationRelativeTo(parent);

    copyFrom();

    nameText.requestFocus();
  }
Esempio n. 15
0
  private void myInit(SanBootView _view, Backupable _bakable, int _mode, int _type) {
    view = _view;
    bakable = _bakable;
    mode = _mode;
    type = _type;

    setupProfileType();
    setupList();
    setupLanguage();

    if (mode == ProfileChooser.MODE_SAVEAS || mode == ProfileChooser.MODE_SAVE) {
      saveAsProfile = new UniProfile();
      nameTextField.requestFocus();
    }
  }
Esempio n. 16
0
  public static void connect() {
    final int port = 1337;
    final String host = "chat.linkura.se";

    userName = userNameBox.getText().trim();
    int count = 0;
    for (int i = 0; i < userName.length(); i++) {
      if (userName.charAt(i) == ' ') {
        count++;
      }
    }

    if (count != 0) {
      error.setText("Du får inte ha mellanslag i användarnamnet!");
    } else if (userName.isEmpty()) {
      error.setText("Skriv ett användarnamn!");
    } else if (!userName.matches("[a-öA-Ö0-9]+")) {
      error.setText("Användarnamnet får bara innhålla siffror och bokstäver!");
    } else if (userName.length() > 15) {
      error.setText("Ditt användarnamn får max vara 15 tecken!");
    } else {
      try {
        Socket socket = new Socket(host, port);
        testThread = new TestThread(socket);
        Thread x = new Thread(testThread);
        x.start();

        PrintWriter out = new PrintWriter(socket.getOutputStream());

        out.println("NICK " + userName);
        out.flush();

        userNameLabel.setVisible(false);
        userNameBox.setVisible(false);
        connectButton.setVisible(false);
        messageField.setVisible(true);
        messageField.requestFocus();
        send.setVisible(true);
        spConversation.setVisible(true);
        spUsersOnline.setVisible(true);
        disconnect.setVisible(true);

      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
 /** Toggle visibility of this frame. Warning, it behaves like a modal dialog. */
 public void setVisible(boolean vis) {
   assert EventQueue.isDispatchThread();
   validate();
   if (vis) {
     DrJavaRoot.installModalWindowAdapter(this, LambdaUtil.NO_OP, CANCEL);
     setOwnerEnabled(false);
     selectStrategy();
     _textField.requestFocus();
     toFront();
   } else {
     DrJavaRoot.removeModalWindowAdapter(this);
     setOwnerEnabled(true);
     if (_owner != null) {
       _owner.toFront();
     }
   }
   super.setVisible(vis);
 }
Esempio n. 18
0
 @Override
 public void actionPerformed(ActionEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == b1) {
     int index = box.getSelectedIndex();
     String column = "";
     if (index == 0) column = "ename";
     else if (index == 1) column = "hiredate";
     else column = "deptno";
     String data = tf.getText().trim();
     if (data.length() < 1) {
       tf.requestFocus();
       return;
     }
     getFindData(column, data);
   }
   if (e.getSource() == b2) {
     getData();
   }
 }
Esempio n. 19
0
  /**
   * Constructor for FindDialog
   *
   * @param type
   * @param ta Description of the Parameter
   */
  public FindDialog(JFrame parent, JTextComponent ta) {
    super(parent, "Find in Output", true);
    this.textarea = ta;
    textarea.requestFocus();

    JPanel panel = new JPanel();
    KappaLayout layout = new KappaLayout();
    panel.setLayout(layout);
    panel.setBorder(new javax.swing.border.EmptyBorder(11, 11, 11, 11));
    setContentPane(panel);

    JLabel find_label = new JLabel("Find:");
    final JTextField to_find = new JTextField(20);
    JButton find_btn = new JButton("Find");
    JButton find_next_btn = new JButton("Find Next");
    JButton cancel_btn = new JButton("Close");
    final JCheckBox wrap_cb = new JCheckBox("Wrap search");
    wrap_cb.setSelected(true);

    panel.add(find_label, "0, 0, 1, 1, W, w, 3");
    panel.add(to_find, "0, 1, 1, 1, 0, w, 3");
    panel.add(wrap_cb, "0, 2, 1, 1, 0, w, 3");

    JPanel btn_panel = new JPanel(new KappaLayout());
    btn_panel.add(find_btn, "0, 0, 1, 1, 0, w, 3");
    btn_panel.add(find_next_btn, "0, 1, 1, 1, 0, w, 3");
    btn_panel.add(cancel_btn, "0, 2, 1, 1, 0, w, 3");
    panel.add(btn_panel, "1, 0, 1, 3, 0, h, 5");

    find_btn.addActionListener(new Finder(to_find, textarea, false, wrap_cb.isSelected()));
    find_next_btn.addActionListener(new Finder(to_find, textarea, true, wrap_cb.isSelected()));
    cancel_btn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            setVisible(false);
            dispose();
          }
        });
    pack();
    to_find.requestFocus();
  }
  @SuppressWarnings("deprecation")
  public void logar() {
    SistemaAcesso sist = new SistemaAcesso();
    sist.addArrayList();

    try {
      if (sist.buscarLogin(tlogin.getText(), tsenha.getText())) {

        GUIMenuPrincipal menu = new GUIMenuPrincipal(bn, sist.getPerfil(), sist.getAgencia());
        menu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        dispose();
      } else {
        tsenha.setText("");
        tlogin.setText("");
        JOptionPane.showMessageDialog(null, "Login e/ou senha incorretos");
        tlogin.requestFocus();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 21
0
  // Function use By Buttons of Window to Perform Action as User Click Them.
  public void actionPerformed(ActionEvent ae) {

    Object obj = ae.getSource();

    if (obj == btnDel) {
      if (txtNo.getText().equals("")) {
        JOptionPane.showMessageDialog(
            this,
            "Please! Provide Id of Customer.",
            "BankSystem - EmptyField",
            JOptionPane.PLAIN_MESSAGE);
        txtNo.requestFocus();
      } else {
        deletion(); // Confirm Deletion of Current Record.
      }
    }
    if (obj == btnCancel) {
      txtClear();
      setVisible(false);
      dispose();
    }
  }
Esempio n. 22
0
  private void myInit2(
      SanBootView _view, Backupable _bakable, int _mode, int _type, BootHost host) {
    view = _view;
    bakable = _bakable;
    mode = _mode;
    type = _type;

    setupProfileType();
    setupList();
    setupLanguage();

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
    Date date = new Date();
    String time = df.format(date);
    System.out.println(host.getID() + "-" + time);
    nameTextField.setText(host.getID() + "-" + time);

    if (mode == ProfileChooser.MODE_SAVEAS || mode == ProfileChooser.MODE_SAVE) {
      saveAsProfile = new UniProfile();
      nameTextField.requestFocus();
    }
  }
  // Constructor connection receiving a socket number
  public ClientGUI(String host, int port, int udpPort) {

    super("Clash of Clans");
    defaultPort = port;
    defaultUDPPort = udpPort;
    defaultHost = host;

    // the server name and the port number
    JPanel serverAndPort = new JPanel(new GridLayout(1, 5, 1, 3));
    tfServer = new JTextField(host);
    tfPort = new JTextField("" + port);
    tfPort.setHorizontalAlignment(SwingConstants.RIGHT);

    // CHAT COMPONENTS
    chatStatus = new JLabel("Please login first", SwingConstants.LEFT);
    chatField = new JTextField(18);
    chatField.setBackground(Color.WHITE);

    JPanel chatControls = new JPanel();
    chatControls.add(chatStatus);
    chatControls.add(chatField);
    chatControls.setBounds(0, 0, 200, 50);

    chatArea = new JTextArea("Welcome to the Chat room\n", 80, 80);
    chatArea.setEditable(false);
    JScrollPane jsp = new JScrollPane(chatArea);
    jsp.setBounds(0, 50, 200, 550);

    JPanel chatPanel = new JPanel(null);
    chatPanel.setSize(1000, 600);
    chatPanel.add(chatControls);
    chatPanel.add(jsp);

    // LOGIN COMPONENTS
    mainLogin = new MainPanel();
    mainLogin.add(new JLabel("Main Login"));

    usernameField = new JTextField("user", 15);
    passwordField = new JTextField("password", 15);
    login = new CButton("Login");
    login.addActionListener(this);

    sideLogin = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    sideLogin.add(usernameField);
    sideLogin.add(passwordField);
    sideLogin.add(login);

    // MAIN MENU COMPONENTS
    mainMenu = new MainPanel();
    mmLabel = new JLabel("Main Menu");
    timer = new javax.swing.Timer(1000, this);
    mainMenu.add(mmLabel);

    sideMenu = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    cmButton = new CButton("Customize Map");
    tmButton = new CButton("Troop Movement");
    gsButton = new CButton("Game Start");
    logout = new CButton("Logout");
    cmButton.addActionListener(this);
    tmButton.addActionListener(this);
    gsButton.addActionListener(this);
    logout.addActionListener(this);
    sideMenu.add(cmButton);
    // sideMenu.add(tmButton);
    sideMenu.add(gsButton);
    sideMenu.add(logout);

    // CM COMPONENTS
    mainCM = new MainPanel(new GridLayout(mapSize, mapSize));
    tiles = new Tile[mapSize][mapSize];
    int tileSize = mainCM.getWidth() / mapSize;
    for (int i = 0; i < mapSize; i++) {
      tiles[i] = new Tile[mapSize];
      for (int j = 0; j < mapSize; j++) {
        tiles[i][j] = new Tile(i, j);
        tiles[i][j].setPreferredSize(new Dimension(tileSize, tileSize));
        tiles[i][j].setSize(tileSize, tileSize);
        tiles[i][j].addActionListener(this);

        if ((i + j) % 2 == 0) tiles[i][j].setBackground(new Color(102, 255, 51));
        else tiles[i][j].setBackground(new Color(51, 204, 51));

        mainCM.add(tiles[i][j]);
      }
    }

    sideCM = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    cmBack = new CButton("Main Menu");
    cmBack.setSize(150, 30);
    cmBack.setPreferredSize(new Dimension(150, 30));
    cmBack.addActionListener(this);
    sideCM.add(cmBack);

    // TM COMPONENTS
    mainTM = new MainPanel(null);
    mapTM = new Map(600);
    mapTM.setPreferredSize(new Dimension(600, 600));
    mapTM.setSize(600, 600);
    mapTM.setBounds(0, 0, 600, 600);
    mainTM.add(mapTM);

    sideTM = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    tmBack = new CButton("Main Menu");
    tmBack.setSize(150, 30);
    tmBack.setPreferredSize(new Dimension(150, 30));
    tmBack.addActionListener(this);
    sideTM.add(tmBack);

    JRadioButton button;
    ButtonGroup group;

    ub = new ArrayList<JRadioButton>();
    group = new ButtonGroup();

    button = new JRadioButton("Barbarian");
    button.addActionListener(this);
    ub.add(button);
    sideTM.add(button);
    group.add(button);

    button = new JRadioButton("Archer");
    button.addActionListener(this);
    ub.add(button);
    sideTM.add(button);
    group.add(button);

    createBuildings();
    bb = new ArrayList<JRadioButton>();

    group = new ButtonGroup();

    JRadioButton removeButton = new JRadioButton("Remove Building");
    bb.add(removeButton);
    sideCM.add(removeButton);
    group.add(removeButton);

    for (int i = 0; i < bList.size(); i++) {
      button = new JRadioButton(bList.get(i).getName() + '-' + bList.get(i).getQuantity());
      bb.add(button);
      sideCM.add(button);
      group.add(button);
    }

    mainPanels = new MainPanel(new CardLayout());
    mainPanels.add(mainLogin, "Login");
    mainPanels.add(mainMenu, "Menu");
    mainPanels.add(mainCM, "CM");
    mainPanels.add(mainTM, "TM");

    sidePanels = new SidePanel(new CardLayout());
    sidePanels.add(sideLogin, "Login");
    sidePanels.add(sideMenu, "Menu");
    sidePanels.add(sideCM, "CM");
    sidePanels.add(sideTM, "TM");

    JPanel mainPanel = new JPanel(null);
    mainPanel.setSize(1000, 600);
    mainPanel.add(sidePanels);
    mainPanel.add(mainPanels);
    mainPanel.add(chatPanel);

    add(mainPanel, BorderLayout.CENTER);

    try {
      setIconImage(ImageIO.read(new File("images/logo.png")));
    } catch (IOException exc) {
      exc.printStackTrace();
    }

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(1000, 600);
    setVisible(true);
    setResizable(false);
    chatField.requestFocus();
  }
  /**
   * Use the GUI results to set up the variables needed to run the algorithm.
   *
   * @return <code>true</code> if parameters set successfully, <code>false</code> otherwise.
   */
  private boolean setVariables() {
    String tmpStr;

    System.gc();

    if (replaceImage.isSelected()) {
      displayLoc = REPLACE;
    } else if (newImage.isSelected()) {
      displayLoc = NEW;
    }

    tmpStr = textSearchWindowSide.getText();

    if (testParameter(tmpStr, 5, 101)) {
      searchWindowSide = Integer.valueOf(tmpStr).intValue();
    } else {
      MipavUtil.displayError("Search window side must be between 5 and 101");
      textSearchWindowSide.requestFocus();
      textSearchWindowSide.selectAll();

      return false;
    }

    if ((searchWindowSide % 2) == 0) {
      MipavUtil.displayError("Search window side must be an odd number");
      textSearchWindowSide.requestFocus();
      textSearchWindowSide.selectAll();
      return false;
    }

    tmpStr = textSimilarityWindowSide.getText();

    if (testParameter(tmpStr, 3, 99)) {
      similarityWindowSide = Integer.valueOf(tmpStr).intValue();
    } else {
      MipavUtil.displayError("Similarity window side must be between 3 and 99");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();

      return false;
    }

    if ((similarityWindowSide % 2) == 0) {
      MipavUtil.displayError("Similarity window side must be an odd number");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();
      return false;
    }

    if (similarityWindowSide >= searchWindowSide) {
      MipavUtil.displayError("Similarity window side must be less than search window side");
      textSimilarityWindowSide.requestFocus();
      textSimilarityWindowSide.selectAll();
      return false;
    }

    tmpStr = textNoiseStandardDeviation.getText();

    if (testParameter(tmpStr, 0.001, 1000.0)) {
      noiseStandardDeviation = Float.valueOf(tmpStr).floatValue();
    } else {
      MipavUtil.displayError("Radius must be between 0.001 and 1000.0");
      textNoiseStandardDeviation.requestFocus();
      textNoiseStandardDeviation.selectAll();

      return false;
    }

    doRician = doRicianCheckBox.isSelected();

    if (doRician) {
      tmpStr = textDegree.getText();
      if (testParameter(tmpStr, 1.0, 10.0)) {
        degreeOfFiltering = Float.valueOf(tmpStr).floatValue();
      } else {
        MipavUtil.displayError("Degree of filtering must be between 1.0 and 10.0");
        textDegree.requestFocus();
        textDegree.selectAll();
      }
    }

    if (image.getNDims() > 2) {
      image25D = image25DCheckBox.isSelected();
    }

    return true;
  }
 public void focusToExtensionField() {
   myExtensionField.selectAll();
   myExtensionField.requestFocus();
 }
 public void focusToNameField() {
   myNameField.selectAll();
   myNameField.requestFocus();
 }
Esempio n. 27
0
 @Override
 public void windowOpened(WindowEvent arg0) {
   jtfDeleteField.setText("");
   jtfDeleteField.requestFocus();
 }
Esempio n. 28
0
  private void createUI() {

    setTitle(strings.getString("window.title"));

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    mailBodyArea = new JTextArea(20, 70);
    mailBodyArea.setLineWrap(true);
    mailBodyArea.setWrapStyleWord(true);
    mailBodyArea.setFont(new Font("monospaced", Font.PLAIN, 12));

    scrollPane = new JScrollPane(mailBodyArea);

    mailSubjectField = new JTextField(20);
    mailToField = new JTextField(20);
    mailFromField = new JTextField(20);

    mailSubjectLabel = new JLabel(strings.getString("subject.label"));
    mailToLabel = new JLabel(strings.getString("to.label"));
    setToFieldEditable(false);

    toLabelListener =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            mouseClicked_searchSource();
          }

          public void mouseEntered(MouseEvent e) {
            setCursor(new Cursor(Cursor.HAND_CURSOR));
          }

          public void mouseExited(MouseEvent e) {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          }
        };

    mailFromLabel = new JLabel(strings.getString("from.label"));

    sendMailButton = new JButton(strings.getString("sendmail.text"));
    sendMailButton.setIcon(
        new ImageIcon(getClass().getResource(strings.getString("sendmail.icon"))));
    sendMailButton.setToolTipText(strings.getString("sendmail.tooltip"));
    cancelButton = new JButton(strings.getString("cancel.text"));
    cancelButton.setIcon(new ImageIcon(getClass().getResource(strings.getString("cancel.icon"))));
    cancelButton.setToolTipText(strings.getString("cancel.tooltip"));

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPerformed_cancel();
          }
        });

    sendMailButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPerformed_sendMail();
          }
        });

    Container pane = this.getContentPane();

    container.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 0, 5);
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    pane.add(mailFromLabel, c);
    c.gridx = 1;
    pane.add(mailFromField, c);

    c.gridx = 0;
    c.gridy = 1;
    pane.add(mailToLabel, c);
    c.gridx = 1;
    pane.add(mailToField, c);

    c.gridx = 0;
    c.gridy = 2;
    pane.add(mailSubjectLabel, c);
    c.gridx = 1;
    pane.add(mailSubjectField, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    pane.add(scrollPane, c);

    JPanel bPane = new JPanel();
    bPane.add(sendMailButton);
    bPane.add(cancelButton);

    c.gridx = 0;
    c.gridy = 4;
    pane.add(bPane, c);

    mailToField.requestFocus();
  }
  /**
   * Use the GUI results to set up the variables needed to run the algorithm.
   *
   * @return <code>true</code> if parameters set successfully, <code>false</code> otherwise.
   */
  private boolean setVariables() {
    String tmpStr;
    int i;

    int totLength = image.getExtents()[0];

    for (i = 1; i < image.getNDims(); i++) {
      totLength *= image.getExtents()[i];
    }

    tmpStr = greenMergingText.getText();
    mergingDistance = Float.parseFloat(tmpStr);
    if (mergingDistance < 0.0f) {
      MipavUtil.displayError("Merging distance cannot be less than 0");
      greenMergingText.requestFocus();
      greenMergingText.selectAll();
      return false;
    }

    tmpStr = redMinText.getText();
    redMin = Integer.parseInt(tmpStr);

    if (redMin < 1) {
      MipavUtil.displayError("red minimum must be at least 1");
      redMinText.requestFocus();
      redMinText.selectAll();

      return false;
    } else if (redMin > totLength) {
      MipavUtil.displayError("red minimum must not exceed " + totLength);
      redMinText.requestFocus();
      redMinText.selectAll();

      return false;
    }

    tmpStr = redFractionText.getText();
    redFraction = Float.parseFloat(tmpStr);

    if (redFraction <= 0.0f) {
      MipavUtil.displayError("red fraction must be greater than zero");
      redFractionText.requestFocus();
      redFractionText.selectAll();

      return false;
    } else if (redFraction > 1.0f) {
      MipavUtil.displayError("red fraction must not exceed one");
      redFractionText.requestFocus();
      redFractionText.selectAll();

      return false;
    }

    tmpStr = greenMinText.getText();
    greenMin = Integer.parseInt(tmpStr);

    if (greenMin < 1) {
      MipavUtil.displayError("green minimum must be at least 1");
      greenMinText.requestFocus();
      greenMinText.selectAll();

      return false;
    } else if (greenMin > totLength) {
      MipavUtil.displayError("green minimum must not exceed " + totLength);
      greenMinText.requestFocus();
      greenMinText.selectAll();

      return false;
    }

    tmpStr = greenFractionText.getText();
    greenFraction = Float.parseFloat(tmpStr);

    if (greenFraction <= 0.0f) {
      MipavUtil.displayError("green fraction must be greater than zero");
      greenFractionText.requestFocus();
      greenFractionText.selectAll();

      return false;
    } else if (greenFraction > 1.0f) {
      MipavUtil.displayError("green fraction must not exceed one");
      greenFractionText.requestFocus();
      greenFractionText.selectAll();

      return false;
    }

    tmpStr = blueMinText.getText();
    blueMin = Integer.parseInt(tmpStr);
    if (blueMin <= 0) {
      MipavUtil.displayError("Number of blue pixels must be greater than 0");
      blueMinText.requestFocus();
      blueMinText.selectAll();
      return false;
    } else if (blueMin > totLength) {
      MipavUtil.displayError("blue minimum must not exceed " + totLength);
      blueMinText.requestFocus();
      blueMinText.selectAll();

      return false;
    }

    if (oneButton.isSelected()) {
      greenRegionNumber = 1;
    } else if (twoButton.isSelected()) {
      greenRegionNumber = 2;
    } else if (threeButton.isSelected()) {
      greenRegionNumber = 3;
    } else {
      greenRegionNumber = 4;
    }

    twoGreenLevels = twoBox.isSelected();

    tmpStr = blueValueText.getText();
    blueBoundaryFraction = Float.parseFloat(tmpStr);
    if (blueBoundaryFraction < 0.0f) {
      MipavUtil.displayError("Blue boundary fraction cannot be less than 0.0");
      blueValueText.requestFocus();
      blueValueText.selectAll();
      return false;
    } else if (blueBoundaryFraction > 1.0f) {
      MipavUtil.displayError("Blue boundary value cannot be greater than 1.0");
      blueValueText.requestFocus();
      blueValueText.selectAll();
      return false;
    }

    blueSmooth = blueSmoothBox.isSelected();

    tmpStr = interpolationText.getText();
    interpolationDivisor = Float.parseFloat(tmpStr);
    if (interpolationDivisor <= 1.0f) {
      MipavUtil.displayError("Interpolation divisor must be greater than 1");
      interpolationText.requestFocus();
      interpolationText.selectAll();
      return false;
    }

    return true;
  } // end setVariables()
Esempio n. 30
0
 public void setReady() {
   textField.setEditable(true);
   textField.requestFocus();
 }