Package javax.swing

Examples of javax.swing.Spring$SumSpring


        SpringLayout layout = new SpringLayout();
        parent.setLayout(layout);

        // Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < cols; c++) {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++) {
                width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
            }
            for (int r = 0; r < rows; r++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        // Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++) {
            Spring height = Spring.constant(0);
            for (int c = 0; c < cols; c++) {
                height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
            }
            for (int c = 0; c < cols; c++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
View Full Code Here


    }

    private void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
        SpringLayout layout = (SpringLayout) parent.getLayout();

        Spring x = Spring.constant(initialX);
        for (int c = 0; c < cols; c++) {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++) {
                width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
            }
            for (int r = 0; r < rows; r++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++) {
            Spring height = Spring.constant(0);
            for (int c = 0; c < cols; c++) {
                height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
            }
            for (int c = 0; c < cols; c++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
View Full Code Here

    content.setVisible(true);
    SpringLayout sl = new SpringLayout();
    content.setLayout(sl);
   
    // defining the basic springs
    Spring top = sl.getConstraint(SpringLayout.NORTH, content);
    Spring left = sl.getConstraint(SpringLayout.WEST, content);
    Spring bottom = sl.getConstraint(SpringLayout.SOUTH, content);
    Spring right = sl.getConstraint(SpringLayout.EAST, content);

    // add the main menu
    log.debug("Adding main menu...");
    mainMenu.setVisible(true);
    // springs for the menu
    Spring menuWidth = Spring.sum(right, Spring.minus(left));
    Spring menuHeight = Spring.constant(20);
    content.add(mainMenu, new SpringLayout.Constraints(top,left,menuWidth,menuHeight));

    // add the status panel
    Spring statusWidth = Spring.constant(146);
    Spring statusHeight = Spring.sum(Spring.sum(bottom, Spring.minus(top)), Spring.minus(menuHeight));
    Spring statusTop = Spring.sum(bottom, Spring.minus(statusHeight));
    Spring statusLeft = Spring.sum(right, Spring.minus(statusWidth));
    log.debug("Adding status panel...");
    sp.setVisible(true);
    content.add(sp, new SpringLayout.Constraints(statusLeft,statusTop,statusWidth,statusHeight));
    // put the status panel in the repository
    PanelRepository.add(PanelRepository.STATUS_PANEL, sp);
    sp.repaint();

//    // add the message panel
//    log.debug("Adding message panel...");
    Spring messHeight = Spring.constant(80);
    Spring messTop = Spring.sum(bottom, Spring.minus(messHeight));
    Spring messLeft = Spring.sum(left, statusWidth);
    Spring messWidth = Spring.sum(right, Spring.minus(messLeft));
//    messP.setVisible(true);
//    content.add(messP, new SpringLayout.Constraints(messLeft,messTop,messWidth,messHeight));
//    PanelRepository.add(PanelRepository.MESSAGE_PANEL, messP);

    // finally, add the map panel
    log.debug("Adding map panel...");
    // map height with message panel:
    // Spring mapHeight = Spring.sum(messTop, Spring.minus(Spring.sum(top, menuHeight)));
    // map height without message panel:
    Spring mapHeight = Spring.sum(bottom, Spring.minus(Spring.sum(top, menuHeight)));
    Spring mapTop = Spring.sum(top, menuHeight);
    Spring mapLeft = left;
    Spring mapWidth = Spring.sum(right, Spring.minus(statusWidth));
   
    mp.setVisible(true);
    // mp.addMouseListener(new GUIEventListener());

    content.add(mp, new SpringLayout.Constraints(mapLeft,mapTop,mapWidth,mapHeight));
View Full Code Here

    content.setVisible(true);
    SpringLayout sl = new SpringLayout();
    content.setLayout(sl);
   
    // defining the basic springs
    Spring top = sl.getConstraint(SpringLayout.NORTH, content);
    Spring left = sl.getConstraint(SpringLayout.WEST, content);
    Spring bottom = sl.getConstraint(SpringLayout.SOUTH, content);
    Spring right = sl.getConstraint(SpringLayout.EAST, content);

    // add the map panel
    log.debug("Adding map panel...");
    Spring mapHeight = Spring.sum(bottom, top);
    Spring mapTop = top;
    Spring mapLeft = left;
    Spring mapWidth = Spring.sum(right, Spring.minus(left));
   
    mp.setVisible(true);

    content.add(mp, new SpringLayout.Constraints(mapLeft,mapTop,mapWidth,mapHeight));
   
View Full Code Here

    this.getContentPane().setBackground(new Color(180,180,255));

    SpringLayout layout = new SpringLayout();
    this.setLayout(layout);
   
    Spring x = Spring.constant(20);
    Spring y = Spring.constant(40);
    Spring width = Spring.constant(150);
    Spring height = Spring.constant(40);

    message.setFont(new Font("SansSerif", Font.BOLD, 16));
    message.setForeground(Color.RED);
    this.add( message, new SpringLayout.Constraints(x,y,width,height) );
View Full Code Here

    });

    SpringLayout sl = new SpringLayout();
    this.setLayout(sl);
   
    Spring top = Spring.constant(20);
    Spring left = Spring.constant(10);
    log.debug("w:"+this.getWidth());
    Spring width = Spring.constant(110);
    Spring height = Spring.constant(40);
    this.add(startGameButton, new SpringLayout.Constraints(top,left,width,height));
       
    this.addMouseListener(this);
   
    this.addKeyListener(GUIEventListener.getInstance());
View Full Code Here

   
    loc.translate((PanelRepository.get(PanelRepository.MAIN_WINDOW).getWidth()-300)/2, 50);
    this.setLocation( loc );
   
    // springs for the buttons
    Spring buttonWidth = Spring.constant(100);
    Spring buttonHeight = Spring.constant(20);
    Spring x = Spring.constant(200);
    Spring y = Spring.constant(290);
    JButton ok = new JButton("OK");
    ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        log.debug("ok "+arg0.getActionCommand());
        saveFields();
        setVisible(false);
        log.debug("Options closed, root="+getRootPane().hashCode());
      }
     
    });
    this.add(ok, new SpringLayout.Constraints(x,y,buttonWidth,buttonHeight));

    x = Spring.constant(310);
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        log.debug("cancel "+arg0.getActionCommand());
        setVisible(false);
      }
     
    });
    this.add(cancel, new SpringLayout.Constraints(x,y,buttonWidth,buttonHeight));
   
    Spring width = Spring.constant(300);
    Spring height = Spring.constant(20);
    x = Spring.constant(10);
    y = Spring.constant(20);
    this.add(cheat, new SpringLayout.Constraints(x,y,width,height));

    JLabel mrXalgoLabel = new JLabel("MrX algorithm: ");
