示例#1
0
  public ViewPanel(Node node, int renderType) {

    // Create render
    render = AppletModelManager.getInstance().createRender(node, renderType);
    Canvas canvas = render.getCanvas();

    render.setName(name);

    canvas.setPreferredSize(new Dimension(300, 300));
    canvas.setMinimumSize(new Dimension(100, 100));
    this.add(canvas, BorderLayout.CENTER);

    // Create render properties dialog
    renderDialog = new RenderProperties(render);
    renderDialog.setVisible(false);

    // Create pop-up menu
    popup = new JPopupMenu();

    JMenuItem menuItem = new JMenuItem("Properties");
    menuItem.addActionListener(this);
    popup.add(menuItem);

    // Add listener to components that can bring up popup menus.
    MouseListener popupListener = new PopupListener();
    canvas.addMouseListener(popupListener);

    this.setMinimumSize(new Dimension(100, 100));
    this.setPreferredSize(new Dimension(200, 200));
    SparkApplet.getViewPanel().add(this);
  }
示例#2
0
  public void actionPerformed(ActionEvent arg0) {
    Object src = arg0.getSource();

    try {
      if (src instanceof JMenuItem) {
        JMenuItem item = (JMenuItem) src;
        String name = item.getText();

        if (name.equals("Properties")) {
          renderDialog.init();
          renderDialog.setVisible(true);
        }
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex.toString());
    }
  }