Package javax.swing

Examples of javax.swing.SpringLayout$SpringProxy


    private final SpinnerNumberModel meanNumberModel = new SpinnerNumberModel(0, -1000, 1000, 1);
    private final SpinnerNumberModel deviationNumberModel = new SpinnerNumberModel(1d, 0.01d, 1000d, 1d);

    public GaussianParametersPanel()
    {
        JPanel wrapper = new JPanel(new SpringLayout());
        wrapper.add(new JLabel("Mean: "));
        wrapper.add(new JSpinner(meanNumberModel));
        wrapper.add(new JLabel("Standard Deviation: "));
        wrapper.add(new JSpinner(deviationNumberModel));
        SpringUtilities.makeCompactGrid(wrapper, 4, 1, 6, 6, 6, 6);
View Full Code Here


{
    private final SpinnerNumberModel rateNumberModel = new SpinnerNumberModel(2.0d, 0.1d, 100.0d, 0.1d);

    public ExponentialParametersPanel()
    {
        JPanel wrapper = new JPanel(new SpringLayout());
        wrapper.add(new JLabel("Rate: "));
        wrapper.add(new JSpinner(rateNumberModel));
        SpringUtilities.makeCompactGrid(wrapper, 2, 1, 6, 6, 6, 6);
        add(wrapper, BorderLayout.NORTH);
    }
View Full Code Here

{
    private final SpinnerNumberModel meanNumberModel = new SpinnerNumberModel(5.0d, 0.1d, 100.0d, 0.1d);

    public PoissonParametersPanel()
    {
        JPanel wrapper = new JPanel(new SpringLayout());
        wrapper.add(new JLabel("Mean: "));
        wrapper.add(new JSpinner(meanNumberModel));
        SpringUtilities.makeCompactGrid(wrapper, 2, 1, 6, 6, 6, 6);
        add(wrapper, BorderLayout.NORTH);
    }
View Full Code Here

    }


    public RNGPanel()
    {
        super(new SpringLayout());
        for (String name : rngs.keySet())
        {
            rngCombo.addItem(name);
        }
        rngCombo.setSelectedIndex(3); // Mersenne Twister.
View Full Code Here

    private final SpinnerNumberModel trialsNumberModel = new SpinnerNumberModel(50, 1, 100, 1);
    private final SpinnerNumberModel probabilityNumberModel = new SpinnerNumberModel(0.5d, 0.0d, 1.0d, 0.01d);

    public BinomialParametersPanel()
    {
        JPanel wrapper = new JPanel(new SpringLayout());
        wrapper.add(new JLabel("No. Trials: "));
        wrapper.add(new JSpinner(trialsNumberModel));
        wrapper.add(new JLabel("Probability: "));
        wrapper.add(new JSpinner(probabilityNumberModel));
        SpringUtilities.makeCompactGrid(wrapper, 4, 1, 6, 6, 6, 6);
View Full Code Here

    private final SpinnerNumberModel minNumberModel = new SpinnerNumberModel(1, 0, 100, 1);
    private final SpinnerNumberModel maxNumberModel = new SpinnerNumberModel(10, 1, 100, 1);

    public UniformParametersPanel()
    {
        JPanel wrapper = new JPanel(new SpringLayout());
        wrapper.add(new JLabel("Minimum: "));
        wrapper.add(new JSpinner(minNumberModel));
        wrapper.add(new JLabel("Maximum: "));
        wrapper.add(new JSpinner(maxNumberModel));
        SpringUtilities.makeCompactGrid(wrapper, 4, 1, 6, 6, 6, 6);
View Full Code Here

  private static void setUpTopGameComponent(CivQuest civQuest, JSplitPane splitPane,
                        GameStatusComponent gameStatusComp) {
     JComponent topComponent = new JPanel();

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

     topComponent.add(splitPane);
    gameStatusComp.setPreferredSize(new Dimension(3000, 20));
    topComponent.add(gameStatusComp);
   

       layout.putConstraint(SpringLayout.WEST, splitPane, 0,
                  SpringLayout.WEST, topComponent);
       layout.putConstraint(SpringLayout.EAST, topComponent, 0,
                  SpringLayout.EAST, splitPane);
       layout.putConstraint(SpringLayout.NORTH, splitPane, 0,
                  SpringLayout.NORTH, topComponent);
      layout.putConstraint(SpringLayout.SOUTH, topComponent, 20,
                 SpringLayout.SOUTH, splitPane);

      layout.putConstraint(SpringLayout.NORTH, gameStatusComp, 0,
                 SpringLayout.SOUTH, splitPane);   

   
    civQuest.setMainComponent(topComponent);
  }
View Full Code Here

     *            x padding between cells
     * @param yPad
     *            y padding between cells
     */
    public static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
        SpringLayout layout;
        try {
            layout = (SpringLayout) parent.getLayout();
        } catch (ClassCastException exc) {
            if (MainFrame.GUI2_DEBUG) {
                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());
        }

        // Apply the new width/height Spring. This forces all the
        // components to have the same size.
        for (int i = 0; i < max; i++) {
            SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

            cons.setWidth(maxWidthSpring);
            cons.setHeight(maxHeightSpring);
        }

        // Then adjust the x/y constraints of all the cells so that they
        // are aligned in a grid.
        SpringLayout.Constraints lastCons = null;
        SpringLayout.Constraints lastRowCons = null;
        for (int i = 0; i < max; i++) {
            SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
            if (i % cols == 0) { // start of new row
                lastRowCons = lastCons;
                cons.setX(initialXSpring);
            } else { // x position depends on previous component
                assert lastCons != null;
                cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring));
            }

            if (i / cols == 0) { // first row
                cons.setY(initialYSpring);
            } else { // y position depends on previous row
                assert lastRowCons != null;
                cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring));
            }
            lastCons = cons;
        }

        assert lastCons != null;
        // Set the parent's size.
        SpringLayout.Constraints pCons = layout.getConstraints(parent);
        pCons.setConstraint(SpringLayout.SOUTH, Spring.sum(Spring.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
        pCons.setConstraint(SpringLayout.EAST, Spring.sum(Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)));
    }
View Full Code Here

        pCons.setConstraint(SpringLayout.EAST, Spring.sum(Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)));
    }

    /* Used by makeCompactGrid. */
    private static SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) {
        SpringLayout layout = (SpringLayout) parent.getLayout();
        Component c = parent.getComponent(row * cols + col);
        return layout.getConstraints(c);
    }
View Full Code Here

     *            x padding between cells
     * @param yPad
     *            y padding between cells
     */
    public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
        SpringLayout layout;
        try {
            layout = (SpringLayout) parent.getLayout();
        } catch (ClassCastException exc) {
            if (MainFrame.GUI2_DEBUG) {
                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);
                constraints.setY(y);
                constraints.setHeight(height);
            }
            y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
        }

        // Set the parent's size.
        SpringLayout.Constraints pCons = layout.getConstraints(parent);
        pCons.setConstraint(SpringLayout.SOUTH, y);
        pCons.setConstraint(SpringLayout.EAST, x);
    }
View Full Code Here

TOP

Related Classes of javax.swing.SpringLayout$SpringProxy

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.