Package javax.swing

Examples of javax.swing.JComponent$AccessibleJComponent


            setResizable(true);
            setCloseAction(CloseAction.DISPOSE);
        }

        protected void addDialogComponents() {
            JComponent dialogContentPane = createDialogContentPane();
            getDialogContentPane().add(dialogContentPane);
            getDialogContentPane().add(createButtonBar(), BorderLayout.SOUTH);
        }
View Full Code Here


        if (m_toolBarBean == null) {
          if (((me.getModifiers() & InputEvent.BUTTON1_MASK)
              == InputEvent.BUTTON1_MASK) && m_mode == NONE) {
            BeanInstance bi = BeanInstance.findInstance(me.getPoint(),
                m_mainKFPerspective.getCurrentTabIndex());
            JComponent bc = null;
            if (bi != null) {
              bc = (JComponent)(bi.getBean());
            }
            if (bc != null /*&& (bc instanceof Visible) */) {
              m_editElement = bi;
              m_oldX = me.getX();
              m_oldY = me.getY();
              m_mode = MOVING;
            }
            if (m_mode != MOVING) {
              m_mode = SELECTING;
              m_oldX = me.getX();
              m_oldY = me.getY();
              m_startX = m_oldX;
              m_startY = m_oldY;
              Graphics2D gx = (Graphics2D)layout.getGraphics();
              gx.setXORMode(java.awt.Color.white);
              //                gx.drawRect(m_oldX, m_oldY, m_oldX, m_oldY);
              //                gx.drawLine(m_startX, m_startY, m_startX, m_startY);
              gx.dispose();
              m_mode = SELECTING;
            }
          }
        }
      }

      public void mouseReleased(MouseEvent me) {
        if (m_editElement != null && m_mode == MOVING) {
          if (m_snapToGridB.isSelected()) {
            int x = snapToGrid(m_editElement.getX());
            int y = snapToGrid(m_editElement.getY());
            m_editElement.setXY(x, y);
            snapSelectedToGrid();
          }

          m_editElement = null;
          revalidate();
          layout.repaint();
          m_mode = NONE;
        }
        if (m_mode == SELECTING) {
          revalidate();
          layout.repaint();
          m_mode = NONE;

          //checkSubFlow(m_startX, m_startY, me.getX(), me.getY());
          highlightSubFlow(m_startX, m_startY, me.getX(), me.getY());
        }
      }

      public void mouseClicked(MouseEvent me) {
        BeanInstance bi = BeanInstance.findInstance(me.getPoint(),
            m_mainKFPerspective.getCurrentTabIndex());
        if (m_mode == ADDING || m_mode == NONE) {
          // try and popup a context sensitive menu if we have
          // been clicked over a bean.
          if (bi != null) {
            JComponent bc = (JComponent)bi.getBean();
            // if we've been double clicked, then popup customizer
            // as long as we're not a meta bean
            if (me.getClickCount() == 2 && !(bc instanceof MetaBean)) {
              try {
                Class custClass =
                  Introspector.getBeanInfo(bc.getClass()).getBeanDescriptor().getCustomizerClass();
                if (custClass != null) {
                  if (bc instanceof BeanCommon) {
                    if (!((BeanCommon)bc).
                        isBusy()) {
                      popupCustomizer(custClass, bc);
                    }
                  } else {
                    popupCustomizer(custClass, bc);
                  }
                }
              } catch (IntrospectionException ex) {
                ex.printStackTrace();
              }
            } else if (((me.getModifiers() & InputEvent.BUTTON1_MASK)
                != InputEvent.BUTTON1_MASK) || me.isAltDown()) {
              if (!m_mainKFPerspective.getExecuting()) {
                doPopup(me.getPoint(), bi, me.getX(), me.getY());
              }
              return;
            } else {
              // just select this bean
              Vector v = m_mainKFPerspective.getSelectedBeans();
              if (me.isShiftDown()) {
              } else {
                v = new Vector();
              }
              v.add(bi);            
              m_mainKFPerspective.setSelectedBeans(v);

              return;
            }
          } else {
            if (((me.getModifiers() & InputEvent.BUTTON1_MASK)
                != InputEvent.BUTTON1_MASK) || me.isAltDown()) {

              // find connections if any close to this point
              if (!m_mainKFPerspective.getExecuting()) {
                rightClickCanvasPopup(me.getX(), me.getY());
              }
              return;
              /*int delta = 10;
                deleteConnectionPopup(BeanConnection.
                      getClosestConnections(new Point(me.getX(), me.getY()),
                                            delta, m_mainKFPerspective.getCurrentTabIndex()),
                                            me.getX(), me.getY()); */
            } else if (m_toolBarBean != null) {
              // otherwise, if a toolbar button is active then
              // add the component

              // snap to grid
              int x = me.getX();
              int y = me.getY();
              if (m_snapToGridB.isSelected()) {
                x = snapToGrid(me.getX());
                y = snapToGrid(me.getY());
              }

              addUndoPoint();
              if (m_toolBarBean instanceof StringBuffer) {
                // serialized user meta bean
                pasteFromClipboard(x, y, (StringBuffer)m_toolBarBean, false);
                m_mode = NONE;
                KnowledgeFlowApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                m_toolBarBean = null;
              } else {
                // saveLayout(m_mainKFPerspective.getCurrentTabIndex(), false);
                addComponent(x, y);
              }
              m_componentTree.clearSelection();
              m_mainKFPerspective.setEditedStatus(true);
            }
          }
        }

        if (m_mode == PASTING && m_pasteBuffer.length() > 0) {
          pasteFromClipboard(me.getX(), me.getY(), m_pasteBuffer, true);
          m_mode = NONE;
          KnowledgeFlowApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
          return;
        }

        if (m_mode == CONNECTING) {
          // turn off connecting points and remove connecting line
          layout.repaint();
          Vector beanInstances =
            BeanInstance.getBeanInstances(m_mainKFPerspective.getCurrentTabIndex());
          for (int i = 0; i < beanInstances.size(); i++) {
            JComponent bean =
              (JComponent)((BeanInstance)beanInstances.elementAt(i)).
              getBean();
            if (bean instanceof Visible) {
              ((Visible)bean).getVisual().setDisplayConnectors(false);
            }
View Full Code Here

   *
   * Modified by Zerbetto: javax.swing.JPopupMenu transformed into java.awt.PopupMenu
   *
   */
  private void doPopup(Point pt, final BeanInstance bi, int x, int y) {
    final JComponent bc = (JComponent) bi.getBean();
    final int xx = x;
    final int yy = y;
    int menuItemCount = 0;

    // modifications by Zerbetto
    PopupMenu beanContextMenu = new PopupMenu();

    //JPopupMenu beanContextMenu = new JPopupMenu();

    //    beanContextMenu.insert(new JLabel("Edit",
    //              SwingConstants.CENTER),
    //         menuItemCount);
    MenuItem edit = new MenuItem("Edit:");
    edit.setEnabled(false);
    beanContextMenu.insert(edit, menuItemCount);
    menuItemCount++;

    if (m_mainKFPerspective.getSelectedBeans().size() > 0) {
      MenuItem copyItem = new MenuItem("Copy");
      copyItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          copyToClipboard();
          m_mainKFPerspective.setSelectedBeans(new Vector());
        }
      });
      beanContextMenu.add(copyItem);
      menuItemCount++;
    }


    if (bc instanceof MetaBean) {
      //JMenuItem ungroupItem = new JMenuItem("Ungroup");
      MenuItem ungroupItem = new MenuItem("Ungroup");
      ungroupItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          // ungroup
          bi.removeBean(m_beanLayout, m_mainKFPerspective.getCurrentTabIndex());

          Vector group = ((MetaBean) bc).getBeansInSubFlow();
          Vector associatedConnections = ((MetaBean) bc).getAssociatedConnections();
          ((MetaBean) bc).restoreBeans(xx, yy);

          for (int i = 0; i < group.size(); i++) {
            BeanInstance tbi = (BeanInstance) group.elementAt(i);
            addComponent(tbi, false);
            tbi.addBean(m_beanLayout, m_mainKFPerspective.getCurrentTabIndex());
          }

          for (int i = 0; i < associatedConnections.size(); i++) {
            BeanConnection tbc = (BeanConnection) associatedConnections.elementAt(i);
            tbc.setHidden(false);
          }

          m_beanLayout.repaint();
          m_mainKFPerspective.setEditedStatus(true);
          notifyIsDirty();           
        }
      });
      beanContextMenu.add(ungroupItem);
      menuItemCount++;

      // Add to user tab
      //JMenuItem addToUserTabItem = new JMenuItem("Add to user tab");
      MenuItem addToUserTabItem = new MenuItem("Add to user tab");
      addToUserTabItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          //addToUserToolBar((MetaBean) bi.getBean(), true);
          //addToUserTreeNode((MetaBean) bi.getBean(), true);
          addToUserTreeNode(bi, true);
          notifyIsDirty();
        }
      });
      beanContextMenu.add(addToUserTabItem);
      menuItemCount++;
    }

    //JMenuItem deleteItem = new JMenuItem("Delete");
    MenuItem deleteItem = new MenuItem("Delete");
    deleteItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        BeanConnection.removeConnections(bi, m_mainKFPerspective.getCurrentTabIndex());
        bi.removeBean(m_beanLayout, m_mainKFPerspective.getCurrentTabIndex());
        if (bc instanceof BeanCommon) {           
          String key = ((BeanCommon)bc).getCustomName()
          + "$" + bc.hashCode();
          m_logPanel.statusMessage(key + "|remove");
        }

        // delete any that have been actively selected
        if (m_mainKFPerspective.getSelectedBeans().size() > 0) {
          deleteSelectedBeans();
        }

        revalidate();
        m_mainKFPerspective.setEditedStatus(true);
        notifyIsDirty();
        m_selectAllB.setEnabled(BeanInstance.
            getBeanInstances(m_mainKFPerspective.getCurrentTabIndex()).size() > 0);
      }
    });
    if (bc instanceof BeanCommon) {
      if (((BeanCommon)bc).isBusy()) {
        deleteItem.setEnabled(false);
      }
    }
    beanContextMenu.add(deleteItem);
    menuItemCount++;

    if (bc instanceof BeanCommon) {
      MenuItem nameItem = new MenuItem("Set name");
      nameItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          String oldName = ((BeanCommon)bc).getCustomName();
          String name = JOptionPane.showInputDialog(KnowledgeFlowApp.this,
              "Enter a name for this component",
              oldName);
          if (name != null) {
            ((BeanCommon)bc).setCustomName(name);
            m_mainKFPerspective.setEditedStatus(true);
          }
        }
      });
      if (bc instanceof BeanCommon) {
        if (((BeanCommon)bc).isBusy()) {
          nameItem.setEnabled(false);
        }
      }
      beanContextMenu.add(nameItem);
      menuItemCount++;
    }

    try {
      //BeanInfo [] compInfo = null;
      //JComponent [] associatedBeans = null;
      Vector compInfo = new Vector(1);
      Vector associatedBeans = null;
      Vector outputBeans = null;
      Vector compInfoOutputs = null;

      if (bc instanceof MetaBean) {
        compInfo = ((MetaBean) bc).getBeanInfoSubFlow();
        associatedBeans = ((MetaBean) bc).getBeansInSubFlow();

        outputBeans = ((MetaBean) bc).getBeansInOutputs();
        compInfoOutputs = ((MetaBean) bc).getBeanInfoOutputs();
      } else {
        compInfo.add(Introspector.getBeanInfo(bc.getClass()));
        compInfoOutputs = compInfo;
      }

      final Vector tempAssociatedBeans = associatedBeans;

View Full Code Here

   
    // record the event set descriptior for this event
    m_sourceEventSetDescriptor = esd;

    Class listenerClass = esd.getListenerType(); // class of the listener
    JComponent source = (JComponent)bi.getBean();
    // now determine which (if any) of the other beans implement this
    // listener
    int targetCount = 0;
    Vector beanInstances =
      BeanInstance.getBeanInstances(m_mainKFPerspective.getCurrentTabIndex());
    for (int i = 0; i < beanInstances.size(); i++) {
      JComponent bean =
        (JComponent)((BeanInstance)beanInstances.elementAt(i)).getBean();
      boolean connectable = false;
      boolean canContinue = false;
      if (bean != source) {
        if (bean instanceof MetaBean) {
View Full Code Here

    public void doLayout() {
      super.doLayout();
      Vector comps = BeanInstance.getBeanInstances(m_mainKFPerspective.getCurrentTabIndex());
      for (int i = 0; i < comps.size(); i++) {
        BeanInstance bi = (BeanInstance)comps.elementAt(i);
        JComponent c = (JComponent)bi.getBean();
        Dimension d = c.getPreferredSize();
        c.setBounds(bi.getX(), bi.getY(), d.width, d.height);
        c.revalidate();
      }
    }
View Full Code Here

        draggedNode = path.getLastPathComponent();
        if (drawImage) {
          Rectangle pathBounds = tree.getPathBounds(path); // getpathbounds
                                    // of
                                    // selectionpath
          JComponent lbl = (JComponent) tree
              .getCellRenderer()
              .getTreeCellRendererComponent(
                  tree,
                  draggedNode,
                  false,
                  tree.isExpanded(path),
                  tree.getModel() .isLeaf(path.getLastPathComponent()),
                  0, false);// returning the label
          lbl.setBounds(pathBounds);// setting bounds to lbl
          image = new BufferedImage(lbl.getWidth(), lbl.getHeight(),
              java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);// buffered
                                      // image
                                      // reference
                                      // passing
                                      // the
                                      // label's
                                      // ht
                                      // and
                                      // width
          Graphics2D graphics = image.createGraphics();// creating
                                  // the
                                  // graphics
                                  // for
                                  // buffered
                                  // image
          graphics.setComposite(AlphaComposite.getInstance(
              AlphaComposite.SRC_OVER, 0.5f)); // Sets the
                                // Composite for
                                // the
                                // Graphics2D
                                // context
          lbl.setOpaque(false);
          lbl.paint(graphics); // painting the graphics to label
          graphics.dispose();
        }
        dragSource.startDrag(dge, DragSource.DefaultMoveNoDrop, image,
            new Point(0, 0), new TransferableNode(draggedNode),
            this);
View Full Code Here

    gb = (GridBagLayout) getLayout();
    gc = new GridBagConstraints();
      gc.gridx = 0;
      gc.weightx = 1.0;
      gc.gridy = GridBagConstraints.RELATIVE;
    JComponent glue;
    glue = new JPanel(); gc.weighty = 1.0; gb.setConstraints(glue, gc); add(glue); gc.weighty = 0.0;
    gb.setConstraints(enableLabel, gc);    add(enableLabel);
    gb.setConstraints(enableButton, gc);   add(enableButton);
    glue = new JPanel(); gc.weighty = 1.0; gb.setConstraints(glue, gc); add(glue); gc.weighty = 0.0;
      gc.fill = GridBagConstraints.HORIZONTAL;
View Full Code Here

    getPopupMenu().repaint();
  }

  private void setPreferedSizeForMenuItems(Component component) {
    if (component instanceof JComponent && !(component instanceof JPopupMenu.Separator)) {
      JComponent jcomp = (JComponent) component;

      int width = jcomp.getPreferredSize().width;
      int height = jcomp.getPreferredSize().height;

      if (jcomp.getBorder() != null) {
        Insets insets = jcomp.getBorder().getBorderInsets(component);
        width += insets.left + insets.right;
      }
      if (width > maxWidth || height > maxHeight) {
        if (width > maxWidth) {
          maxWidth = width;
        }
        if (height > maxHeight) {
          maxHeight = height;
          setMaxItemToDisplay();
        }

        for (Component scrollableItem : scrollableItems) {
          if (scrollableItem instanceof JComponent && !(scrollableItem instanceof JPopupMenu.Separator)) {
            JComponent jComponent = (JComponent) scrollableItem;
            jComponent.setPreferredSize(new Dimension(maxWidth, maxHeight));
          }
        }
      } else {
        jcomp.setPreferredSize(new Dimension(maxWidth, maxHeight));
      }
View Full Code Here

  /**
   * Start the scrolling. Please don't forget to call stopScrolling
   * at the end
   */
  public void startScrolling() {
    JComponent component = (JComponent) getViewport().getView();
    locationY = getViewport().getExtentSize().height;
    component.setVisible(true);
    component.setLocation(0, locationY);
    timer.start();
  }
View Full Code Here

  public void stopScrolling() {
    timer.stop();
  }

  public void actionPerformed(ActionEvent e) {
    JComponent component = (JComponent) getViewport().getView();
    locationY -= scrollOffset;
    component.setLocation(0, locationY);

    if (component.getPreferredSize().height + locationY < 0) {
      locationY = getViewport().getExtentSize().height;
      component.setVisible(true);
      component.setLocation(0, locationY);
    }
  }
View Full Code Here

TOP

Related Classes of javax.swing.JComponent$AccessibleJComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.