public HDMColdAccountForm(final WalletListPanel walletListPanel) {
    this.walletListPanel = walletListPanel;

    inactiveBackGroundColor = Color.WHITE;
    selected = false;
    panelMain.setOpaque(true);
    panelMain.setFocusable(true);
    panelMain.setBackground(inactiveBackGroundColor);

    if (ColorAndFontConstants.isInverse()) {
      inactiveBackGroundColor =
          new Color(
              Math.min(255, Themes.currentTheme.detailPanelBackground().getRed() + 2 * COLOR_DELTA),
              Math.min(
                  255, Themes.currentTheme.detailPanelBackground().getBlue() + 2 * COLOR_DELTA),
              Math.min(
                  255, Themes.currentTheme.detailPanelBackground().getGreen() + 2 * COLOR_DELTA));
    } else {
      inactiveBackGroundColor =
          new Color(
              Math.max(0, Themes.currentTheme.detailPanelBackground().getRed() - COLOR_DELTA),
              Math.max(0, Themes.currentTheme.detailPanelBackground().getBlue() - COLOR_DELTA),
              Math.max(0, Themes.currentTheme.detailPanelBackground().getGreen() - COLOR_DELTA));
    }
    panelMain.applyComponentOrientation(
        ComponentOrientation.getOrientation(LocaliserUtils.getLocale()));

    updateFromModel();
    panelMain.addMouseListener(
        new WalletMouseListener(this.walletListPanel, HDMColdAccountForm.this));

    setSelected(false);
    setContent();
  }
Exemplo n.º 2
0
  public MapperDividersController(Mapper mapper, JPanel leftDivider, JPanel rightDivider) {
    this.mapper = mapper;
    this.leftDivider = leftDivider;
    this.rightDivider = rightDivider;

    leftDivider.addMouseListener(this);
    leftDivider.addMouseMotionListener(this);

    rightDivider.addMouseListener(this);
    rightDivider.addMouseMotionListener(this);
  }
Exemplo n.º 3
0
  public Clock() {

    main_panel.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            System.exit(0);
          }
        });

    Timer timer =
        new Timer(
            1000,
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                Calendar curTime = Calendar.getInstance();
                curTime.setTimeInMillis(System.currentTimeMillis());

                hour.setText(setTimeString(curTime.get(Calendar.HOUR_OF_DAY) + ""));
                minutes.setText(setTimeString(curTime.get(Calendar.MINUTE) + ""));
                second.setText(setTimeString(curTime.get(Calendar.SECOND) + ""));
              }
            });
    timer.setInitialDelay(0);
    timer.start();
  }
