@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setHorizontalAlignment(alignments[column]); return this; } }
private static class HeaderRenderer implements TableCellRenderer { DefaultTableCellRenderer renderer; public HeaderRenderer(JTable table) { renderer = (DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer(); renderer.setHorizontalAlignment(JLabel.CENTER); } @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { return renderer.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, col); } }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (promptArray != null && promptArray.length >= row) { Prompt currentPrompt = promptArray[row]; if (currentPrompt != null) { Recording currentRecording = currentPrompt.getRecording(); if (currentRecording != null) { // Determine cell colour Color backgroundColor = Color.WHITE; // Reset first to white // If amplitude clipping or temporal clipping occurred, then cell background is pink // Note: Red is too harsh (too saturated) if ((currentRecording.isAmpClipped) || (currentRecording.isTempClipped)) { backgroundColor = Color.PINK; } // Otherwise if within the warning threshold, cell background is yellow else if (currentRecording.isAmpWarning) { backgroundColor = Color.YELLOW; } setBackground(backgroundColor); } } } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } }
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { if ((row % 2) == 0) { setBackground(_color); } else { setBackground(Color.white); } FilteredLogTableModel model = (FilteredLogTableModel) table.getModel(); LogRecord record = model.getFilteredRecord(row); setForeground(getLogLevelColor(record.getLevel())); return (super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col)); }
boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); label.setIcon(null);
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int columns) { ActionArgumentValuesTableModel model = (ActionArgumentValuesTableModel)table.getModel(); ActionArgumentValue argumentValue = model.getValues()[row]; ActionArgument argument = model.getValueAt(row); switch (argument.getDatatype().getBuiltin()) { case BOOLEAN: return new BooleanArgumentValueCellComponent(argumentValue, editable); default: String argumentStringValue = null; if (argumentValue != null && argumentValue.toString().length() == 0) { argumentStringValue = "<<NULL>>"; } else if (argumentValue != null && argumentValue.toString().length() > 0) { argumentStringValue = argumentValue.toString(); } else if (argumentValue == null) { argumentStringValue = "Click to edit..."; } return super.getTableCellRendererComponent( table, argumentStringValue, isSelected, hasFocus, row, columns ); } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int columns) { StateVariableValuesTableModel model = (StateVariableValuesTableModel)table.getModel(); StateVariableValue stateVariableValue = model.getValueAt(row); StateVariable stateVariable = stateVariableValue.getStateVariable(); switch (stateVariable.getTypeDetails().getDatatype().getBuiltin()) { case BOOLEAN: return new BooleanArgumentValueCellComponent(stateVariableValue); default: String stringValue; if (stateVariableValue != null && stateVariableValue.toString().length() > 0) { stringValue = stateVariableValue.toString(); } else { stringValue = "<<NULL>>"; } return super.getTableCellRendererComponent( table, stringValue, isSelected, hasFocus, row, columns ); } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Date d = (Date) value; if (d != null) { label.setText(datetimeFormater.format(d)); } else { label.setText(""); } return label; } };
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Date d = (Date) value; label.setText(timeFormater.format(d)); return label; } };
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value == null || ((String) value).isEmpty()) { value = "world"; } label.setToolTipText(CountryUtil.getCountryName((String) value)); label.setIcon(CountryUtil.getCountryFlagIcon((String) value)); label.setText(""); return label; } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); Long ms = (Long) value; if (ms != 0) { Duration dur = timeFormater.approximateDuration(new Date(ms)); label.setText((timeFormater.formatDuration(dur))); } else { label.setText(""); } return label; } };
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel defaultLabel = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); defaultLabel.setHorizontalAlignment(JLabel.CENTER); // colors String val = (String) value; String[] valsList = val.split("/"); if (valsList.length == 2 && !valsList[0].equals(valsList[1])) { // green draw Color defaultBack = defaultLabel.getBackground(); greenLabel.setText(val); greenLabel.setHorizontalAlignment(JLabel.CENTER); greenLabel.setFont(defaultLabel.getFont()); greenLabel.setForeground(Color.black); greenLabel.setOpaque(true); greenLabel.setBackground(new Color(156, 240, 146)); greenLabel.setBorder(new LineBorder(defaultBack, 1)); return greenLabel; } else { // default draw return defaultLabel; } } };
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (!overrideGetFont) { if (deriveNewFont) { Font oldFont = super.getFont(); int fontSize = customFont.getSize(); Font newFont = null; if (castToFloat) { newFont = oldFont.deriveFont((float) fontSize); } else { // Here's the problem I tripped over... newFont = oldFont.deriveFont(fontSize); } setFont(newFont); } else { setFont(customFont); } } return this; } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // get table text cell settings DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class); JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); String skillCode = baseComp.getText(); // apply settings to render panel from parent renderPanel.setOpaque(baseComp.isOpaque()); renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground())); renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground())); renderPanel.setBorder(baseComp.getBorder()); // create each skill symbol as child label renderPanel.removeAll(); renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS)); for (char skillSymbol : skillCode.toCharArray()) { JLabel symbolLabel = new JLabel(); symbolLabel.setBorder(new EmptyBorder(0, 3, 0, 0)); symbolLabel.setIcon(skillIcon); renderPanel.add(symbolLabel); } return renderPanel; } };
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
return super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column);
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { if ((row % 2) == 0) { setBackground(_color); } else { setBackground(Color.white); } FilteredLogTableModel model = (FilteredLogTableModel) table.getModel(); LogRecord record = model.getFilteredRecord(row); setForeground(getLogLevelColor(record.getLevel())); return (super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col)); }
return (JLabel) cellRendererDefault.getTableCellRendererComponent( table, StringUtil.detectUtf8HtmlNoWrap(cellValue), isSelected, hasFocus, row, column );
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); return this; } }