Ejemplo n.º 1
0
  // The difference between X-system and Win32: on Win32 Dragged event start to be generated after
  // any mouse drag.
  // On X-systems Dragged event first fired when mouse has left the SMUDGE area
  public void smallWin32Drag(int pixelsX, int pixelsY) {
    // by the X-axis
    robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2);
    // drag for a short distance
    robot.mousePress(InputEvent.BUTTON1_MASK);
    System.out.println(" pixelsX = " + pixelsX + " pixelsY = " + pixelsY);
    for (int i = 1; i <= pixelsX; i++) {
      System.out.println("Moving a mouse by X");
      robot.mouseMove(fp.x + frame.getWidth() / 2 + i, fp.y + frame.getHeight() / 2);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    if (!dragged) {
      throw new RuntimeException(
          "Test failed. Dragged event (by the X-axis) didn't occur in the SMUDGE area. Dragged = "
              + dragged);
    }

    // the same with Y-axis
    robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    for (int i = 1; i <= pixelsY; i++) {
      System.out.println("Moving a mouse by Y");
      robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2 + i);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    if (!dragged) {
      throw new RuntimeException(
          "Test failed. Dragged event (by the Y-axis) didn't occur in the SMUDGE area. Dragged = "
              + dragged);
    }
  }
Ejemplo n.º 2
0
  public void smallDrag(int pixelsX, int pixelsY) {
    // by the X-axis
    robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2);
    // drag for a short distance
    robot.mousePress(InputEvent.BUTTON1_MASK);
    for (int i = 1; i < pixelsX; i++) {
      robot.mouseMove(fp.x + frame.getWidth() / 2 + i, fp.y + frame.getHeight() / 2);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    if (dragged) {
      throw new RuntimeException(
          "Test failed. Dragged event (by the X-axis) occured in SMUDGE area. Dragged = "
              + dragged
              + ". Clicked = "
              + clicked);
    }

    // the same with Y-axis
    robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    for (int i = 1; i < pixelsY; i++) {
      robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2 + i);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    if (dragged) {
      throw new RuntimeException(
          "Test failed. Dragged event (by the Y-axis) occured in SMUDGE area. Dragged = "
              + dragged
              + ". Clicked = "
              + clicked);
    }
  }
Ejemplo n.º 3
0
 private void zentriere(java.awt.Frame hf) {
   java.awt.Point OL = hf.getLocationOnScreen();
   OL.translate(hf.getWidth() / 2, hf.getHeight() / 2);
   OL.translate(-this.getWidth() / 2, -this.getHeight() / 2);
   if (OL.getX() < 0) OL.setLocation(0, OL.getY());
   if (OL.getY() < 0) OL.setLocation(OL.getX(), 0);
   this.setLocation(OL);
 }
Ejemplo n.º 4
0
 /**
  * Displays a dialog that allows the user to add/remove MIDI event types to to/from a MIDI event
  * map.
  *
  * @param midiDescriptor The parent <code>MidiDescriptor</code>
  * @param eventMap The <code>EventMap</code> to be edited.
  */
 public static void showEditEventMappingDialog(MidiDescriptor midiDescriptor, EventMap eventMap) {
   Frame m = getMainFrame();
   EditEventMappingDialog d = new EditEventMappingDialog(m, midiDescriptor, eventMap);
   d.pack();
   d.setLocation(
       m.getX() + m.getWidth() / 2 - d.getWidth() / 2,
       m.getY() + m.getHeight() / 2 - d.getHeight() / 2);
   d.setVisible(true);
 }
Ejemplo n.º 5
0
  /**
   * Displays a dialog that allows the user to assign output devices and MIDI channels to the given
   * MIDI sequence.
   *
   * @param midiDescriptor The MIDI descriptor containing the sequence.
   * @param track The track.
   */
  public static void showAssignMidiOutputDevicesDialog(MidiDescriptor midiDescriptor) {

    Frame m = getMainFrame();
    AssignOutputDevicesDialog d = new AssignOutputDevicesDialog(m, midiDescriptor);
    d.pack();
    d.setLocation(
        m.getX() + m.getWidth() / 2 - d.getWidth() / 2,
        m.getY() + m.getHeight() / 2 - d.getHeight() / 2);
    d.setVisible(true);
  }
  public static void main(String s[]) {
    initParams(s);
    initAdapters();
    f = new Frame();
    final int[] modifiers = {InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK};
    final String[] modifierNames = {"InputEvent.SHIFT_MASK", "InputEvent.CTRL_MASK"};
    f.setLayout(new FlowLayout());
    f.addMouseWheelListener(
        new MouseWheelListener() {
          public void mouseWheelMoved(MouseWheelEvent e) {
            System.out.println("WHEEL " + e);
          }
        });
    f.setSize(300, 300);
    f.setVisible(true);

    try {
      robot = new Robot();
      robot.delay(500);
      robot.mouseMove(
          f.getLocationOnScreen().x + f.getWidth() / 2,
          f.getLocationOnScreen().y + f.getHeight() / 2);
      if (autorun) {
        // testing buttons 1, 2, 3 only
        testPlainButtons();
        robot.delay(500);

        // testing buttons 1, 2, 3 with SHIFT, CTRL, ALT keyboard modifiers
        testButtonsWithShift();
        robot.delay(500);

        testButtonsWithControl();
        robot.delay(500);

        testButtonsWithAlt();
        robot.delay(500);
      } else {
        switch (testModifier) {
          case SHIFT:
            f.addMouseListener(adapterTest2);
            break;
          case CTRL:
            f.addMouseListener(adapterTest3);
            break;
          case ALT:
            f.addMouseListener(adapterTest4);
            break;
          default: // NONE inclusive
            f.addMouseListener(adapterTest1);
        }
      }
    } catch (Exception e) {
      throw new RuntimeException("Test failed.");
    }
  }