Exemplo n.º 4
0
  /*
     El uso de este método estático es para inicializar el Canvas, su panel y
     otros componentes.
  */
  public static void initializeCanvas() {
    pastelements = null;
    futureelements = null;
    seleccionado = null;
    elements = new ArrayList<>();

    panel =
        new JPanel() {
          @Override
          public void paint(Graphics g) {
            super.paint(g);
            g.clearRect(0, 0, WIDTH, HEIGHT);
            for (int i = 0; i < elements.size(); i++) elements.get(i).paint(g);
          }
        };

    MouseAdapter ma =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent me) {
            Canvas.mouseClicked(me);
          }

          @Override
          public void mouseMoved(MouseEvent me) {
            Canvas.mouseMoved(me);
          }
        };

    panel.addMouseListener(ma);
    panel.addMouseMotionListener(ma);
  }
  /**
   * Creates the panel that appears when there are no pages
   *
   * @return JPanel
   */
  protected JPanel createFirstPanel() {
    firstButtonPanel = new JPanel(new GridBagLayout());
    firstButtonPanel.setBorder(BorderFactory.createLineBorder(Color.black));
    firstButtonPanel.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent _evt) {
            if (OSPRuntime.isPopupTrigger(_evt))
              return; // SwingUtilities.isRightMouseButton(_evt)) return;
            if (!firstButtonPanel.isEnabled()) return;
            Object obj =
                JOptionPane.showInputDialog(
                    getComponent(),
                    res.getString("TabbedEditor.NewName"),
                    res.getString("TabbedEditor.Rename"),
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    null,
                    getUniqueName(defaultString));
            if (obj == null) return;
            String txt = obj.toString().trim();
            if (txt.length() > 0) addPage(defaultType, txt, null, true);
            else addPage(defaultType, defaultString, null, true);
          }
        });
    String label = res.getOptionalString("TabbedEditor.ClickHere." + defaultHeader);
    if (label == null) label = res.getString("TabbedEditor.ClickHere");
    firstButton = new JLabel(label);
    firstButton.setFont(firstButton.getFont().deriveFont(TabbedEditor.BUTTON_FONT_SIZE));
    firstButtonPanel.add(firstButton);

    JPanel firstPanel = new JPanel(new GridLayout(0, 1));
    firstPanel.add(firstButtonPanel);
    return firstPanel;
  }
  private JPanel createContentPane() {
    JPanel panel = new JPanel();

    combo1 = new JComboBox<>(numData);
    panel.add(combo1);
    combo2 = new JComboBox<>(dayData);
    combo2.setEditable(true);
    panel.add(combo2);
    panel.setSize(300, 200);

    popupMenu = new JPopupMenu();
    JMenuItem item;
    for (int i = 0; i < dayData.length; i++) {
      item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i]));
      item.addActionListener(this);
    }
    panel.addMouseListener(new PopupListener(popupMenu));

    JTextField field = new JTextField("CTRL+down for Popup");
    // CTRL-down will show the popup.
    field
        .getInputMap()
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP");
    field.getActionMap().put("OPEN_POPUP", new PopupHandler());

    panel.add(field);

    return panel;
  }
  private JPanel createDraggablePane() {
    System.out.println("creating a new draggable pane");
    String value = JOptionPane.showInputDialog("Say what?");

    if (value == null) return null;

    JPanel pane = new JPanel();
    JLabel lbl = new JLabel(value);
    lbl.setHorizontalAlignment(JLabel.CENTER);

    pane.setLayout(new BorderLayout());
    pane.add(lbl, BorderLayout.CENTER);
    pane.setSize(100, 50);
    pane.setBackground(Color.CYAN);
    pane.setBorder(new LineBorder(Color.BLACK, 1));

    dragSources.add(makeDraggablePaneProducer(pane));

    pane.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mousePressed(MouseEvent e) {
            System.out.println("draggable-mouse-pressed");
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            System.out.println("draggable-mouse-released");
          }
        });

    return pane;
  }
Exemplo n.º 8
0
 /**
  * Kicseréli a rajzterület egér-eseménykezelőjét.
  *
  * @param newListener Az új egér-eseménykezelő.
  */
 public static void replaceGameAreaMouseListener(MouseInputListener newListener) {
   gameArea.removeMouseListener(gameAreaMouseListener);
   gameArea.removeMouseMotionListener(gameAreaMouseListener);
   gameAreaMouseListener = newListener;
   gameArea.addMouseListener(newListener);
   gameArea.addMouseMotionListener(newListener);
 }
  public void setStarAtlas(Map starAtlas) {
    lblStarAtlasId_1.setText(starAtlas.getMapId() + "");
    lblNoOfItems_1.setText(starAtlas.getItemCount() + "");
    lblLocationId_1.setText(starAtlas.getPositionId());

    Iterator<Map> starMapIterator = starAtlas.getStarMapList().iterator();
    while (starMapIterator.hasNext()) {
      map = starMapIterator.next();

      JPanel star = new JPanel();
      lblStar = new JLabel((new ImageIcon(map.getImageFilePath())));
      star.add(lblStar);

      star.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              try {
                StarMapView starMapViewDialog = new StarMapView();
                starMapViewDialog.setStarMap(map);
              } catch (Exception e1) {
                e1.printStackTrace();
              }
            }
          });

      panel_StarMapContainer.add(star);
    }
  }
  /** @param presentationModel A presentation model with panel's logic. */
  public ImageRenderingPanel(ImagePresentationModel presentationModel) {
    if (presentationModel == null)
      throw new IllegalArgumentException("presentationModel cannot be null.");

    mUIModel = presentationModel;
    mUIModel.addListener(
        new Listener() {
          @Override
          public void onVisibleImageContentUpdate() {
            SwingUtilities.invokeLater(() -> repaint());
          }

          @Override
          public void onImageChange() {
            SwingUtilities.invokeLater(() -> repaint());
          }
        });

    MouseHandler handler = new MouseHandler();

    super.addMouseListener(handler);
    super.addMouseMotionListener(handler);
    super.addMouseWheelListener(handler);
    super.addComponentListener(new ResizeHandler());
  }
  /** Create the custom ui components. */
  private void createUIComponents() {
    root = new JPanel();
    top = new JPanel();
    right = new JPanel();
    properties = new JPanel();
    propertiesRoot = new JPanel();
    network = new NetworkPanel();
    network.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent mouseEvent) {}

          public void mousePressed(MouseEvent mouseEvent) {

            selectedNode =
                NetworkImage.peekNearest(
                    (int) network.getSize().getWidth(),
                    (int) network.getSize().getHeight(),
                    mouseEvent.getX(),
                    mouseEvent.getY(),
                    epanetNetwork);
            network.repaint();
          }

          public void mouseReleased(MouseEvent mouseEvent) {}

          public void mouseEntered(MouseEvent mouseEvent) {}

          public void mouseExited(MouseEvent mouseEvent) {}
        });
  }
