Package javax.swing

Examples of javax.swing.Spring$HeightSpring


            System.err.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++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
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

      System.err.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++) {
        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

        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

            System.err.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());
            }
View Full Code Here

    final SpringLayout layout = new SpringLayout();
    comp = new JPanel(layout);
    comp.setBorder(BorderFactory.createEmptyBorder(6,6,6,6));
    comp.setOpaque(true);
   
    final Spring constant6 = Spring.constant(6);
    final Spring constant0 = Spring.constant(0);
    final Spring glue12 = Spring.constant(12,12,Short.MAX_VALUE);

    final JLabel label = new JLabel("ID: ");
    invalidLabel = new JLabel("Invalid URI");
    invalidLabel.setForeground(new Color(225, 25, 25));
    idText = new JTextField(19);
    idText.getDocument().addDocumentListener(this);
    idText.setMaximumSize(new Dimension(Short.MAX_VALUE, idText.getPreferredSize().height));
    comp.add(label);
    comp.add(idText);
    comp.add(invalidLabel);
    layout.putConstraint(SpringLayout.WEST, idText, constant6, SpringLayout.EAST, label);
    layout.putConstraint(SpringLayout.WEST, invalidLabel, constant6, SpringLayout.EAST, idText);
    Spring nextY = Spring.max(layout.getConstraint(SpringLayout.SOUTH, idText), layout.getConstraint(SpringLayout.SOUTH, label));
    nextY = Spring.sum(nextY, constant6);
   
    comboLabel = new JLabel();
    comboBox = new JComboBox();
    comboBox.addActionListener(this);
    comboBox.setEditable(false);
    comp.add(comboLabel);
    comp.add(comboBox);
   
    final SpringLayout.Constraints constraints = layout.getConstraints(comboLabel);
    constraints.setHeight(Spring.max(constraints.getHeight(), layout.getConstraints(comboBox).getHeight()));
    layout.putConstraint(SpringLayout.NORTH, comboBox, constant0, SpringLayout.NORTH, comboLabel);
    layout.putConstraint(SpringLayout.NORTH, comboLabel, nextY, SpringLayout.NORTH, comp);
    layout.putConstraint(SpringLayout.WEST, comboBox, constant6, SpringLayout.EAST, comboLabel);

    nextY = layout.getConstraint(SpringLayout.SOUTH, comboBox);
    nextY = Spring.max(nextY, layout.getConstraint(SpringLayout.SOUTH, comboLabel));
    nextY = Spring.sum(nextY, constant6);
    Spring right = layout.getConstraint(SpringLayout.EAST, comboBox);
   
   
    final JLabel descriptionLabel = new JLabel("Description");
    descriptionArea = new JTextArea(4, 35);
    descriptionArea.setWrapStyleWord(true);
    descriptionArea.setLineWrap(true);
    descriptionArea.getDocument().addDocumentListener(this);
    final JScrollPane scroll = new JScrollPane(descriptionArea);
   
    comp.add(descriptionLabel);
    comp.add(scroll);
    layout.putConstraint(SpringLayout.NORTH, descriptionLabel, nextY, SpringLayout.NORTH, comp);
    layout.putConstraint(SpringLayout.WEST, scroll, constant0, SpringLayout.WEST, idText);
    final Spring idTextWidth = layout.getConstraints(idText).getWidth();
    layout.getConstraints(scroll).setWidth(Spring.sum(idTextWidth, idTextWidth));
    layout.putConstraint(SpringLayout.NORTH, scroll, constant6, SpringLayout.SOUTH, descriptionLabel);
   
    right = Spring.max(right, layout.getConstraint(SpringLayout.EAST, scroll));
    nextY = Spring.sum(layout.getConstraint(SpringLayout.SOUTH, scroll), glue12);
View Full Code Here

   
    add(label);
    add(functionBox);
    add(valueBox);
   
    final Spring constant6 = Spring.constant(6);
    layout.putConstraint(SpringLayout.NORTH, label, constant6, SpringLayout.NORTH, this);
    layout.putConstraint(SpringLayout.NORTH, functionBox, constant6, SpringLayout.NORTH, this);
    layout.putConstraint(SpringLayout.NORTH, valueBox, constant6, SpringLayout.NORTH, this);
    Spring bottom = layout.getConstraint(SpringLayout.SOUTH, label);
    bottom = Spring.max(bottom, layout.getConstraint(SpringLayout.SOUTH, functionBox));
    bottom = Spring.max(bottom, layout.getConstraint(SpringLayout.SOUTH, valueBox));
    layout.putConstraint(SpringLayout.SOUTH, this, bottom, SpringLayout.NORTH, this);
   
    layout.putConstraint(SpringLayout.WEST, functionBox, constant6, SpringLayout.EAST, label);
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))
                .getHeight();
        for (int i = 1; i < max; i++) {
            SpringLayout.Constraints cons = layout.getConstraints(parent
                    .getComponent(i));

View Full Code Here

TOP

Related Classes of javax.swing.Spring$HeightSpring

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.