Esempio n. 1
0
  public void paint(Graphics g) {
    super.paint(g);
    if (screen.equalsIgnoreCase("title")) {
      MyPanel.score = 0;
      hs = new Highscore();
      c.removeAll();
      c.add(ts);
      panel = null;
      ts.revalidate();
    } else if (screen.equalsIgnoreCase("instructions")) {
      c.removeAll();
      c.add(instructions);
      instructions.revalidate();
    } else if (screen.equalsIgnoreCase("mode")) {
      c.removeAll();
      c.add(mode);
      mode.revalidate();
    } else if (screen.equalsIgnoreCase("difficulty")) {
      c.removeAll();
      c.add(dif);
      dif.revalidate();
    } else if (screen.equalsIgnoreCase("highscore")) {
      if (hs.returnCount() == 0) {
        c.removeAll();
        c.add(hs);
        c.validate();
      }
    } else if (screen.equalsIgnoreCase("gameover")) {
      if (!once) {
        c.removeAll();
        c.add(gg);
        once = true;
        c.validate();
      }

    } else {
      if (once) {
        c.removeAll();
        panel = new MyPanel(THA.WIDTH, THA.HEIGHT, ai, diff);
        c.setLayout(new BorderLayout());
        c.add(panel.returnNs(), BorderLayout.WEST);
        c.add(panel, BorderLayout.CENTER);
        c.add(btns, BorderLayout.SOUTH);
        c.add(panel.returnAmmo(), BorderLayout.EAST);
        c.validate();
        once = false;
      }
    }
    repaint();
  }
Esempio n. 2
0
  // handle button events by toggling between layouts
  public void actionPerformed(ActionEvent event) {
    if (toggle) container.setLayout(gridLayout2); // set layout to second
    else container.setLayout(gridLayout1); // set layout to first

    toggle = !toggle; // set toggle to opposite value
    container.validate(); // re-lay out container
  } // end method actionPerformed