View Full Code Here

          System.err
              .println("The first argument to makeGrid must use SpringLayout.");
          return;
        }

        Spring xPadSpring = Spring.constant(xPad);
        Spring yPadSpring = Spring.constant(yPad);
        Spring initialXSpring = Spring.constant(initialX);
        Spring initialYSpring = Spring.constant(initialY);
        int max = rows * cols;

        //Calculate Springs that are the max of the width/height so that all
        //cells have the same size.
        Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0))
            .getWidth();
        Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0))
            .getWidth();
        for (int i = 1; i < max; i++) {
          SpringLayout.Constraints cons = layout.getConstraints(parent
              .getComponent(i));

View Full Code Here

              .println("The first argument to makeCompactGrid must use SpringLayout.");
          return;
        }

        //Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < cols; c++) {
          Spring width = Spring.constant(0);
          for (int r = 0; r < rows; r++) {
            width = Spring.max(width, getConstraintsForCell(r, c, parent,
                cols).getWidth());
          }
          for (int r = 0; r < rows; r++) {
            SpringLayout.Constraints constraints = getConstraintsForCell(r,
                c, parent, cols);
            constraints.setX(x);
            constraints.setWidth(width);
          }
          x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        //Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++) {
          Spring height = Spring.constant(0);
          for (int c = 0; c < cols; c++) {
            height = Spring.max(height, getConstraintsForCell(r, c, parent,
                cols).getHeight());
          }
          for (int c = 0; c < cols; c++) {
View Full Code Here

        catch (ClassCastException exc) {
            System.err.println("The first argument to makeGrid must use SpringLayout.");
            return;
        }

        Spring xPadSpring = Spring.constant(xPad);
        Spring yPadSpring = Spring.constant(yPad);
        Spring initialXSpring = Spring.constant(initialX);
        Spring initialYSpring = Spring.constant(initialY);
        int max = rows * cols;

        //Calculate Springs that are the max of the width/height so that all
        //cells have the same size.
        Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
        Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
        for (int i = 1; i < max; i++) {
            SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

            maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
            maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
View Full Code Here

TOP

Related Classes of javax.swing.Spring$SumSpring

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.