Exemplo n.º 12
0
 /**
  * Constructs an OSPControl.
  *
  * @param _model
  */
 public OSPControl(Object _model) {
   super(ControlsRes.getString("OSPControl.Default_Title")); // $NON-NLS-1$
   model = _model;
   if (model != null) {
     // added by D Brown 2006-09-10
     // modified by D Brown 2007-10-17
     if (OSPRuntime.translator != null) OSPRuntime.translator.associate(this, model.getClass());
     String name = model.getClass().getName();
     setTitle(
         name.substring(1 + name.lastIndexOf("."))
             + ControlsRes.getString("OSPControl.Controller")); // $NON-NLS-1$ //$NON-NLS-2$
   }
   ToolsRes.addPropertyChangeListener("locale", this);
   Font labelFont = new Font("Dialog", Font.BOLD, 12); // $NON-NLS-1$
   inputLabel =
       new JLabel(
           ControlsRes.getString("OSPControl.Input_Parameters"),
           SwingConstants.CENTER); // $NON-NLS-1$
   inputLabel.setFont(labelFont);
   messageTextArea = new JTextArea(5, 5);
   JScrollPane messageScrollPane = new JScrollPane(messageTextArea);
   // contains a view of the control
   JPanel topPanel = new JPanel(new BorderLayout());
   topPanel.add(inputLabel, BorderLayout.NORTH);
   topPanel.add(controlScrollPane, BorderLayout.CENTER);
   buttonPanel.setVisible(true);
   topPanel.add(buttonPanel, BorderLayout.SOUTH); // buttons are added using addButton method.
   // clear panel acts like a button to clear the message area
   JPanel clearPanel = new JPanel(new BorderLayout());
   clearPanel.addMouseListener(new ClearMouseAdapter());
   clearLabel = new JLabel(ControlsRes.getString("OSPControl.Clear")); // $NON-NLS-1$
   clearLabel.setFont(new Font(clearLabel.getFont().getFamily(), Font.PLAIN, 9));
   clearLabel.setForeground(Color.black);
   clearPanel.add(clearLabel, BorderLayout.WEST);
   // contains the messages
   JPanel bottomPanel = new JPanel(new BorderLayout());
   messageLabel =
       new JLabel(
           ControlsRes.getString("OSPControl.Messages"), SwingConstants.CENTER); // $NON-NLS-1$
   messageLabel.setFont(labelFont);
   bottomPanel.add(messageLabel, BorderLayout.NORTH);
   bottomPanel.add(messageScrollPane, BorderLayout.CENTER);
   bottomPanel.add(clearPanel, BorderLayout.SOUTH);
   Container cp = getContentPane();
   splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
   splitPane.setOneTouchExpandable(true);
   cp.add(splitPane, BorderLayout.CENTER);
   messageTextArea.setEditable(false);
   controlScrollPane.setPreferredSize(new Dimension(350, 200));
   controlScrollPane.setMinimumSize(new Dimension(0, 50));
   messageScrollPane.setPreferredSize(new Dimension(350, 75));
   if (OSPRuntime.translator != null && model != null) {
     OSPRuntime.translator.associate(table, model.getClass());
   }
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   setLocation(
       (d.width - getSize().width) / 2, (d.height - getSize().height) / 2); // center the frame
   init();
 }