Ejemplo n.º 7
0
 /**
  * ErrorDialog constructor comment.
  *
  * @param owner java.awt.Frame
  * @param title java.lang.String
  * @param modal boolean
  */
 public ErrorDialog(java.awt.Frame owner, String title, String message) {
   super(owner, true);
   initialize();
   setTitle(title);
   ivjJTextPane1.setText(message);
   setLocation(
       owner.getX() + (owner.getWidth() - getWidth()) / 2,
       owner.getY() + (owner.getHeight() - getHeight()) / 2);
   show();
   repaint();
 }
 public void showMessage(String message) {
   int x = frame.getX() + (frame.getWidth() - WIDTH) / 2,
       y = frame.getY() + (frame.getHeight() - HEIGHT) / 2;
   setLocation(x, y);
   textArea.append(message + "\n");
   int value = jsbar.getMaximum() - jsbar.getVisibleAmount();
   jsbar.setValue(value);
   repaint();
   if (!isVisible()) {
     setVisible(true);
   }
 }
Ejemplo n.º 9
0
  public void oneDrag(int pixels) {
    robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2);
    // drag for a short distance
    robot.mousePress(InputEvent.BUTTON1_MASK);
    for (int i = 1; i < pixels; i++) {
      robot.mouseMove(fp.x + frame.getWidth() / 2 + i, fp.y + frame.getHeight() / 2);
    }
    robot.waitForIdle();
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.waitForIdle();

    if (dragged && clicked) {
      throw new RuntimeException(
          "Test failed. Clicked event follows by Dragged. Dragged = "
              + dragged
              + ". Clicked = "
              + clicked
              + " : distance = "
              + pixels);
    }
  }
Ejemplo n.º 10
0
  private static Point getAppropriateLocation(Frame owner, Point position) {
    Point result = new Point(position);
    Point p = owner.getLocation();
    int offsetX = (position.x + width) - (p.x + owner.getWidth());
    int offsetY = (position.y + height) - (p.y + owner.getHeight());

    if (offsetX > 0) {
      result.x -= offsetX;
    }

    if (offsetY > 0) {
      result.y -= offsetY;
    }
    return result;
  }
  /**
   * Creates new form JDialogTicketAttente
   *
   * @param parent
   * @param listA
   * @param titre
   */
  public JDialogTicketAttente(java.awt.Frame parent, ArrayList<TicketAttente> listA, String titre) {
    super(parent, titre, true);

    initComponents();
    this.listeTA = listA;
    jTableTA
        .getTableHeader()
        .setPreferredSize(new Dimension(jTableTA.getTableHeader().getWidth(), 30));
    jTableTA
        .getTableHeader()
        .setPreferredSize(new Dimension(jTableTA.getTableHeader().getWidth(), 50));
    jTableTA.getTableHeader().setFont(new Font("Helvetica", Font.BOLD, 13));
    myModelTicketAtt.setMyList(listeTA);
    setLocation(parent.getX() + parent.getWidth() / 3, parent.getY() + parent.getHeight() / 3);
    this.setVisible(true);
  }
