public MeasurementPanel (final @Nonnull String text) { assert EventQueue.isDispatchThread(); setBackground(Color.WHITE); setOpaque(true); lbUpper.setHorizontalAlignment(SwingConstants.CENTER); lbLower.setHorizontalAlignment(SwingConstants.CENTER); lbUpper.setVerticalAlignment(SwingConstants.BOTTOM); lbLower.setVerticalAlignment(SwingConstants.TOP); addComponentListener(componentListener); final String[] split = text.split("\n"); final GridLayout gridLayout = new GridLayout(split.length, 1); setLayout(gridLayout); lbUpper.setText(split[0]); add(lbUpper); if (split.length > 1) { add(lbLower); lbLower.setText(split[1]); } else { lbUpper.setVerticalAlignment(SwingConstants.CENTER); } }
public void renderMeasurements (final @Nonnull String[][] measurements) { assert EventQueue.isDispatchThread(); innerPanel.removeAll(); gridLayout.setColumns(measurements[0].length); gridLayout.setRows(measurements.length); gridLayout.setHgap(1); gridLayout.setVgap(1); for (int row = 0; row < gridLayout.getRows(); row++) { for (int column = 0; column < gridLayout.getColumns(); column++) { innerPanel.add(new MeasurementPanel(measurements[row][column])); } } innerPanel.validate(); } }
public MeasurementPanel (final @Nonnull String text) { assert EventQueue.isDispatchThread(); setBackground(Color.WHITE); setOpaque(true); lbUpper.setHorizontalAlignment(SwingConstants.CENTER); lbLower.setHorizontalAlignment(SwingConstants.CENTER); lbUpper.setVerticalAlignment(SwingConstants.BOTTOM); lbLower.setVerticalAlignment(SwingConstants.TOP); addComponentListener(componentListener); final String[] split = text.split("\n"); final GridLayout gridLayout = new GridLayout(split.length, 1); setLayout(gridLayout); lbUpper.setText(split[0]); add(lbUpper); if (split.length > 1) { add(lbLower); lbLower.setText(split[1]); } else { lbUpper.setVerticalAlignment(SwingConstants.CENTER); } }
public void renderMeasurements (final @Nonnull String[][] measurements) { assert EventQueue.isDispatchThread(); innerPanel.removeAll(); gridLayout.setColumns(measurements[0].length); gridLayout.setRows(measurements.length); gridLayout.setHgap(1); gridLayout.setVgap(1); for (int row = 0; row < gridLayout.getRows(); row++) { for (int column = 0; column < gridLayout.getColumns(); column++) { innerPanel.add(new MeasurementPanel(measurements[row][column])); } } innerPanel.validate(); } }