Example usage for java.awt GridLayout getRows

List of usage examples for java.awt GridLayout getRows

Introduction

In this page you can find the example usage for java.awt GridLayout getRows.

Prototype

public int getRows() 

Source Link

Document

Gets the number of rows in this layout.

Usage

From source file:Main.java

public Main() {

    add(new JButton("w w w.j a v a 2 s . c o m"));
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    setLayout(gridLayout);//from  w  ww .j a va  2 s  .c  o  m

    System.out.println(gridLayout.getRows());
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java

/**
 * @param value/*from ww w  .  ja v  a2 s  .  c  o m*/
 *            true if the button should be shown
 */
public void setShowTestButton(boolean value) {
    _testButton.setVisible(value);
    if (value) {
        final GridLayout layout = (GridLayout) _buttonPanel.getLayout();
        layout.setRows(layout.getRows() + 1);
        _buttonPanel.add(_testButton);
    } else {
        final GridLayout layout = (GridLayout) _buttonPanel.getLayout();
        layout.setRows(layout.getRows() - 1);
        _buttonPanel.remove(_testButton);

    }
}

From source file:com.diversityarrays.kdxplore.field.PlotIdTrialLayoutPane.java

@Override
public JComponent getFieldLayoutPane(FieldLayout<Integer>[] returnLayout) {
    int runLength = runLengthModel.getNumber().intValue();
    if (runLength <= 0) {
        fieldLayoutRunLengthLE_0.setText("RunLength=" + runLength);
        return fieldLayoutRunLengthLE_0;
    }//w  w  w .j  av a2 s . c  o  m

    int firstPlotId = plotIdModel.getNumber().intValue();

    PlotIdFieldLayoutProcessor layoutProcessor = new PlotIdFieldLayoutProcessor();
    FieldLayout<Integer> fieldLayout = layoutProcessor.layoutField(plotIdentSummary, odtPanel.getOrigin(),
            firstPlotId, odtPanel.getOrientation(), runLength, odtPanel.getTraversal());

    if (returnLayout != null && returnLayout.length > 0) {
        returnLayout[0] = fieldLayout;
    }

    Border insideBorder = new LineBorder(Color.BLACK);
    Border outsideBorder = new EmptyBorder(1, 1, 1, 1);
    Border border = new CompoundBorder(outsideBorder, insideBorder);

    GridLayout gridLayout = new GridLayout(fieldLayout.ysize, fieldLayout.xsize);
    if (DEBUG) {
        System.out.println(
                "GridLayout( rows=" + gridLayout.getRows() + " , cols=" + gridLayout.getColumns() + ")");
    }

    fieldLayoutRunLengthGT_0.setLayout(gridLayout);

    fieldLayoutRunLengthGT_0.removeAll();
    for (int y = 0; y < fieldLayout.ysize; ++y) {
        for (int x = 0; x < fieldLayout.xsize; ++x) {
            Integer plotId = fieldLayout.cells[y][x];

            String label_s;
            if (plotId == null) {
                label_s = ".";
            } else {
                PlotName plotName = plotNameByPlotId.get(plotId);
                if (plotName == null) {
                    label_s = "-";
                } else {
                    //s = "P_" + plotId + ":" + x + "," + y;
                    StringBuilder sb = new StringBuilder("P_");
                    sb.append(plotName.getPlotId());
                    Integer xx = plotName.getX();
                    Integer yy = plotName.getY();

                    if (xx != null || yy != null) {
                        sb.append(": ");
                        if (xx != null) {
                            sb.append(xx);
                        }
                        sb.append(",");
                        if (yy != null) {
                            sb.append(yy);
                        }
                    }
                    label_s = sb.toString();
                }
            }
            JLabel label = new JLabel("<HTML><BR>" + label_s + "<BR>&nbsp;");
            label.setHorizontalAlignment(SwingConstants.CENTER);
            label.setBorder(border);
            fieldLayoutRunLengthGT_0.add(label);
        }
    }

    return fieldLayoutRunLengthGT_0;
}