Esempio n. 3
0
  public void addClient() {
    client =
        new Canvas() {
          public void paint(Graphics g) {
            super.paint(g);
          }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc =
        startClient(
            new Rectangle[] {
              fbounds,
              dummy.getBounds(),
              toFocusBounds,
              new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
              new Rectangle(10, 130, 20, 20)
            },
            pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
  }
Esempio n. 4
0
    /**
     * Updates the <code>Toolbar</code> represented by this folder.
     *
     * @param cookies array of instance cookies for the folder
     * @return the updated <code>ToolbarPool</code> representee
     */
    protected Object createInstance(InstanceCookie[] cookies)
        throws java.io.IOException, ClassNotFoundException {
      // refresh the toolbar's content
      getToolbar().removeAll();
      for (int i = 0; i < cookies.length; i++) {
        try {
          Object obj = cookies[i].instanceCreate();
          if (obj instanceof Presenter.Toolbar) {
            obj = ((Presenter.Toolbar) obj).getToolbarPresenter();
          }
          if (obj instanceof Component) {
            Component comp = (Component) obj;
            getToolbar().add(comp);
          }
        } catch (java.io.IOException ex) {
        } catch (ClassNotFoundException ex) {
        }
      }

      // invalidate the toolbar and its parent
      toolbar.invalidate();
      java.awt.Container parent = toolbar.getParent();
      if (parent != null) {
        parent.validate();
        parent.repaint();
      }
      return toolbar;
    }
 /**
  * @param renderable
  * @param widget
  * @param container
  * @requires renderable != null && renderable.blockID != null && renderable.blockID != Block.NULL
  *     && widget != null && container != null
  * @modifies renderable && children blocks connected to renderable
  * @effects removes renderable from container and widget and re-renders renderable block, widget,
  *     and container appropriately. Repeats for all of renderable's children.
  */
 private void removeBlock(
     RenderableBlock renderable, WorkspaceWidget widget, Container container) {
   widget.removeBlock(renderable);
   container.remove(renderable);
   container.validate();
   container.repaint();
   renderable.setParentWidget(null);
   // Workspace.getInstance().notifyListeners(new WorkspaceEvent(widget, renderable.getBlockID(),
   // WorkspaceEvent.BLOCK_REMOVED));
   for (BlockConnector child :
       BlockLinkChecker.getSocketEquivalents(
           workspace.getEnv().getBlock(renderable.getBlockID()))) {
     if (child == null || child.getBlockID().equals(Block.NULL)) {
       continue;
     }
     RenderableBlock childRenderable = workspace.getEnv().getRenderableBlock(child.getBlockID());
     if (childRenderable == null) {
       continue;
     }
     removeBlock(childRenderable, widget, container);
   }
   if (renderable.hasComment()) {
     renderable.removeComment();
   }
   workspace.notifyListeners(
       new WorkspaceEvent(
           workspace, widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
 }
  private void removeOrder(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_removeOrder

    // let the user confirm removal
    int userSure =
        JOptionPane.showConfirmDialog(
            client,
            "Bestellung wirklich" + " löschen?",
            "Löschung bestätigen",
            JOptionPane.YES_NO_OPTION);

    if (userSure != JOptionPane.YES_OPTION) return;

    // remove the order from the database
    try {
      stmt.executeUpdate("DELETE FROM orderParts WHERE orderId = " + orderID);
      stmt.executeUpdate("DELETE FROM orders WHERE id = " + orderID);
    } catch (SQLException e) {
      JOptionPane.showMessageDialog(
          client,
          "Fehler bei der Kommunikation" + "mit der Datenbank.",
          "Netzwerkfehler",
          JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
      return;
    }

    // remove this panel
    java.awt.Container parent = getParent();
    parent.remove(this);
    parent.validate();
    parent.repaint();
  } // GEN-LAST:event_removeOrder
Esempio n. 7
0
  /** Method for initializing a default Dialog window ready for GC Content input */
  public void init() {
    JLabel fastaFileLabel = new JLabel("Select FASTA File:");
    JPanel fastaFileField = prepareFastaField(mFasta);

    JPanel beginField = prepareRangeField("Start Position:", mRangeBegin);
    JPanel endField = prepareRangeField("End Position:", mRangeEnd);

    JPanel nucleotideRangeField = new JPanel();
    nucleotideRangeField.setLayout(new FlowLayout(FlowLayout.LEADING));
    nucleotideRangeField.add(beginField);
    nucleotideRangeField.add(endField);

    JPanel lengthMin = prepareRangeField("Length Min:", mLengthMin);
    JPanel lengthMax = prepareRangeField("Length Max:", mLengthMax);
    JPanel maxOnly = prepareRangeField("Maximal Repeats only?", mMaxOnly);

    JPanel frameField = new JPanel();
    frameField.setLayout(new FlowLayout(FlowLayout.LEADING));
    frameField.add(lengthMin);
    frameField.add(lengthMax);
    frameField.add(maxOnly);

    mPane.add(fastaFileLabel);
    mPane.add(fastaFileField);

    mPane.add(nucleotideRangeField);

    mPane.add(frameField);

    mPane.add(initControls());

    mPane.validate();
  }
Esempio n. 8
0
  /**
   * Shows this glass box on the glass pane.
   *
   * @param glassPane the glass pane
   * @param originX the location on the X-axis to position the glass box
   * @param originY the location on the Y-axis to position the glass box
   */
  public void showOnGlassPane(Container glassPane, int originX, int originY) {
    Dimension gd = glassPane.getSize();
    Dimension bd = getPreferredSize();

    int x = Math.min(originX, gd.width - bd.width);
    int y = Math.min(originY, gd.height - bd.height);

    if (x < 0) {
      x = 0;
    }

    if (y < 0) {
      y = 0;
    }

    int width = x + bd.width < gd.width ? bd.width : gd.width;
    int height = y + bd.height < gd.height ? bd.height : gd.height;

    glassPane.setLayout(null);
    setBounds(x, y, width, height);
    glassPane.add(this);
    glassPane.setVisible(true);

    Container topLevel = getTopLevel();
    topLevel.validate();
    topLevel.repaint();
  }
Esempio n. 9
0
  public void start() {
    snakePanel.init();

    rootContainer.validate();
    rootContainer.setVisible(true);
    rootContainer.repaint();

    snakePanel.requestFocus();
    snakePanel.start();
  }
Esempio n. 10
0
  /**
   * Dismisses this glass box. This causes the glass box to be removed from it's parent and ensure
   * that the display is correctly updated.
   */
  public void dismiss() {
    JComponent parent = (JComponent) getParent();

    if (parent != null) {
      Container toplevel = parent.getTopLevelAncestor();
      parent.remove(this);
      toplevel.validate();
      toplevel.repaint();
    }
  }
 @Override
 public void validate() {
   super.validate();
   if (this.m_target != null) {
     this.screenTargetMoved(
         null,
         this.m_target.getScreenX(),
         this.m_target.getScreenY(),
         this.m_target.getScreenTargetHeight());
   }
 }
Esempio n. 12
0
 private void setPage(AbstractWizardPage newPage) {
   Container wizardPageContainer = wizard.getWizardPageContainer();
   if (currentPage != null) {
     wizardPageContainer.remove(currentPage);
   }
   currentPage = newPage;
   currentPage.setWizardController(this);
   wizardPageContainer.add(currentPage);
   wizardPageContainer.validate();
   wizardPageContainer.repaint();
   updateButtons();
 }
 @SuppressWarnings({"UnusedDeclaration"})
 protected void cancelButtonActionPerformed(ActionEvent event) {
   if (this.thread.isAlive()) {
     // Cancel thread
     this.thread.interrupt();
     this.cancelButton.setBackground(Color.ORANGE);
     this.cancelButton.setText("Remove");
     this.updateTimer.stop();
   } else {
     // Remove from monitor panel
     Container top = this.getTopLevelAncestor();
     this.getParent().remove(this);
     top.validate();
   }
 }
 private void captureWindow(View _aView, String _aWindow) {
   if (_aWindow == null) {
     return;
   }
   RootPaneContainer root;
   if (_parentFrame != null) {
     root = _parentFrame;
   } else {
     root = this;
   }
   Component comp = _aView.getComponent(_aWindow);
   if (comp == null) {
     return;
   }
   // Dimension size = comp.getSize();
   if (comp instanceof DrawingFrame) {
     comp.setVisible(true);
     Container contentPane = ((RootPaneContainer) comp).getContentPane();
     contentPane.setVisible(true);
     root.setContentPane(contentPane);
     Component glassPane = ((RootPaneContainer) comp).getGlassPane();
     root.setGlassPane(glassPane);
     glassPane.setVisible(true);
     ((DrawingFrame) comp).setKeepHidden(true);
     ((DrawingFrame) comp).setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   } else if (comp instanceof JDialog) {
     comp.setVisible(true);
     Container contentPane = ((RootPaneContainer) comp).getContentPane();
     contentPane.setVisible(true);
     root.setContentPane(contentPane);
     Component glassPane = ((RootPaneContainer) comp).getGlassPane();
     root.setGlassPane(glassPane);
     glassPane.setVisible(true);
     ((JDialog) comp).dispose();
   } else {
     root.getContentPane().setLayout(new java.awt.BorderLayout());
     root.getContentPane().add(comp, java.awt.BorderLayout.CENTER);
     root.getContentPane().validate();
     Container oldParent = comp.getParent();
     if (oldParent != null) {
       oldParent.validate();
     }
   }
   if (_parentFrame != null) {
     _parentFrame.pack();
   }
 }
  /** Externalize panel (internal method) */
  void externalizeInternal() {
    if (!externalizationAutorized) return;

    // externalize
    if (parent != null) {
      parent.remove(this);
      parent.validate();
    }

    frame.add(this, BorderLayout.CENTER);
    frame.validate();
    frame.addToDesktopPane();
    frame.setVisible(true);

    // notify
    fireStateChange(true);
  }
  /** Internalize panel (internal method) */
  void internalizeInternal() {
    if (!internalizationAutorized) return;

    // internalize
    frame.setVisible(false);
    frame.remove(this);
    frame.validate();
    frame.removeFromMainDesktopPane();

    if (parent != null) {
      parent.add(this);
      parent.validate();
    }

    // notify
    fireStateChange(false);
  }
Esempio n. 17
0
  public static void deleteBlock(RenderableBlock block) {
    block.setLocation(0, 0);

    WorkspaceWidget widget = block.getParentWidget();
    if (widget != null) {
      widget.removeBlock(block);
    }

    Container parent = block.getParent();
    if (parent != null) {
      parent.remove(block);
      parent.validate();
    }

    block.setParentWidget(null);
    Workspace workspace = block.getWorkspace();
    workspace.notifyListeners(
        new WorkspaceEvent(workspace, widget, block.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
  }
Esempio n. 18
0
 private void removeChildrenBlock(
     RenderableBlock renderable, WorkspaceWidget widget, Container container) {
   widget.removeBlock(renderable);
   container.remove(renderable);
   container.validate();
   container.repaint();
   renderable.setParentWidget(null);
   // Workspace.getInstance().notifyListeners(new WorkspaceEvent(widget, renderable.getBlockID(),
   // WorkspaceEvent.BLOCK_REMOVED));
   for (BlockConnector child : workspace.getEnv().getBlock(renderable.getBlockID()).getSockets()) {
     if (child == null || child.getBlockID().equals(Block.NULL)) {
       continue;
     }
     RenderableBlock childRenderable = workspace.getEnv().getRenderableBlock(child.getBlockID());
     if (childRenderable == null) {
       continue;
     }
     removeBlock(childRenderable, widget, container);
   }
   // If it is a procedure block, we want to delete the entire stack
   if (workspace.getEnv().getBlock(renderable.getBlockID()).isProcedureDeclBlock()) {
     if (workspace.getEnv().getBlock(renderable.getBlockID()).getAfterBlockID() != Block.NULL) {
       removeAfterBlock(
           workspace
               .getEnv()
               .getRenderableBlock(
                   workspace.getEnv().getBlock(renderable.getBlockID()).getAfterBlockID()),
           widget,
           container);
       this.disconnectBlock(
           workspace
               .getEnv()
               .getBlock(workspace.getEnv().getBlock(renderable.getBlockID()).getAfterBlockID()),
           widget);
     }
   }
   if (renderable.hasComment()) {
     renderable.removeComment();
   }
   workspace.notifyListeners(
       new WorkspaceEvent(
           workspace, widget, renderable.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
 }
Esempio n. 19
0
  public void blockDropped(RenderableBlock block) {
    // remove block
    WorkspaceWidget oldParent = block.getParentWidget();
    if (oldParent != null) oldParent.removeBlock(block);

    Container parent = block.getParent();
    if (parent != null) {
      parent.remove(block);
      parent.validate();
      parent.repaint();
      block.setParentWidget(null);
    }

    // fire to workspace that block was removed
    // DO FIRE AN EVENT IF BLOCK IS REMOVED BY USER!!!!
    // NOTE however that we do not throw na event for adding internally
    Workspace.getInstance()
        .notifyListeners(
            new WorkspaceEvent(this, block.getBlockID(), WorkspaceEvent.BLOCK_REMOVED));
  }
  public void init() {

    setupAppletText();

    /**
     * Set up the contentPane JPanel instance along with the additional JPanels to create the
     * appropriate layout
     */
    container = getContentPane();

    frame = new JFrame();

    ppPanel = KoboPostProcPanel.getInstance(frame);

    container.add(ppPanel); // Generated

    container.validate();
    setVisible(true);

    this.setPreferredSize(new Dimension(500, 400));
  }
 private void setBounds(Point location, Dimension size) {
   if (myView != null) {
     if (size == null) {
       size = myView.getSize();
     }
     if (location == null) {
       location = myView.getLocation();
     } else {
       Component parent = myView instanceof Window ? null : myView.getParent();
       if (parent != null) {
         SwingUtilities.convertPointFromScreen(location, parent);
       }
     }
     myView.setBounds(location.x, location.y, size.width, size.height);
     if (myView.isVisible()) {
       myView.invalidate();
       myView.validate();
       myView.repaint();
     }
   }
 }
Esempio n. 22
0
  /**
   * @param filenames
   * @exception Exception if internal error
   */
  public ChestImageViewer(String filenames[]) throws Exception {
    DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas();
    if (displayDeviceAreas == null) {
      System.err.println("Cannot determine device display areas");
    } else {
      System.err.println("Found " + displayDeviceAreas.length + " device display areas");
      for (int i = 0; i < displayDeviceAreas.length; ++i) {
        System.err.println("[" + i + "] = " + displayDeviceAreas[i]);
        displayDeviceAreas[i].getFrame().setBackground(Color.black);
        displayDeviceAreas[i].getFrame().setVisible(true);
      }

      {
        // Need to actually add something to the unused left display frame, else background will not
        // be set to black on Windows
        JPanel backgroundPanel = new JPanel();
        backgroundPanel.setBackground(Color.black);
        displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel);
        displayDeviceAreas[0].getFrame().validate();
      }

      frame = displayDeviceAreas[1].getFrame();

      Container content = frame.getContentPane();
      content.setLayout(new GridLayout(1, 1));
      multiPanel = new JPanel();
      // multiPanel.setBackground(Color.black);
      frameWidth = (int) frame.getWidth();
      frameHeight = (int) frame.getHeight();
      Dimension d = new Dimension(frameWidth, frameHeight);
      // multiPanel.setSize(d);
      multiPanel.setPreferredSize(d);
      multiPanel.setBackground(Color.black);
      content.add(multiPanel);
      // frame.pack();
      content.validate();

      loadMultiPanelFromSpecifiedFiles(filenames);
    }
  }
Esempio n. 23
0
  public void setMemoryLevel(int width, int heigh, File f) {
    m = width;
    n = heigh;
    inconNum = m;
    gradeFile = f;
    block = new Block[m * n];
    icon = new ImageIcon[inconNum];
    for (int i = 0; i < icon.length; i++) {
      icon[i] = new ImageIcon("src/com/eric/lession/testmemory/a" + i + ".gif");
    }
    for (int i = 0; i < block.length; i++) {
      block[i] = new Block();
      block[i].setCloseIcon(new ImageIcon("src/com/eric/lession/testmemory/close.gif"));
    }

    memoryTestPane = new MemoryTestPane(block, icon, m, n, gradeFile);
    container.removeAll();
    container.add(memoryTestPane, BorderLayout.CENTER);
    container.add(tipLable, BorderLayout.SOUTH);
    container.validate();
    this.validate();
  }
Esempio n. 24
0
  public GamePlayView(PlayController controller) {
    this.controller = controller;
    setTitle("Game Maker: Play game");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setMinimumSize(
        new Dimension(
            Dimensions.GAME_MAKER_RIGHT_PANEL_WIDTH, Dimensions.GAME_MAKER_RIGHT_PANEL_HEIGHT));
    setPreferredSize(
        new Dimension(
            Dimensions.GAME_MAKER_RIGHT_PANEL_WIDTH, Dimensions.GAME_MAKER_RIGHT_PANEL_HEIGHT));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout(20, 20));

    GamePanel gamePanelObj = new GamePanel();
    gamePanelObj.setBackground(Color.WHITE);
    gamePanelObj.setMinimumSize(
        new Dimension(
            Dimensions.GAME_MAKER_RIGHT_PANEL_WIDTH,
            Dimensions.GAME_MAKER_RIGHT_PANEL_HEIGHT - 50));
    gamePanelObj.setPreferredSize(
        new Dimension(
            Dimensions.GAME_MAKER_RIGHT_PANEL_WIDTH,
            Dimensions.GAME_MAKER_RIGHT_PANEL_HEIGHT - 50));
    gamePanelObj.revalidate();
    contentPane.add(gamePanelObj, BorderLayout.CENTER);

    JSeparator jSeparator = new JSeparator();
    contentPane.add(jSeparator, BorderLayout.SOUTH);

    msgLabel = new JLabel();
    msgLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 20));
    msgLabel.setBounds(200, 200, 200, 50);

    JPanel panelLeft = new JPanel();
    panelLeft.setBackground(Color.LIGHT_GRAY);
    panelLeft.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 5));
    contentPane.add(panelLeft, BorderLayout.SOUTH);

    playButton = new JButton();
    playButton.setText("Play");
    playButton.setFocusable(false);
    playButton.setEnabled(true);
    panelLeft.add(playButton);
    playButton.addActionListener(new playListener());

    stopButton = new JButton();
    stopButton.setText("Stop");
    stopButton.setFocusable(false);
    stopButton.setEnabled(true);
    panelLeft.add(stopButton);
    stopButton.addActionListener(new stopListener());

    scoreLable = new JLabel("Score: ");
    scoreLable.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15));
    panelLeft.add(scoreLable);

    addKeyListener(new StrokeAdapter());

    contentPane.validate();
    setLocationRelativeTo(null);
  }
Esempio n. 25
0
  /**
   * This method is used at the end of a drag session to place the frame in either its original
   * parent as a docked JToolBar or in its floating frame.
   *
   * @param position The position of the mouse cursor relative to the JToolBar.
   * @param origin The screen position of the JToolBar before the drag session started.
   */
  protected void floatAt(Point position, Point origin) {
    Point p = new Point(position);
    int aoc = areaOfClick(origParent, SwingUtilities.convertPoint(toolBar, p, origParent));

    Container oldParent = toolBar.getParent();

    oldParent.remove(toolBar);
    oldParent.doLayout();
    oldParent.repaint();

    Container newParent;

    if (aoc == -1) newParent = ((RootPaneContainer) floatFrame).getContentPane();
    else {
      floatFrame.hide();
      newParent = origParent;
    }

    String constraint;
    switch (aoc) {
      case SwingConstants.EAST:
        constraint = BorderLayout.EAST;
        break;
      case SwingConstants.NORTH:
        constraint = BorderLayout.NORTH;
        break;
      case SwingConstants.SOUTH:
        constraint = BorderLayout.SOUTH;
        break;
      case SwingConstants.WEST:
        constraint = BorderLayout.WEST;
        break;
      default:
        constraint = BorderLayout.CENTER;
        break;
    }

    int newOrientation = SwingConstants.HORIZONTAL;
    if ((aoc != -1) && ((aoc == SwingConstants.EAST) || (aoc == SwingConstants.WEST)))
      newOrientation = SwingConstants.VERTICAL;

    if (aoc != -1) {
      constraintBeforeFloating = constraint;
      lastGoodOrientation = newOrientation;
    }

    newParent.add(toolBar, constraint);

    setFloating(aoc == -1, null);
    toolBar.setOrientation(newOrientation);

    Insets insets = floatFrame.getInsets();
    Dimension dims = toolBar.getPreferredSize();
    p = dragWindow.getOffset();
    setFloatingLocation(
        (position.x + origin.x) - p.x - ((insets.left + insets.right) / 2),
        (position.y + origin.y) - p.y - ((insets.top + insets.bottom) / 2));

    if (aoc == -1) {
      floatFrame.pack();
      floatFrame.setSize(
          dims.width + insets.left + insets.right, dims.height + insets.top + insets.bottom);
      floatFrame.show();
    }

    newParent.invalidate();
    newParent.validate();
    newParent.repaint();
  }
  /** Initialise the page with proper layout and all. */
  public void init() {
    content.removeAll();

    GridBagConstraints constraint = new GridBagConstraints();
    JTextArea area =
        new JTextArea(
            "Editing the Label of the class '"
                + ontClass.getLocalName()
                + "'. You need to define which property will be used to identify a particular instance of this class. "
                + "For example, to identify a paper you can use the title of that paper. "
                + "You can either directly use one of the property of this class or specify the property of a related class "
                + "(e.g. for an ourSpaces account, you might want to use the name of the Person that holds that account)");
    area.setEditable(false);
    area.setLineWrap(true);
    area.setWrapStyleWord(true);
    constraint.insets = new Insets(10, 10, 10, 10);
    constraint.fill = GridBagConstraints.HORIZONTAL;
    constraint.anchor = GridBagConstraints.CENTER;
    constraint.weightx = 1.0;
    constraint.gridx = 0;
    constraint.gridy = 0;
    constraint.gridwidth = 2;
    content.add(area, constraint);

    directPropertyTypeButton = new JRadioButton("Direct");
    directPropertyTypeButton.setActionCommand("direct");
    directPropertyTypeButton.setSelected(true);

    indirectPropertyTypeButton = new JRadioButton("Indirect");
    indirectPropertyTypeButton.setActionCommand("indirect");

    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(directPropertyTypeButton);
    group.add(indirectPropertyTypeButton);

    // Register a listener for the radio buttons.
    directPropertyTypeButton.addActionListener(this);
    indirectPropertyTypeButton.addActionListener(this);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(1, 0));
    JLabel propTypeLabel = new JLabel("Property Type: ");
    radioPanel.add(propTypeLabel);
    radioPanel.add(directPropertyTypeButton);
    radioPanel.add(indirectPropertyTypeButton);

    constraint.gridy = 1;
    content.add(radioPanel, constraint);

    // Initialise list of direct properties
    initDirectPropertyList();

    // Create Panel for direct properties
    constraint.weightx = 1;
    constraint.weighty = 0.7; // add extra space to the tree widget, so it can expand
    constraint.anchor = GridBagConstraints.FIRST_LINE_START;
    constraint.gridx = 1;
    constraint.gridy = 2;
    constraint.fill = GridBagConstraints.BOTH;
    constraint.gridwidth = 1;
    propertyList.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    directPropertyPane = new JScrollPane(propertyList);
    Border blackBorder = BorderFactory.createLineBorder(Color.black);
    directPropertyPane.setBorder(blackBorder);
    content.add(directPropertyPane, constraint);

    // Create Panel for indirect properties at the same place as the direct prop panel, so that only
    // one is displayed at a time
    indirectPropertyPanel = new JPanel(new GridLayout(0, 2));
    indirectPropertyPanel.setBorder(blackBorder);
    JLabel linkingPropLabel = new JLabel(" Property linking to another class: ");
    linkingPropField = new JTextField(20);
    classSubjectPropCheckBox = new JCheckBox("This class is the subject of the above property");
    JLabel relatedClassPropLabel =
        new JLabel(" Property of the related class that identify the original class: ");
    relatedClassPropField = new JTextField(20);

    indirectPropertyPanel.add(linkingPropLabel);
    indirectPropertyPanel.add(linkingPropField);
    indirectPropertyPanel.add(classSubjectPropCheckBox);
    indirectPropertyPanel.add(new JLabel());
    indirectPropertyPanel.add(relatedClassPropLabel);
    indirectPropertyPanel.add(relatedClassPropField);
    content.add(indirectPropertyPanel, constraint);

    /** TODO: Add a list to allow user to add more than one property used as label */
    // List of properties used as label
    //        constraint.gridy = 3;
    //        constraint.weighty = 0.3;
    //        String[] testList = {"test", "poi", "sdfs"};
    //        content.add(new JScrollPane(new JList(testList)), constraint);
    //        content.repaint();

    constraint.fill = GridBagConstraints.NONE;
    constraint.anchor = GridBagConstraints.PAGE_START;
    constraint.weighty = 0;
    constraint.weightx = 0;
    constraint.gridx = 0;
    constraint.gridy = 4;
    constraint.gridwidth = 2;
    backBtn.addActionListener(this);
    saveBtn.addActionListener(this);
    // 		exampleBtn.addActionListener(this);

    Container cont = new Container();
    cont.add(backBtn);
    cont.add(saveBtn);
    // 		cont.add(exampleBtn);
    cont.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 20));
    content.add(cont, constraint);

    content.validate();
  }