Ejemplo n.º 12
0
 public void checkClicked() {
   robot.mouseMove(fp.x + frame.getWidth() / 2, fp.y + frame.getHeight() / 2);
   robot.mousePress(InputEvent.BUTTON1_MASK);
   robot.delay(10);
   robot.mouseRelease(InputEvent.BUTTON1_MASK);
   robot.delay(1000);
   if (!clicked || !pressed || !released || dragged) {
     throw new RuntimeException(
         "Test failed. Some of Pressed/Released/Clicked events are missed or dragged occured. Pressed/Released/Clicked/Dragged = "
             + pressed
             + ":"
             + released
             + ":"
             + clicked
             + ":"
             + dragged);
   }
 }
    public void tryDocking() {
      if (thisEditor == null) return;
      Editor editor = thisEditor;
      Frame frame = thisErrorWindow;

      int ex = editor.getX();
      int ey = editor.getY();
      int ew = editor.getWidth();
      int eh = editor.getHeight();

      int fx = frame.getX();
      int fy = frame.getY();
      int fw = frame.getWidth();
      int fh = frame.getHeight();

      if (((fy > ey) && (fy < ey + eh)) || ((fy + fh > ey) && (fy + fh < ey + eh))) {
        int dis_border_left = Math.abs(ex - (fx + fw));
        int dis_border_right = Math.abs((ex + ew) - (fx));

        if (dis_border_left < MAX_GAP_ || dis_border_right < MAX_GAP_) {
          docking_border = (dis_border_left < dis_border_right) ? 0 : 1;
          dock_on_editor_y_offset_ = fy - ey;
          dock();
          return;
        }
      }

      if (((fx > ex) && (fx < ex + ew)) || ((fx + fw > ey) && (fx + fw < ex + ew))) {
        int dis_border_top = Math.abs(ey - (fy + fh));
        int dis_border_bot = Math.abs((ey + eh) - (fy));

        if (dis_border_top < MAX_GAP_ || dis_border_bot < MAX_GAP_) {
          docking_border = (dis_border_top < dis_border_bot) ? 2 : 3;
          dock_on_editor_x_offset_ = fx - ex;
          dock();
          return;
        }
      }
      docking_border = -1;
    }
Ejemplo n.º 14
0
  /**
   * Creates a new <code>AccountingEntryDialog</code> to let the user create a new entry.
   *
   * @param parent This dialog's parent frame.
   * @param modal Whether this dialog should be modal or not.
   * @param dbcon A connection to the database where the accounting information is stored.
   * @see salssuite.server.module.AccountingModule#buildDatabase
   */
  public AccountingEntryDialog(java.awt.Frame parent, boolean modal, Connection dbcon) {
    super(parent, modal);
    this.dbcon = dbcon;
    initComponents();

    try {
      stmt = dbcon.createStatement();

      ResultSet categoryList = stmt.executeQuery("SELECT * FROM " + "accounting_categories");

      while (categoryList.next()) categoryChooser.addItem(categoryList.getString("name"));
    } catch (SQLException ex) {
      JOptionPane.showMessageDialog(
          this,
          "Fehler bei der Kommunikation mit der" + " Datenbank",
          "Netzwerkfehler",
          JOptionPane.ERROR_MESSAGE);
      ex.printStackTrace();
      return;
    }

    // fill in default values
    GregorianCalendar now = new GregorianCalendar();

    dayInput.setText("" + now.get(GregorianCalendar.DAY_OF_MONTH));
    monthInput.setText("" + (now.get(GregorianCalendar.MONTH) + 1));
    yearInput.setText("" + now.get(GregorianCalendar.YEAR));

    hourInput.setText("" + now.get(GregorianCalendar.HOUR_OF_DAY));
    minutesInput.setText("" + now.get(GregorianCalendar.MINUTE));
    secondsInput.setText("" + now.get(GregorianCalendar.SECOND));

    // usability tweaks
    int xLocation = parent.getX() + parent.getWidth() / 2 - getWidth() / 2;
    int yLocation = parent.getY() + parent.getHeight() / 2 - getHeight() / 2;
    setLocation(xLocation, yLocation);
    setTitle("Neuer Eintrag");
    descriptionInput.requestFocus();
  }
    public void dock() {
      if (thisEditor == null) return;
      Editor editor = thisEditor;
      Frame frame = thisErrorWindow;

      int ex = editor.getX();
      int ey = editor.getY();
      int ew = editor.getWidth();
      int eh = editor.getHeight();

      // int fx = frame.getX();
      // int fy = frame.getY();
      int fw = frame.getWidth();
      int fh = frame.getHeight();

      int x = 0, y = 0;
      if (docking_border == -1) {
        return;
      }

      if (docking_border == 0) {
        x = ex - fw;
        y = ey + dock_on_editor_y_offset_;
      }
      if (docking_border == 1) {
        x = ex + ew;
        y = ey + dock_on_editor_y_offset_;
      }

      if (docking_border == 2) {
        x = ex + dock_on_editor_x_offset_;
        y = ey - fh;
      }
      if (docking_border == 3) {
        x = ex + dock_on_editor_x_offset_;
        y = ey + eh;
      }
      frame.setLocation(x, y);
    }