/** * Determines if this component is showing. To be showing, the component * and all of its ancestors must be visible and attached to a display. * * @return * <tt>true</tt> if this component is showing; <tt>false</tt> otherwise. */ public boolean isShowing() { Component component = this; while (component != null && component.isVisible() && !(component instanceof Display)) { component = component.getParent(); } return (component != null && component.isVisible()); }
/** * Determines if this component is showing. To be showing, the component * and all of its ancestors must be visible and attached to a display. * * @return * <tt>true</tt> if this component is showing; <tt>false</tt> otherwise. */ public boolean isShowing() { Component component = this; while (component != null && component.isVisible() && !(component instanceof Display)) { component = component.getParent(); } return (component != null && component.isVisible()); }
@Override public boolean isVisible(int index) { return tabButtonBoxPane.get(index).isVisible(); }
@Override public int getBaseline(int width, int height) { FlowPane flowPane = (FlowPane)getComponent(); int baseline = -1; if (alignToBaseline) { int contentWidth = Math.max(width - (padding.left + padding.right), 0); // Break the components into multiple rows, and calculate the baseline of the // first row int rowWidth = 0; for (int i = 0, n = flowPane.getLength(); i < n; i++) { Component component = flowPane.get(i); if (component.isVisible()) { Dimensions size = component.getPreferredSize(); if (rowWidth + size.width > contentWidth && rowWidth > 0) { // The component is too big to fit in the remaining space, // and it is not the only component in this row; wrap break; } baseline = Math.max(baseline, component.getBaseline(size.width, size.height)); rowWidth += size.width + horizontalSpacing; } } // Include top padding value baseline += padding.top; } return baseline; }
@Override public int getBaseline(int width, int height) { FlowPane flowPane = (FlowPane)getComponent(); int baseline = -1; if (alignToBaseline) { int contentWidth = Math.max(width - (padding.left + padding.right), 0); // Break the components into multiple rows, and calculate the baseline of the // first row int rowWidth = 0; for (int i = 0, n = flowPane.getLength(); i < n; i++) { Component component = flowPane.get(i); if (component.isVisible()) { Dimensions size = component.getPreferredSize(); if (rowWidth + size.width > contentWidth && rowWidth > 0) { // The component is too big to fit in the remaining space, // and it is not the only component in this row; wrap break; } baseline = Math.max(baseline, component.getBaseline(size.width, size.height)); rowWidth += size.width + horizontalSpacing; } } // Include top padding value baseline += padding.top; } return baseline; }
Component component = flowPane.get(i); if (component.isVisible()) { Dimensions size = component.getPreferredSize(); preferredWidth += size.width;
@Override public int getPreferredWidth(int height) { FlowPane flowPane = (FlowPane)getComponent(); int preferredWidth = 0; // Preferred width is the sum of the preferred widths of all components // (height constraint is ignored) int j = 0; for (int i = 0, n = flowPane.getLength(); i < n; i++) { Component component = flowPane.get(i); if (component.isVisible()) { preferredWidth += component.getPreferredWidth(); j++; } } // Include spacing if (j > 1) { preferredWidth += horizontalSpacing * (j - 1); } // Include left and right padding values preferredWidth += padding.left + padding.right; return preferredWidth; }
@Override public int getPreferredWidth(int height) { FlowPane flowPane = (FlowPane)getComponent(); int preferredWidth = 0; // Preferred width is the sum of the preferred widths of all components // (height constraint is ignored) int j = 0; for (int i = 0, n = flowPane.getLength(); i < n; i++) { Component component = flowPane.get(i); if (component.isVisible()) { preferredWidth += component.getPreferredWidth(); j++; } } // Include spacing if (j > 1) { preferredWidth += horizontalSpacing * (j - 1); } // Include left and right padding values preferredWidth += padding.left + padding.right; return preferredWidth; }
public Component getComponentAt(int x, int y) { assertEventDispatchThread(); Component component = null; int i = components.getLength() - 1; while (i >= 0) { component = components.get(i); if (component.isVisible()) { Bounds bounds = component.getBounds(); if (bounds.contains(x, y)) { break; } } i--; } if (i < 0) { component = null; } return component; }
public Component getComponentAt(int x, int y) { assertEventDispatchThread(); Component component = null; int i = components.getLength() - 1; while (i >= 0) { component = components.get(i); if (component.isVisible()) { Bounds bounds = component.getBounds(); if (bounds.contains(x, y)) { break; } } i--; } if (i < 0) { component = null; } return component; }
if (!component.isVisible()) { throw new IllegalArgumentException("component is not visible.");
@Override public int getPreferredHeight(int width) { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); Metadata metadata = new Metadata(); int cellWidthLocal = getCellWidth(width, metadata); int preferredCellHeight = 0; for (int i = 0; i < rowCount; i++) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { preferredCellHeight = Math.max(preferredCellHeight, component.getPreferredHeight(cellWidthLocal)); } } } // The preferred height of the grid pane is the sum of the row // heights, plus padding and spacing int preferredHeight = padding.top + padding.bottom + metadata.visibleRowCount * preferredCellHeight; if (metadata.visibleRowCount > 1) { preferredHeight += (metadata.visibleRowCount - 1) * verticalSpacing; } return preferredHeight; }
@Override public int getPreferredWidth(int height) { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); Metadata metadata = new Metadata(); int cellHeight = getCellHeight(height, metadata); int preferredCellWidth = 0; for (int i = 0; i < rowCount; i++) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { preferredCellWidth = Math.max(preferredCellWidth, component.getPreferredWidth(cellHeight)); } } } // The preferred width of the grid pane is the sum of the column // widths, plus padding and spacing int preferredWidth = padding.left + padding.right + metadata.visibleColumnCount * preferredCellWidth; if (metadata.visibleColumnCount > 1) { preferredWidth += (metadata.visibleColumnCount - 1) * horizontalSpacing; } return preferredWidth; }
@Override public int getPreferredWidth(int height) { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); Metadata metadata = new Metadata(); int cellHeightLocal = getCellHeight(height, metadata); int preferredCellWidth = 0; for (int i = 0; i < rowCount; i++) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { preferredCellWidth = Math.max(preferredCellWidth, component.getPreferredWidth(cellHeightLocal)); } } } // The preferred width of the grid pane is the sum of the column // widths, plus padding and spacing int preferredWidth = padding.left + padding.right + metadata.visibleColumnCount * preferredCellWidth; if (metadata.visibleColumnCount > 1) { preferredWidth += (metadata.visibleColumnCount - 1) * horizontalSpacing; } return preferredWidth; }
public Metadata() { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); visibleRows = new boolean[rowCount]; visibleColumns = new boolean[columnCount]; int visibleRowCountLocal = 0; int visibleColumnCountLocal = 0; for (int i = 0; i < rowCount; i++) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { if (!visibleRows[i]) { visibleRowCountLocal++; visibleRows[i] = true; } if (!visibleColumns[j]) { visibleColumnCountLocal++; visibleColumns[j] = true; } } } } this.visibleRowCount = visibleRowCountLocal; this.visibleColumnCount = visibleColumnCountLocal; }
public Metadata() { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); visibleRows = new boolean[rowCount]; visibleColumns = new boolean[columnCount]; int visibleRowCount = 0; int visibleColumnCount = 0; for (int i = 0; i < rowCount; i++) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { if (!visibleRows[i]) { visibleRowCount++; visibleRows[i] = true; } if (!visibleColumns[j]) { visibleColumnCount++; visibleColumns[j] = true; } } } } this.visibleRowCount = visibleRowCount; this.visibleColumnCount = visibleColumnCount; }
&& component != null && !(component instanceof Window)) { focusable = component.isVisible() && isEnabled();
@Override public int getBaseline(int width, int height) { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); Metadata metadata = new Metadata(); int cellWidthLocal = getCellWidth(width, metadata); int cellHeightLocal = getCellHeight(height, metadata); // Return the first available baseline by traversing cells top left to bottom right int baseline = -1; int rowY = padding.top; for (int i = 0; i < rowCount && baseline == -1; i++) { if (metadata.isRowVisible(i)) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { baseline = component.getBaseline(cellWidthLocal, cellHeightLocal); if (baseline != -1) { baseline += rowY; } } } rowY += (cellHeightLocal + verticalSpacing); } } return baseline; }
@Override public int getBaseline(int width, int height) { GridPane gridPane = (GridPane)getComponent(); GridPane.RowSequence rows = gridPane.getRows(); int columnCount = gridPane.getColumnCount(); int rowCount = rows.getLength(); Metadata metadata = new Metadata(); int cellWidth = getCellWidth(width, metadata); int cellHeight = getCellHeight(height, metadata); // Return the first available baseline by traversing cells top left to bottom right int baseline = -1; int rowY = padding.top; for (int i = 0; i < rowCount && baseline == -1; i++) { if (metadata.isRowVisible(i)) { GridPane.Row row = rows.get(i); for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) { Component component = row.get(j); if (component != null && component.isVisible()) { baseline = component.getBaseline(cellWidth, cellHeight); if (baseline != -1) { baseline += rowY; } } } rowY += (cellHeight + verticalSpacing); } } return baseline; }
&& component.isVisible()) { component.setLocation(componentX, componentY); component.setSize(cellWidth, cellHeight);