private static void createAndShowGUI() { try { UIManager.setLookAndFeel(new TestLookAndFeel()); JLabel label = new JLabel("Test Label"); label.setSize(SIZE, SIZE); TitledBorder border = new TitledBorder("ABCDEF"); label.setBorder(new TitledBorder(border)); if (useLAF) { UIManager.setLookAndFeel(new NimbusLookAndFeel()); } else { UIManager.getDefaults().put("LabelUI", MetalLabelUI.class.getName()); } SwingUtilities.updateComponentTreeUI(label); paintToImage(label); } catch (Exception e) { throw new RuntimeException(e); } }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component def = table.getDefaultRenderer(String.class).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); c.setBackground(def.getBackground()); //click pe celula pe vertical highlight <=> click pe diagonala principala //System.out.println(VerticalMatrix.getColCounter() + " "+column+" 4value: "+value); if(hasFocus ){ VerticalTextForHorizontalMatrixCellRenderer.setSelectedCellCol(row); VerticalColorCellRenderer.setSelectedCellCol(row); ColorDSMRenderer.simulateClickOn(row,row); } boolean alreadySet=false; //daca celula se expand i jos atunci inseamna ca am parinte cu copii expandati si trebuie scris pe verticala if(row+1 < VerticalMatrix.getRowCounter()){ if(EntityVerticalMatrix.getValueAt(row, column) == EntityVerticalMatrix.getValueAt(row+1, column)){ setUI(new VerticalLabelUI(false)); alreadySet=true; } }else{ if(row-1>=0){ if(EntityVerticalMatrix.getValueAt(row, column) == EntityVerticalMatrix.getValueAt(row-1, column)){ setUI(new VerticalLabelUI(false)); alreadySet=true; } } } if(!alreadySet){ setUI(new MetalLabelUI()); } //get maxDepth int maxTreeDepth = EntityCatalog.getMaxTreeDepth(); int cellDepth = EntityVerticalMatrix.getValueAt(row, column).getTreeDepth(); if(selectedCellRow == row && VerticalMatrix.isAPrintedEntity(row, column)){ //this entity was somehow cliked and needs to be highlighted c.setBackground(Colors.clickedColor); }else{ c.setBackground(Colors.getColor4Depth(cellDepth)); } return c; }