Exemplo n.º 13
0
 /** Hakee nykyiseen näkymään liittyvät klikkauskohteet */
 private void paivitaKlikattavat() {
   jpanel.removeMouseListener(shk);
   shk =
       new KlikattavienHiiriKuuntelija(
           this,
           tiedot.getSijainti(),
           tiedot.getRuutu().getNakyma(tiedot.getSuunta()).getKlikattavat());
   jpanel.addMouseListener(shk);
 }
Exemplo n.º 14
0
  CommandPanel(Commande c) {
    super(new BorderLayout());
    commande = c;
    commande.addActionEventListener(this);

    JPanel text = new JPanel();
    text.addMouseListener(this);
    text.add(new JLabel(commande.getName()));
    add(text, BorderLayout.PAGE_START);

    itemList = new JPanel(new GridBagLayout());
    itemList.addMouseListener(this);
    itemList.setBackground(Color.WHITE);

    JScrollPane pane = new JScrollPane(itemList);
    pane.setPreferredSize(new Dimension(95, 100));
    add(pane, BorderLayout.CENTER);
    drawItems();
  }
Exemplo n.º 15
0
 protected void generateGUI() {
   setOpaque(false);
   plus = new javax.swing.ImageIcon(CompositeElementPanel.class.getResource("images/plus.gif"));
   minus = new javax.swing.ImageIcon(CompositeElementPanel.class.getResource("images/minus.gif"));
   expandButton = new javax.swing.JButton();
   expandButton.setContentAreaFilled(false);
   expandButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
   expandButton.setFocusPainted(false);
   expandButton.setBorderPainted(false);
   expandButton.setBorder(null);
   expandButton.addActionListener(actionListener);
   glue = javax.swing.Box.createHorizontalGlue();
   addDragSourceComponent(glue);
   glue.addMouseListener(elementMouseListener);
   addMouseListener(elementMouseListener);
   grip.addMouseListener(elementMouseListener);
   if (headerLabel == null) {
     headerLabel = new javax.swing.JLabel();
     setHeaderLabel();
     headerLabel.setOpaque(false);
     headerLabel.addMouseListener(elementMouseListener);
     addDragSourceComponent(headerLabel);
   }
   if (containingPanel == null) {
     containingPanel = new javax.swing.JPanel();
     containingPanel.setLayout(new java.awt.BorderLayout());
     containingPanel.addMouseListener(elementMouseListener);
     containingPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
     containingPanel.setOpaque(false);
     addDragSourceComponent(containingPanel);
   }
   if (headerPanel == null) {
     headerPanel = new javax.swing.JPanel();
     headerPanel.setLayout(new java.awt.GridBagLayout());
     headerPanel.addMouseListener(elementMouseListener);
     headerPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
     headerPanel.setOpaque(false);
     addDragSourceComponent(headerPanel);
   }
 }