Esempio n. 27
0
  RootWindow(Container container, Screen screen, Format[] format, Client c) {
    super(screen.rootId);
    rootwindow = container;
    client = c;
    screen.setRoot((Window) this);
    this.width = (short) (screen.width);
    this.height = (short) (screen.height);
    this.screen = screen;
    depth = screen.rootDepth;
    id = screen.rootId;
    type = DRAWABLE_WINDOW;
    x = y = 0;
    origin.x = 0;
    origin.y = 0;
    clss = (byte) InputOutput;
    for (int i = 0; i < format.length; i++) {
      if (format[i].depth == screen.rootDepth) {
        this.bitsPerPixel = format[i].bpp;
      }
    }
    setVisual(screen.rootVisual);
    setBackgroundIsPixel();
    background.pixel = screen.white;

    setBorderIsPixel();
    border.pixel = screen.black;
    borderWidth = 0;
    Resource.add(this);
    makeOptional();
    attr &= ~(1 << 3); // cursorIsNone

    optional.cursor = Cursor.rootCursor;
    setColormap(screen.defaultColormap);

    //  if(rootwindow instanceof JFrame){
    //    rootwindow.setSize(this.width+10, this.height+30); // ??
    //  }
    //  else{
    rootwindow.setSize(this.width, this.height);
    //  }

    try {
      ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance());
    } catch (Exception e) {
      System.err.println(e);
      /*ddxwindow=new DDXWindowImp();*/
    }

    ddxwindow.init(this);
    ddxwindow.setLocation(0, 0);

    if (rootwindow instanceof Frame) {
      // ((Frame)rootwindow).setLayout(null);
      ((Frame) rootwindow).setResizable(false);
      ((Frame) rootwindow).setMenuBar(null);
      ((Frame) rootwindow).add((java.awt.Component) ddxwindow);
    } else if (rootwindow instanceof Applet) {
      ((Applet) rootwindow).add((java.awt.Component) ddxwindow);
    }
    /*
        else if(rootwindow instanceof JFrame){
          ((JFrame)rootwindow).getContentPane().setLayout(null);
          ((JFrame)rootwindow).setResizable(false);
          ((JFrame)rootwindow).setJMenuBar(null);
          ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if(rootwindow instanceof JWindow){
          ((JWindow)rootwindow).getContentPane().setLayout(null);
          ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if (rootwindow instanceof JApplet){
          ((JApplet)rootwindow).setJMenuBar(null);
          ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
    */
    else {
      rootwindow.add((java.awt.Component) ddxwindow);
    }

    if (screen.windowmode != WeirdX.InBrowser) {
      rootwindow.addNotify();
    } else {
      rootwindow.setVisible(true);
    }
    ddxwindow.setVisible(true);

    {
      rootwindow.validate();
      Insets insets = rootwindow.getInsets();
      rootwindow.setSize(
          this.width + insets.left + insets.right, this.height + insets.top + insets.bottom);
      ddxwindow.setLocation(insets.left, insets.top);
      rootwindow.validate();
    }

    ddxwindow.requestFocus();
    Window.focus.win = id;

    Window.LOCK = rootwindow.getTreeLock();
    Client.LOCK = rootwindow.getTreeLock();
    Resource.LOCK = rootwindow.getTreeLock();

    spriteTrace[0] = this;
    sprite.win = this;
  }
