private void recreateLabels( String[] dataNames ) { cCols.removeAll(); cRows.removeAll(); int dims = dataNames.length; cCols.setLayout( createLabelLayout( dims, true ) ); cRows.setLayout( createLabelLayout( dims, false ) ); Insets insetsH = new Insets( 0, 5, 0, 5 ); Insets insetsV = new Insets( 5, 0, 5, 0 ); GridBagConstraintsBuilder builder = new GridBagConstraintsBuilder(); BasicLabelUI verticalUI = new VerticalLabelUI( false ); for ( int i = 0; i < dims; ++i ) { JLabel lblH = new JLabel( dataNames[i] ); lblH.setHorizontalAlignment( SwingConstants.CENTER ); lblH.setVisible( false ); cCols.add( lblH, builder.position( i, 0 ).insets( insetsH ).build() ); JLabel lblV = new JLabel( dataNames[i] ); lblV.setUI( verticalUI ); lblV.setHorizontalAlignment( SwingConstants.CENTER ); lblV.setVisible( false ); cRows.add( lblV, builder.position( 0, i ).insets( insetsV ).build() ); } updateLabelLayout( true ); updateLabelLayout( false ); }
public TagTreeCellRenderer() { setUI(new BasicLabelUI()); setOpaque(false); //setBackground(Color.green); setBackgroundNonSelectionColor(Color.white); //setBackgroundSelectionColor(Color.ORANGE); }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) { if (value instanceof CellValue) { double cellValue = ((CellValue) value).getValue(); this.setBackground(doubleToColor.apply(cellValue)); this.setText(""); this.setToolTipText(format(cellValue)); } else { this.setText(value.toString()); this.setBackground(Color.WHITE); this.setHorizontalAlignment(JLabel.CENTER); this.setToolTipText(""); } if (table.convertRowIndexToModel(row) == 0) { this.setUI(new VerticalLabelUI(false)); this.setHorizontalAlignment(JLabel.LEFT); this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); this.setFont(getHeatmapFont()); } else { this.setUI(new BasicLabelUI()); this.setHorizontalAlignment(JLabel.RIGHT); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); this.setFont(getHeatmapFont()); } return this; }
@Override public void updateUI() { setUI(new BasicLabelUI()); }
public MyTreeCellRenderer() { setUI(new BasicLabelUI()); setOpaque(false); setBackgroundNonSelectionColor(Color.white); }
public DumpTreeCellRenderer() { setUI(new BasicLabelUI()); setOpaque(false); setBackgroundNonSelectionColor(Color.white); }