Exemplo n.º 16
0
  private void button11LensOnDoubleSlitActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_button11LensOnDoubleSlitActionPerformed
    actionTag = "DoubleSlit";
    if (parseArguments()) {
      PatternImage image = ((EduPatternJPanel) panelPattern).pimage;
      image.updateLensParameterDrawSlit(
          2,
          d_widthX_double,
          d_heightX_double,
          d_postionX_double,
          d_rotation_double,
          d_grayLevel_double,
          d_spacing_double);
      image.slit(2);
      EduPatternShowOn.updateLensPatternPattern(image, genLogDoubleSlit());
      setLog(genLogDoubleSlit());
      imageGenerated = true;

      if (countLenOnDoubleSlit % 2 == 0) {
        magFrameLenon.dispose();
        panelPattern.addMouseListener(
            new java.awt.event.MouseAdapter() {
              public void mouseClicked(java.awt.event.MouseEvent evt) {
                patternFrameDoubleClick.show();
              }
            });
      } else {
        magFrameLenon = new JFrame("1:1 Lens On");
        URL url = ClassLoader.getSystemResource("resources/jdclogo_48x48.png");
        Toolkit kit = Toolkit.getDefaultToolkit();
        Image img = kit.createImage(url);
        magFrameLenon.setIconImage(img);
        magFrameLenon.setResizable(false);

        EduLensOn11 mag = new EduLensOn11(panelPattern, new Dimension(120, 120));
        magFrameLenon.getContentPane().add(mag);
        magFrameLenon.pack();
        magFrameLenon.setLocation(new Point(568, 450));
        magFrameLenon.setResizable(false);
        magFrameLenon.setVisible(true);
        magFrameLenon.setAlwaysOnTop(true);
        magFrameLenon.addWindowListener(
            new java.awt.event.WindowAdapter() {
              public void windowClosing(java.awt.event.WindowEvent e) {
                countLenOnDoubleSlit--;
                buttong11LensOnDoubleSlit.setText(labels.getString("btnLensOn"));
                magFrameLenon.dispose();
              }
            });
      }
    }
  } // GEN-LAST:event_button11LensOnDoubleSlitActionPerformed
  protected void setup(
      final AnAction action,
      JPanel root,
      final JLabel name,
      final JLabel description,
      JLabel icon) {
    name.setText(action.getTemplatePresentation().getText());
    name.setUI(DarculaWelcomeScreenLabelUI.createUI(name));
    name.setForeground(UIUtil.getPanelBackground());
    description.setUI(DarculaWelcomeScreenLabelUI.createUI(description));
    // icon.setIcon(action.getTemplatePresentation().getIcon());
    final String text = action.getTemplatePresentation().getDescription();
    final String html =
        XmlStringUtil.wrapInHtml(
            MessageFormat.format(text, ApplicationNamesInfo.getInstance().getFullProductName()));
    root.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    description.setText(html);
    description.setForeground(Gray._200);
    description.setEnabled(false);
    root.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            description.setEnabled(true);
            name.setForeground(new Color(0xE09600));
          }

          @Override
          public void mouseExited(MouseEvent e) {
            description.setEnabled(false);
            name.setForeground(UIUtil.getPanelBackground());
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            final ActionManager actionManager = ActionManager.getInstance();
            AnActionEvent evt =
                new AnActionEvent(
                    null,
                    DataManager.getInstance().getDataContext(e.getComponent()),
                    ActionPlaces.WELCOME_SCREEN,
                    action.getTemplatePresentation(),
                    actionManager,
                    0);
            action.beforeActionPerformedUpdate(evt);
            if (evt.getPresentation().isEnabled()) {
              action.actionPerformed(evt);
            }
          }
        });
  }
  private Container createContentPane() {
    startFrontEndPane = new JPanel(new BorderLayout());
    JPanel centeringPanel = new JPanel(new FlowLayout());
    JLabel startLabel = new JLabel();
    startLabel.setIcon(new ImageIcon(ClothesItem.class.getResource("clothesshop.jpg")));
    centeringPanel.add(startLabel);
    startFrontEndPane.add(centeringPanel, BorderLayout.CENTER);

    frontEndPane = (JPanel) getContentPane();
    frontEndPane.setLayout(new BorderLayout());
    frontEndPane.addMouseListener(new MouseForPopup(this));
    frontEndPane.setBackground(Color.getHSBColor(44, 56, 100));

    // top panel currently empty before "Select outfit" is pressed
    topPanel = new JPanel(new GridLayout(1, 5));

    frontEndPane.add(topPanel, BorderLayout.NORTH);

    JPanel centre = new JPanel(new GridLayout(1, 2));
    JPanel c1 = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 30));
    JPanel c2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 30));

    // Total Price label with prompt string until the items are shown

    totalPrice = new JLabel("Press Button Below To Start");
    c1.add(totalPrice);
    centre.add(c1);

    // Selected Price label empty until items selected
    selectedPrice = new JLabel();
    c2.add(selectedPrice);
    centre.add(c2);

    frontEndPane.add(centre, BorderLayout.CENTER);

    // adding buttons
    buttonHolder = new JPanel(new GridLayout(1, 2));

    selectOutfit = new JButton("Select Outfit");
    selectOutfit.addActionListener(this);
    buttonHolder.add(selectOutfit);

    replaceOutfit = new JButton("Replace"); // added after the selectOutfit is pressed once
    replaceOutfit.addActionListener(this);

    startFrontEndPane.add(selectOutfit, BorderLayout.SOUTH);
    frontEndPane.add(buttonHolder, BorderLayout.SOUTH);

    return startFrontEndPane;
  }