Esempio n. 28
0
  public Memory() {
    primaryFile = new File("src/com/eric/lession/testmemory/primaryTop");
    integermediateFile = new File("src/com/eric/lession/testmemory/intermediateTop");
    advancedFile = new File("src/com/eric/lession/testmemory/advancedTop");
    block = new Block[m * n];
    inconNum = m;
    icon = new ImageIcon[inconNum];
    bar = new JMenuBar();
    menu = new JMenu("TEST MEMORY");
    primary = new JMenuItem("PRIMARY");
    intermediate = new JMenuItem("INTERMEDIATE");
    advanced = new JMenuItem("ADVANCE");
    primaryTop = new JMenuItem("PTOP");
    intermediateTop = new JMenuItem("ITOP");
    advancedTop = new JMenuItem("ATOP");
    primary.addActionListener(this);
    intermediate.addActionListener(this);
    advanced.addActionListener(this);
    primaryTop.addActionListener(this);
    intermediateTop.addActionListener(this);
    advancedTop.addActionListener(this);
    scoreList = new LinkedList();
    for (int i = 0; i < icon.length; i++) {
      icon[i] = new ImageIcon("src/com/eric/lession/testmemory/a" + i + ".gif");
    }
    for (int i = 0; i < block.length; i++) {
      block[i] = new Block();
      block[i].setCloseIcon(new ImageIcon("src/com/eric/lession/testmemory/close.gif"));
    }

    menu.add(primary);
    menu.add(intermediate);
    menu.add(advanced);
    menu.add(primaryTop);
    menu.add(intermediateTop);
    menu.add(advancedTop);
    bar.add(menu);
    setJMenuBar(bar);

    if (!primaryFile.exists()) {
      try {
        FileOutputStream fos = new FileOutputStream(primaryFile);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(scoreList);
        oos.close();
        fos.close();

      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    if (!integermediateFile.exists()) {
      try {
        FileOutputStream fos = new FileOutputStream(integermediateFile);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(scoreList);
        oos.close();
        fos.close();

      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    if (!advancedFile.exists()) {
      try {
        FileOutputStream fos = new FileOutputStream(advancedFile);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(scoreList);
        oos.close();
        fos.close();

      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    gradeFile = primaryFile;
    container = getContentPane();
    memoryTestPane = new MemoryTestPane(block, icon, m, n, gradeFile);
    tipLable = new JTextField("初级,你需要找出6个相同的方块");
    tipLable.setEditable(false);
    tipLable.setForeground(Color.red);
    setLayout(new BorderLayout());
    add(tipLable, BorderLayout.SOUTH);
    add(memoryTestPane, BorderLayout.CENTER);
    container.validate();
    setBounds(100, 100, 300, 260);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    setSize(500, 500);
    setLocation(300, 300);
    validate();
  }
Esempio n. 29
0
  public void showPinObj(PushpinIF pobj, boolean on) {
    Component comp = (Component) pobj;
    if (comp == null) return;
    Container p = comp.getParent();
    if (!on) {
      pobj.setPopup(false, true);
      if (p != null && p != tabbedPane) {
        p.remove(comp);
        p.validate();
        p.repaint();
      }
      if (popupComp == comp) popupComp = null;
      return;
    }

    if (popupComp != null) {
      if (popupComp != comp) {
        ((PushpinIF) popupComp).setPopup(false, true);
        p = popupComp.getParent();
        if (p != null && p != tabbedPane) {
          p.remove(popupComp);
        }
      }
      popupComp = null;
    }
    /*
    if (!isShowing()) {
        return;
    }
     */
    if (comp.isShowing()) {
      return;
    }
    Container p2 = null;
    p = pinPanel.getParent();
    while (p != null) {
      if (p instanceof JLayeredPane) p2 = p;
      p = p.getParent();
    }
    if (p2 == null) return;
    if (!isShowing()) {
      VnmrjIF vif = Util.getVjIF();
      vif.raiseToolPanel(on);
      setVisible(true);
    }

    popupComp = comp;
    p = p2;
    pobj.setPopup(true, true);
    /*
    Point pt0 = p.getLocationOnScreen();
    Point pt1 = getLocationOnScreen();
     */
    Point pt1 = getLocation();
    Dimension dim = getSize();
    int y0 = (int) ((float) dim.height * pobj.getRefY());
    int h = (int) ((float) dim.height * pobj.getRefH());
    int x = pt1.x + 2;
    int y = pt1.y + y0;
    p.add(comp, JLayeredPane.MODAL_LAYER);
    comp.setBounds(x, y, dim.width, dim.height - y0);
    ((JComponent) p).validate();
    /*
    p.repaint();
     */
  }
Esempio n. 30
0
 public void addFeatureTo(Container container) {
   addCenterComponent(getFeature(), container);
   container.validate();
   container.repaint();
 }