private void moveMousePointerOnButton(final JButton button) { Application application = ApplicationManager.getApplication(); if (application != null && application.hasComponent(UISettings.class)) { if (button != null && UISettings.getInstance().MOVE_MOUSE_ON_DEFAULT_BUTTON) { Point p = button.getLocationOnScreen(); Rectangle r = button.getBounds(); try { Robot robot = new Robot(); robot.mouseMove(p.x + r.width / 2, p.y + r.height / 2); } catch (AWTException e) { LOG.warn(e); } } } }
@Test public void testEntrarComLoginQualquer() { try { // fail("Not yet implemented"); try { Thread.sleep(3000); } catch (Exception e) { } JButton botaoEntrar = telaLogin.getEntrar(); Robot r = new Robot(); r.delay(3000); Point p = botaoEntrar.getLocationOnScreen(); r.mouseMove(p.x + botaoEntrar.getWidth() / 2, p.y + botaoEntrar.getHeight() / 2); r.mousePress(InputEvent.BUTTON1_MASK); r.delay(3000); r.mouseRelease(InputEvent.BUTTON1_MASK); r.delay(3000); } catch (AWTException exc) { exc.printStackTrace(); fail("awt exception no teste da telaLogin clicar botao entrar"); } }
public void actionPerformed(ActionEvent arg0) { String cmd = arg0.getActionCommand(); if (cmd == "Up") { int[] ind = levelList.getSelectedIndices(); if (ind.length > 1) { levelList.setSelectedIndex(ind[0]); } else if (ind.length == 1 && ind[0] > 0) { DefaultListModel model = (DefaultListModel) levelList.getModel(); Object obj = model.remove(ind[0]); model.add(ind[0] - 1, obj); levelList.setSelectedIndex(ind[0] - 1); } } else if (cmd == "Down") { int[] ind = levelList.getSelectedIndices(); if (ind.length > 1) { levelList.setSelectedIndex(ind[0]); } else if (ind.length == 1 && ind[0] < (levelList.getModel().getSize() - 1)) { DefaultListModel model = (DefaultListModel) levelList.getModel(); Object obj = model.remove(ind[0]); model.add(ind[0] + 1, obj); levelList.setSelectedIndex(ind[0] + 1); } } else if (cmd == "Add") { String result = JOptionPane.showInputDialog( this, "Please Enter the new factor Level", "New Factor Level", JOptionPane.INFORMATION_MESSAGE); if (result != null) { if (result.length() > 0) { ((DefaultListModel) levelList.getModel()).add(0, result); } else { int b = JOptionPane.showConfirmDialog( this, "Add an empty character vector to the factor levels?"); if (b == JOptionPane.OK_OPTION) { ((DefaultListModel) levelList.getModel()).add(0, result); } } } } else if (cmd == "Delete") { int[] ind = levelList.getSelectedIndices(); if (ind.length > 0) { DefaultListModel model = (DefaultListModel) levelList.getModel(); for (int i = ind.length - 1; i >= 0; i--) { model.remove(ind[i]); } } } else if (cmd == "Cancel") { this.dispose(); } else if (cmd == "OK") { ArrayList newLevels = new ArrayList(); DefaultListModel model = (DefaultListModel) levelList.getModel(); for (int i = 0; i < model.getSize(); i++) { newLevels.add(model.get(i)); } String rLevels = RController.makeRStringVector(newLevels); /* String order = "FALSE"; if(ordered.isSelected()) order="TRUE"; else order="FALSE"; * */ REXPInteger varID = (REXPInteger) SimDat.eval("which(variableNames(" + rModelName + ") == '" + variable + "')", curEnv); String call = "levels(variables(" + rModelName + ")[[" + varID.asIntegers()[0] + "]]) <- " + rLevels; if (cntr != null) { call += "\n" + cntr.getCall(variable); } SimDat.execute(call, curEnv); // call = call.replace("\"", "\\\""); // SimDat.eval(call); this.dispose(); } else if (cmd == "Contrasts") { cntr = new ContrastDialog(null); cntr.setLocation(contrast.getLocationOnScreen()); cntr.setTitle("Set Contrast Codes"); cntr.setVisible(true); } }