Exemplo n.º 19
0
  /**
   * Sets up the event handler mechanics, including invoking the initGUIHandlers method, which would
   * be provided by the game developer using this framework, and would presumably be different for
   * each game.
   */
  private void initHandlers() {
    // SETUP THE LOW-LEVEL HANDLER WHO WILL
    // RELAY EVERYTHING
    MiniGameEventRelayer mger = new MiniGameEventRelayer(this);
    canvas.addMouseListener(mger);
    canvas.addMouseMotionListener(mger);
    window.setFocusable(true);
    window.addKeyListener(mger);
    canvas.addKeyListener(mger);

    // AND NOW LET THE GAME DEVELOPER PROVIDE
    // CUSTOM HANDLERS
    initGUIHandlers();
  }
  // MouseTrackerFrame constructor sets up GUI and
  // registers mouse event handlers
  public MouseTrackerFrame() {
    super("Demonstrating Mouse Events");

    mousePanel = new JPanel(); // create panel
    mousePanel.setBackground(Color.WHITE); // set background color
    add(mousePanel, BorderLayout.CENTER); // add panel to JFrame

    statusBar = new JLabel("Mouse outside JPanel");
    add(statusBar, BorderLayout.SOUTH); // add label to JFrame

    // create and register listener for mouse and mouse motion events
    MouseHandler handler = new MouseHandler();
    mousePanel.addMouseListener(handler);
    mousePanel.addMouseMotionListener(handler);
  } // end MouseTrackerFrame constructor
Exemplo n.º 21
0
  public static void main(String[] s) {
    JFrame frame = new JFrame("A test frame");
    JPanel outputBox = new JPanel();
    JButton jButton = new JButton();

    frame.setSize(200, 200);
    frame.addMouseWheelListener(
        new MouseWheelListener() {
          public void mouseWheelMoved(MouseWheelEvent e) {
            System.out.println("Wheel moved on FRAME : " + e);
            actualEvents++;
          }
        });

    outputBox.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            System.out.println("MousePressed on OUTBOX : " + e);
          }
        });
    frame.add(outputBox);
    outputBox.add(jButton);

    frame.setVisible(true);

    Util.waitForIdle(robot);

    Util.pointOnComp(jButton, robot);
    Util.waitForIdle(robot);

    for (int i = 0; i < MOVE_COUNT; i++) {
      robot.mouseWheel(1);
      robot.delay(10);
    }

    for (int i = 0; i < MOVE_COUNT; i++) {
      robot.mouseWheel(-1);
      robot.delay(10);
    }

    Util.waitForIdle(robot);
    // Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
    // result in a single wheel rotation.
    if (actualEvents != EXPECTED_COUNT) {
      AbstractTest.fail(
          "Expected events count: " + EXPECTED_COUNT + " Actual events count: " + actualEvents);
    }
  }
Exemplo n.º 22
0
  public CategoryPanel(
      String name, List<ResourceLocator> locatorList, Set<String> loadedTrackNames) {

    expanded = true;

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setAlignmentX(LEFT_ALIGNMENT);
    // setLayout(null);

    labelBar = new JPanel();
    // labelBar.setBackground(Color.blue);
    labelBar.setLayout(new BoxLayout(labelBar, BoxLayout.X_AXIS));
    labelBar.setBorder(BorderFactory.createRaisedBevelBorder()); //  new LabelBorder(Color.black));
    labelBar.setAlignmentX(LEFT_ALIGNMENT);
    JideButton toggleButton = new JideButton(expanded ? " - " : " + ");
    toggleButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE);
    labelBar.add(toggleButton);

    labelBar.add(new JLabel(name));
    this.add(labelBar);

    listPanel = new JPanel();
    listPanel.setLayout(new GridLayout(0, 4));
    for (ResourceLocator loc : locatorList) {
      final String trackName = loc.getTrackName();
      JCheckBox cb = new JCheckBox(trackName);
      cb.setSelected(loadedTrackNames.contains(trackName));
      listPanel.add(cb);
    }
    this.add(listPanel);

    toggleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            expanded = !expanded;
            listPanel.setVisible(expanded);
          }
        });
    labelBar.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent mouseEvent) {
            expanded = !expanded;
            listPanel.setVisible(expanded);
          }
        });
  }
