int hgap = getHgap(); int vgap = getVgap(); int w = target.getWidth();
@ScriptFunction(jsDoc = HGAP_JSDOC) public int getHgap() { return ((FlowLayout) super.getLayout()).getHgap(); }
@Override public Dimension getPreferredSize() { FlowLayout layout = (FlowLayout) getLayout(); Insets insets = getInsets(); // This isn't exact, but hopefully it's close enough int availableWidth = getPanel().getAvailableWidth() - insets.left - insets.right; int height = insets.top + insets.bottom + layout.getVgap(); int rowHeight = 0; int rowWidth = insets.left + layout.getHgap() + insets.right; for (Component c : getComponents()) { Dimension cSize = c.getPreferredSize(); if (rowWidth + cSize.width + layout.getHgap() - 5 > availableWidth && rowWidth > 0) { height += rowHeight + layout.getVgap(); rowHeight = 0; rowWidth = insets.left + layout.getHgap() + insets.right; } rowWidth += cSize.width + layout.getHgap(); rowHeight = Math.max(cSize.height, rowHeight); } height += rowHeight; Dimension prefSize = new Dimension(availableWidth, height); return prefSize; }
public void actionPerformed(ActionEvent e) { FlowLayout layout = (FlowLayout) sister.getLayout(); layout.setHgap(layout.getHgap() * 2);
@Override public Dimension getPreferredSize() { FlowLayout layout = (FlowLayout) getLayout(); Insets insets = getInsets(); // This isn't exact, but hopefully it's close enough int availableWidth = getPanel().getAvailableWidth() - insets.left - insets.right - 10; int height = insets.top + insets.bottom + layout.getVgap(); int rowHeight = 0; int rowWidth = insets.left + layout.getHgap() + insets.right; for (Component c : getComponents()) { Dimension cSize = c.getPreferredSize(); if (rowWidth + cSize.width + layout.getHgap() - 5 > availableWidth && rowWidth > 0) { height += rowHeight + layout.getVgap(); rowHeight = 0; rowWidth = insets.left + layout.getHgap() + insets.right; } rowWidth += cSize.width + layout.getHgap(); rowHeight = Math.max(cSize.height, rowHeight); } height += rowHeight; Dimension prefSize = new Dimension(availableWidth, height); return prefSize; }
public LayoutManager getLayout() { LayoutManager togo = null; if (exemplar instanceof FlowLayout) { FlowLayout exflow = (FlowLayout)exemplar; togo = new FlowLayout(exflow.getAlignment(), exflow.getHgap(), exflow.getVgap()); } else { throw new AssertionException("Unrecognised layout manager " + exemplar); } return togo; } public int getHeight() {
int hgap = getHgap(); int vgap = getVgap(); int w = target.getWidth();
@Override public Dimension getPreferredSize() { Dimension size = getParent().getSize(); FlowLayout layout = (FlowLayout) getLayout(); Insets insets = getInsets(); // This isn't exact, but hopefully it's close enough int x = layout.getHgap() + insets.left; int y = layout.getVgap(); int rowHeight = 0; for (Component c : getComponents()) { Dimension cSize = c.getPreferredSize(); if (x + cSize.width + layout.getHgap() > size.width - insets.right && x > 0) { x = 0; y += rowHeight + layout.getVgap(); rowHeight = 0; } x += cSize.width + layout.getHgap(); rowHeight = Math.max(cSize.height, rowHeight); } y += rowHeight + layout.getVgap(); y += getInsets().top; y += getInsets().bottom; Dimension prefSize = new Dimension(size.width, y); return prefSize; }
private static final int H = 100; private final FlowLayout layout = new FlowLayout(); private final int hGap = layout.getHgap(); private final int vGap = layout.getVgap(); private final Dimension size;