Example usage for java.awt GridLayout getColumns

List of usage examples for java.awt GridLayout getColumns

Introduction

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

Prototype

public int getColumns() 

Source Link

Document

Gets the number of columns 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);// www .j  a  v a  2 s. com

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

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  a  2s . 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;
}