Exemplo n.º 23
0
  private static JPanel createOverlayPanel(
      final JComponent comp, final JLayeredPane layeredPane, final IDropInfo info) {
    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    JLabel label = new JLabel("<html><center>" + info.getOverlayMessage() + "</center></html>");
    label.setForeground(Color.WHITE);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    label.setBorder(new EmptyBorder(20, 20, 20, 20));
    panel.add(label, BorderLayout.CENTER);
    panel.setBackground(new Color(0, 0, 0, 150));
    addListener(
        panel,
        new FileDropListener(info) {

          @Override
          public void drop(DropTargetDropEvent dtde) {
            super.drop(dtde);
            restore();
          }

          @Override
          public void dragExit(DropTargetEvent dte) {
            restore();
          }

          private void restore() {
            layeredPane.remove(panel);
            layeredPane.repaint();
          }
        });
    // This listener shouldn't be necessary(?), but sometimes dragExit() isn't called
    // properly and the overlay can get stuck even though the drag has ended.
    // This lets you kill the overlay by moving the mouse in and out of it.
    panel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseExited(MouseEvent e) {
            layeredPane.remove(panel);
            layeredPane.repaint();
          }
        });
    return panel;
  }
Exemplo n.º 24
0
  public void chat(JPanel panel) {
    this.panel = panel;
    userInterface = new UI(player);
    userInterface.chat(panel);

    AddKeyListener keyListener = new AddKeyListener();
    keyListener.setPlayer(player);

    keyListenerLayer = new JLayeredPane();
    keyListenerLayer.add(keyListener, 10);

    panel.add(BorderLayout.CENTER, keyListenerLayer);
    keyListener.setFocusable(true);
    keyListener.requestFocusInWindow();

    panel.add(BorderLayout.CENTER, layeredPane);
    panel.add(BorderLayout.SOUTH, userInterface.getChatPanel());
    panel.validate();
    panel.repaint();

    // initialize
    networkStartup.InGameChatInitialize(userInterface.getOutgoing(), userInterface.getIncoming());

    panel.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            keyListener.setFocusable(true);
            keyListener.requestFocusInWindow();
          }
        });

    userInterface
        .getOutgoing()
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                networkStartup.InGameChatSendButtonListener(
                    userInterface.getOutgoing(), userInterface.getIncoming());
              }
            });

    // startDrawingPanelThread();

  }
Exemplo n.º 25
0
  public Task7() {

    // Panel settings
    panel.setLayout(new BorderLayout());
    add(panel);

    // Window settings
    setSize(600, 400);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setTitle("Task7");

    // Adding slider to Panel
    panel.add(slider, BorderLayout.SOUTH);

    setVisible(true);

    // Adding ChangeListener to slider
    slider.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            if (positionSelected) {
              radius = slider.getValue();
            }
          }
        });

    // Adding MouseListener to Panel
    // If user don't select position for circle center nothing will happen
    panel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            positionX = e.getX();
            positionY = e.getY();
            positionSelected = true;
          }
        });
  }
Exemplo n.º 26
0
    private JPanel makeEntry(TagSet tagSet) {
      JPanel entry = new JPanel();
      entry.setOpaque(false);
      entry.setLayout(new BoxLayout(entry, BoxLayout.LINE_AXIS));

      entry.add(new JLabel(new LegendIcon(tagSet)));
      for (TagCapability tag : tagSet.tags) {
        JComponent view = LabelView.VIEW_INFO.createView(tag.getComponentRepresentation());
        view.setForeground(Color.LIGHT_GRAY);
        entry.add(view);
      }
      if (tagSet.tags.isEmpty()) {
        JLabel label = new JLabel(tagSet.toString());
        label.setForeground(Color.LIGHT_GRAY);
        entry.add(label);
      }
      entry.setAlignmentX(LEFT_ALIGNMENT);
      entry.addMouseListener(new Highlighter(tagSet));
      return entry;
    }
Exemplo n.º 27
0
 // generate options for color changes
 protected JPanel colorOption(final JPanel inner, final Color c, final String name) {
   JPanel outer = new JPanel();
   outer.setLayout(new BorderLayout(0, 0));
   TitledBorder ColorTitle =
       BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), name + " Color");
   ColorTitle.setTitlePosition(TitledBorder.ABOVE_TOP);
   outer.setBorder(ColorTitle);
   inner.setBorder(BorderFactory.createLineBorder(Color.black));
   inner.setBackground(c);
   inner.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           Color changed = JColorChooser.showDialog(null, "Pick " + name + " Color", c);
           if (changed != null) {
             inner.setBackground(changed);
           }
         }
       });
   outer.add(inner);
   return outer;
 }
Exemplo n.º 28
0
 public void addRow(Component... components) {
   remove(puff);
   final JPanel row = new JPanel();
   row.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent event) {
           gui.notifyObserver("/use " + rows.indexOf(event.getSource()));
         }
       });
   row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
   // row.add(Box.createHorizontalStrut(3));
   row.setMinimumSize(new Dimension(10, 30));
   row.setMaximumSize(new Dimension(250, 30));
   for (Component component : components) {
     row.add(component);
   }
   JButton red = new JButton("x");
   red.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent event) {
           int deleted = rows.indexOf(row);
           gui.notifyObserver("/use " + deleted);
           gui.notifyObserver("/disconnect");
         }
       });
   red.setBackground(Color.PINK.darker());
   red.setForeground(Color.WHITE);
   row.add(Box.createHorizontalGlue());
   row.add(red);
   rows.add(row);
   Component strut = Box.createVerticalStrut(5);
   struts.add(strut);
   add(row);
   add(strut);
   add(puff);
   repaint();
   updateUI();
 }
Exemplo n.º 29
0
  public void init(Object parent) {

    glass = new BlurGlass();
    glass.setLayout(null);

    this.setLayout(null);

    setOpaque(false);
    // getContentPane().setOpaque(false);
    this.getLayeredPane().setOpaque(false);
    this.getRootPane().setOpaque(false);
    // putClientProperty("Synthetica.opaque", Boolean.FALSE);

    JParent = parent;
    glass.setOpaque(false);

    MouseInputAdapter adapter = new MouseInputAdapter() {};
    glass.addMouseListener(adapter);
    glass.addMouseMotionListener(adapter);

    try {
      if (parent instanceof JFrame) {
        layer = ((JFrame) parent).getLayeredPane();
      } else if (parent instanceof JInternalFrame) {
        layer = ((JInternalFrame) parent).getLayeredPane();
      }
      glass.setBounds(layer.getBounds());

    } catch (NullPointerException err) {
      Dialogos.error("Error interno en Dialogo interno modal", err);
    }

    try {
      glass.add(this);
      layer.add(glass, JLayeredPane.DEFAULT_LAYER);
    } catch (NullPointerException err) {
      Dialogos.error("Error interno en dialogo modal interno", err);
    }
  }
Exemplo n.º 30
0
  public EditorPanel(ParticleValue value, String name, String description) {
    this.name = name;
    this.value = value;
    this.description = description;

    initializeComponents();

    titlePanel.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent event) {
            if (!activeButton.isVisible()) return;
            activeButton.setSelected(!activeButton.isSelected());
            updateActive();
          }
        });
    activeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            updateActive();
          }
        });
    advancedButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            advancedPanel.setVisible(advancedButton.isSelected());
          }
        });

    if (value != null) {
      activeButton.setSelected(value.isActive());
      updateActive();
    }

    boolean alwaysActive = value == null ? true : value.isAlwaysActive();
    activeButton.setVisible(!alwaysActive);
    if (alwaysActive) contentPanel.setVisible(true);
    if (alwaysActive) titlePanel.setCursor(null);
  }