List of usage examples for java.awt Component setBackground
public void setBackground(Color c)
From source file:lu.lippmann.cdb.graph.GraphViewImpl.java
/** * {@inheritDoc}//w w w. j a va2s . c o m */ @Override public void addMetaInfoComponent(final Component c) { c.setBackground(this.getBackground()); //same bg metaInfosPanel.add(c); validate(); repaint(); }
From source file:au.com.jwatmuff.eventmanager.gui.scoreboard.ScoreboardDisplayPanel.java
void updateColors() { ScoringColors colors = model.getColors(); switch (model.getHolddownPlayer()) { case 0:/* w ww. j a v a 2 s . c om*/ holddownTimer.setBackground(colors.getColor(Area.PLAYER1_BACKGROUND)); holddownTimer.setForeground(colors.getColor(Area.PLAYER1_FOREGROUND)); break; case 1: holddownTimer.setBackground(colors.getColor(Area.PLAYER2_BACKGROUND)); holddownTimer.setForeground(colors.getColor(Area.PLAYER2_FOREGROUND)); break; default: holddownTimer.setBackground(colors.getColor(Area.IDLE_BACKGROUND)); holddownTimer.setForeground(colors.getColor(Area.IDLE_FOREGROUND)); } for (ScalableLabel label : new ScalableLabel[] { timer, goldenScore, goldenScoreApprove, vs, division, vsDivision, pendingDivision }) { label.setForeground(Color.BLACK); label.setBackground(Color.WHITE); } for (ScalableLabel[] labels : shido) { for (ScalableLabel label : labels) { label.setForeground(Color.BLACK); label.setBackground(Color.WHITE); } } Color mainBg; Color mainFg; switch (model.getMode()) { case FIGHTING: if (!model.isHolddownActivated()) { mainBg = colors.getColor(Area.FIGHTING_BACKGROUND); mainFg = colors.getColor(Area.FIGHTING_FOREGROUND); } else { mainBg = colors.getColor(Area.HOLDDOWN_BACKGROUND); mainFg = colors.getColor(Area.HOLDDOWN_FOREGROUND); } break; default: mainBg = colors.getColor(Area.IDLE_BACKGROUND); mainFg = colors.getColor(Area.IDLE_FOREGROUND); break; } setBackground(mainBg); setForeground(mainFg); for (Component c : new Component[] { noFightLayer, pendingFightLayer, vsLayer, pendingPlayer[0], pendingPlayer[1], pendingFightTimer[0], pendingFightTimer[1] }) { c.setBackground(mainBg); c.setForeground(mainFg); } for (int i = 0; i < 2; i++) { int playerPnt = swapPlayers ? (1 - i) : i; Color fg = colors.getColor((playerPnt == 0) ? Area.PLAYER1_FOREGROUND : Area.PLAYER2_FOREGROUND); Color bg = colors.getColor((playerPnt == 0) ? Area.PLAYER1_BACKGROUND : Area.PLAYER2_BACKGROUND); for (Component c : Arrays.asList(player[i], team[i], playerBackground[i], pendingFightTimer[i], pendingPlayer[i], vsPlayer[playerPnt])) { c.setForeground(fg); c.setBackground(bg); } for (int j = 0; j < 2; j++) { score[i][j].setForeground(fg); score[i][j].setBackground(bg); pendingScores[i][j].setForeground(fg); pendingScores[i][j].setBackground(bg); } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { scoreLabels[i][j].setBackground(mainBg); scoreLabels[i][j].setForeground(mainFg); scoreLabels[i][j].setBorder(new EmptyBorder(0, 0, 0, 0)); } } // Special colours for IJF if (this.scoreboardLayout instanceof IJFScoreboardLayout) { clearBackground(timer); timerBackground.setBackground(Color.BLACK); timer.setForeground(model.getMode() == Mode.FIGHTING ? Color.GREEN : Color.RED); for (ScalableLabel[] ls : score) { for (ScalableLabel l : ls) { clearBackground(l); } } for (int i = 0; i < 2; i++) { clearBackground(player[i], team[i]); } } }
From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java
public static void setBackgroundColor(Component cellRendererComponent, JTable tbl, Object oValue, boolean bSelected, boolean bHasFocus, int iRow, int iColumn) { cellRendererComponent.setBackground(bSelected ? tbl.getSelectionBackground() : iRow % 2 == 0 ? tbl.getBackground() : NuclosThemeSettings.BACKGROUND_PANEL); cellRendererComponent.setForeground(bSelected ? tbl.getSelectionForeground() : tbl.getForeground()); final TableModel tm; final int adjustColIndex; if (tbl instanceof FixedColumnRowHeader.HeaderTable && ((FixedColumnRowHeader.HeaderTable) tbl).getExternalTable() != null) { tm = ((FixedColumnRowHeader.HeaderTable) tbl).getExternalTable().getModel(); adjustColIndex = FixedRowIndicatorTableModel.ROWMARKERCOLUMN_COUNT; } else {//from w ww .jav a2 s . c om tm = tbl.getModel(); adjustColIndex = 0; } // check whether the data of the component is readable for current user, by asking the security agent of the actual field if (tm instanceof SortableCollectableTableModel<?>) { final SortableCollectableTableModel<Collectable> tblModel = (SortableCollectableTableModel<Collectable>) tm; if (tblModel.getRowCount() > iRow) { final Collectable clct = tblModel.getCollectable(iRow); final Integer iTColumn = tbl.getColumnModel().getColumn(iColumn).getModelIndex() - adjustColIndex; final CollectableEntityField clctef = tblModel.getCollectableEntityField(iTColumn); if (clctef == null) { throw new NullPointerException("getTableCellRendererComponent failed to find field: " + clct + " tm index " + iTColumn); } boolean isEnabled = true; if (!clctef.isNullable() && isNull(oValue)) { cellRendererComponent.setBackground(getMandatoryColor()); cellRendererComponent.setForeground(tbl.getForeground()); } else { // if (clct.getId() == null) { // cellRendererComponent.setBackground(tbl.getBackground()); // cellRendererComponent.setForeground(tbl.getForeground()); // } else { if (tbl instanceof SubForm.SubFormTable) { SubFormTable subformtable = (SubForm.SubFormTable) tbl; Column subformcolumn = subformtable.getSubForm().getColumn(clctef.getName()); if (subformcolumn != null && !subformcolumn.isEnabled()) { isEnabled = false; if (bSelected) { cellRendererComponent .setBackground(NuclosThemeSettings.BACKGROUND_INACTIVESELECTEDCOLUMN); } else { cellRendererComponent.setBackground(NuclosThemeSettings.BACKGROUND_INACTIVECOLUMN); } } } // } try { EntityMetaDataVO meta = MetaDataClientProvider.getInstance() .getEntity(clctef.getEntityName()); if (meta.getRowColorScript() != null && !bSelected) { AbstractCollectableComponent.setBackground(cellRendererComponent, meta.getRowColorScript(), clct, meta, isEnabled); } } catch (CommonFatalException ex) { LOG.warn(ex); } } } } if (tbl instanceof TableRowMouseOverSupport) { TableRowMouseOverSupport trmos = (TableRowMouseOverSupport) tbl; if (trmos.isMouseOverRow(iRow)) { final Color bgColor = LangUtils.defaultIfNull(cellRendererComponent.getBackground(), Color.WHITE); cellRendererComponent .setBackground(new Color(Math.max(0, bgColor.getRed() - (bgColor.getRed() * 8 / 100)), Math.max(0, bgColor.getGreen() - (bgColor.getGreen() * 8 / 100)), Math.max(0, bgColor.getBlue() - (bgColor.getBlue() * 8 / 100)))); // cellRendererComponent.setBackground(UIManager.getColor("Table.selectionBackground")); } } }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.GUIComponents.FLIMPanel.java
private void setControlDefaults() { String[] colName = { "Delays (ps)" }; int max = 16666; try {//from w ww.j a va 2 s. c o m max = Integer.parseInt(core_.getProperty("Laser", "Frequency")); } catch (Exception e) { } tableModel_ = new DelayTableModel(colName, (sap_.getDelaysArray()).get(0), 0, max, 25); tableModel_.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { sap_.setDelaysArray(0, tableModel_.getData()); fm_.setGatingData((sap_.getDelaysArray()).get(0)); var_.delays = tableModel_.getData(); } }); delayTable_ = new JTable() { @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component comp = super.prepareRenderer(renderer, row, column); int modelRow = convertRowIndexToModel(row); int modelColumn = convertColumnIndexToModel(column); if (modelColumn != 0 && modelRow != 0) { comp.setBackground(Color.GREEN); } return comp; } }; delayTable_.setModel(tableModel_); delayTable_.setSurrendersFocusOnKeystroke(true); delayTable_.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); JScrollPane scroller = new javax.swing.JScrollPane(delayTable_); delayTable_.setPreferredScrollableViewportSize(new java.awt.Dimension(60, 100)); delayTablePanel.setLayout(new BorderLayout()); delayTablePanel.add(scroller, BorderLayout.CENTER); final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete delay"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = delayTable_.getSelectedRow(); tableModel_.removeRow(r); } }); JMenuItem addItem = new JMenuItem("Add delay"); addItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = delayTable_.getSelectedRow(); tableModel_.insertRow(r + 1, 0); } }); popupMenu.add(addItem); popupMenu.add(deleteItem); delayTable_.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { // System.out.println("pressed"); } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { JTable source = (JTable) e.getSource(); int row = source.rowAtPoint(e.getPoint()); int column = source.columnAtPoint(e.getPoint()); if (!source.isRowSelected(row)) source.changeSelection(row, column, false, false); popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); // Set up slider controls mcpSlider_ = new SliderControl("MCP voltage (V)", 300, 850, 750); mcpVoltagePanel.setLayout(new BorderLayout()); mcpVoltagePanel.add(mcpSlider_, BorderLayout.SOUTH); mcpSlider_.addPropertyChangeListener(new java.beans.PropertyChangeListener() { @Override public void propertyChange(java.beans.PropertyChangeEvent evt) { mcpSliderPropertyChange(evt); } }); gatewidthSlider_ = new SliderControl("Gate width (ps)", 200, 7000, 3000); gatewidthPanel.setLayout(new BorderLayout()); gatewidthPanel.add(gatewidthSlider_, BorderLayout.SOUTH); gatewidthSlider_.addPropertyChangeListener(new java.beans.PropertyChangeListener() { @Override public void propertyChange(java.beans.PropertyChangeEvent evt) { gatewidthSliderPropertyChange(evt); } }); HRIControlsPanel.revalidate(); HRIControlsPanel.repaint(); slowDelaySlider_ = new SliderControl("Current delay setting (ps)", 0, 20000, 0); slowCurrentDelayPanel.setLayout(new BorderLayout()); slowCurrentDelayPanel.add(slowDelaySlider_, BorderLayout.SOUTH); slowDelaySlider_.addPropertyChangeListener(new java.beans.PropertyChangeListener() { @Override public void propertyChange(java.beans.PropertyChangeEvent evt) { slowDelaySlider_.setValue(tableModel_.validateData(slowDelaySlider_.getValue().intValue())); slowDelaySliderPropertyChange(evt); } }); fastDelaySlider_ = new SliderControl("Current delay setting (ps)", 0, 20000, 0); fastCurrentDelayPanel.setLayout(new BorderLayout()); fastCurrentDelayPanel.add(fastDelaySlider_, BorderLayout.SOUTH); fastDelaySlider_.addPropertyChangeListener(new java.beans.PropertyChangeListener() { @Override public void propertyChange(java.beans.PropertyChangeEvent evt) { fastDelaySlider_.setValue(tableModel_.validateData(fastDelaySlider_.getValue().intValue())); fastDelaySliderPropertyChange(evt); } }); delayBoxTabbedPane.revalidate(); delayBoxTabbedPane.repaint(); fm_ = new FindMaxpoint(); maxpointGraphPanel.setLayout(new BorderLayout()); chartPanel_ = new ChartPanel(fm_.getChart()); maxpointGraphPanel.add(chartPanel_, BorderLayout.NORTH); // for some reason maxpointGraphPanel's height and width are returned 0 // so hardcode for now... chartPanel_.setMaximumDrawWidth(500); chartPanel_.setMaximumDrawHeight(200); chartPanel_.setPreferredSize(new Dimension(500, 200)); // Set values for other controls based on underlying data to ensure // that all controls are in a consistent state. scanDelCheck.setSelected(sap_.getUseScanFLIM()); }
From source file:plugins.ImageRectificationPanel.java
public final void createGui() { this.removeAll(); if (imageGCPsXCoords == null) { return;/*from w w w . jav a 2s .c o m*/ } int i; int newN = 0; for (i = 0; i < imageGCPsXCoords.length; i++) { if (useGCP[i]) { newN++; } } double[] X1 = new double[newN]; double[] Y1 = new double[newN]; double[] X2 = new double[newN]; double[] Y2 = new double[newN]; int j = 0; for (i = 0; i < imageGCPsXCoords.length; i++) { if (useGCP[i]) { X1[j] = imageGCPsXCoords[i]; Y1[j] = imageGCPsYCoords[i]; X2[j] = mapGCPsXCoords[i]; Y2[j] = mapGCPsYCoords[i]; j++; } } calculateEquations(X1, Y1, X2, Y2); // gui stuff this.setLayout(new BorderLayout()); DecimalFormat df = new DecimalFormat("###,###,##0.000"); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); JButton btnOK = createButton(bundle.getString("OK"), bundle.getString("OK"), "ok"); JButton btnExit = createButton(bundle.getString("Close"), bundle.getString("Close"), "close"); //JButton btnRefresh = createButton("Cancel", "Cancel"); buttonPane.add(Box.createHorizontalStrut(10)); buttonPane.add(btnOK); buttonPane.add(Box.createHorizontalStrut(5)); //buttonPane.add(btnRefresh); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(btnExit); buttonPane.add(Box.createHorizontalGlue()); progressBar = new JProgressBar(0, 100); buttonPane.add(progressBar); buttonPane.add(Box.createHorizontalStrut(5)); cancel = new JLabel(bundle.getString("Cancel")); cancel.setForeground(Color.BLUE.darker()); cancel.addMouseListener(this); buttonPane.add(cancel); buttonPane.add(Box.createHorizontalStrut(10)); this.add(buttonPane, BorderLayout.SOUTH); Box mainBox = Box.createVerticalBox(); mainBox.add(Box.createVerticalStrut(10)); Box box1 = Box.createHorizontalBox(); box1.add(Box.createHorizontalStrut(10)); box1.add(new JLabel(bundle.getString("PolynomialOrder") + ": ")); SpinnerModel model = new SpinnerNumberModel(polyOrder, //initial value 1, //min 5, //max 1); //step polyOrderSpinner = new JSpinner(model); polyOrderSpinner.setPreferredSize(new Dimension(15, polyOrderSpinner.getPreferredSize().height)); polyOrderSpinner.addChangeListener(this); JSpinner.DefaultEditor editor = (JSpinner.DefaultEditor) polyOrderSpinner.getEditor(); editor.getTextField().setEnabled(true); editor.getTextField().setEditable(false); box1.add(polyOrderSpinner); box1.add(Box.createHorizontalGlue()); JLabel label = new JLabel("RMSE: " + df.format(overallRMSE)); box1.add(label); box1.add(Box.createHorizontalStrut(10)); mainBox.add(box1); mainBox.add(Box.createVerticalStrut(10)); // Create columns names int numPoints = imageGCPsXCoords.length; Object dataValues[][] = new Object[numPoints][7]; j = 0; for (i = 0; i < numPoints; i++) { dataValues[i][0] = i + 1; dataValues[i][1] = df.format(imageGCPsXCoords[i]); dataValues[i][2] = df.format(imageGCPsYCoords[i]); dataValues[i][3] = df.format(mapGCPsXCoords[i]); dataValues[i][4] = df.format(mapGCPsYCoords[i]); if (useGCP[i]) { dataValues[i][5] = df.format(residualsXY[j]); j++; } else { dataValues[i][5] = null; } dataValues[i][6] = useGCP[i]; } String columnNames[] = { "GCP", bundle.getString("Image") + " X", bundle.getString("Image") + " Y", bundle.getString("Map") + " X", bundle.getString("Map") + " Y", messages.getString("Error"), "Use" }; DefaultTableModel tableModel = new DefaultTableModel(dataValues, columnNames); dataTable = new JTable(tableModel) { private static final long serialVersionUID = 1L; @Override public Class getColumnClass(int column) { switch (column) { case 0: return Integer.class; case 1: return String.class; //Double.class; case 2: return String.class; //Double.class; case 3: return String.class; //Double.class; case 4: return String.class; //Double.class; case 5: return String.class; //Double.class; case 6: return Boolean.class; default: return String.class; //Double.class; } } @Override public Component prepareRenderer(TableCellRenderer renderer, int index_row, int index_col) { Component comp = super.prepareRenderer(renderer, index_row, index_col); //even index, selected or not selected if (index_row % 2 == 0) { comp.setBackground(Color.WHITE); comp.setForeground(Color.BLACK); } else { comp.setBackground(new Color(225, 245, 255)); //new Color(210, 230, 255)); comp.setForeground(Color.BLACK); } if (isCellSelected(index_row, index_col)) { comp.setForeground(Color.RED); } return comp; } }; tableModel.addTableModelListener(this); TableCellRenderer rend = dataTable.getTableHeader().getDefaultRenderer(); TableColumnModel tcm = dataTable.getColumnModel(); //for (int j = 0; j < tcm.getColumnCount(); j += 1) { TableColumn tc = tcm.getColumn(0); TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null if (rendCol == null) { rendCol = rend; } Component c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 0); tc.setPreferredWidth(35); tc = tcm.getColumn(6); rendCol = tc.getHeaderRenderer(); // likely null if (rendCol == null) { rendCol = rend; } c = rendCol.getTableCellRendererComponent(dataTable, tc.getHeaderValue(), false, false, 0, 6); tc.setPreferredWidth(35); JScrollPane scroll = new JScrollPane(dataTable); mainBox.add(scroll); this.add(mainBox, BorderLayout.CENTER); this.validate(); }
From source file:dataviewer.DataViewer.java
private void renderData(DefaultTableModel model) { tb_data.setVisible(false);//from ww w . j a va 2 s . com tb_data.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { @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); c.setBackground(row % 2 == 0 ? Color.WHITE : new Color(240, 240, 240)); if (table.isCellSelected(row, column)) { c.setBackground(new Color(200, 0, 0)); c.setForeground(Color.white); } else if (table.isRowSelected(row)) { c.setBackground(new Color(0, 0, 200)); c.setForeground(Color.white); } else { c.setForeground(Color.black); } return c; } }); tb_data.setGridColor(new Color(220, 220, 220)); tb_data.setShowVerticalLines(true); tb_data.setModel(model); for (int i = 0; i < model.getColumnCount(); ++i) { if (model.getColumnName(i).equals("_N_")) { TableRowSorter trs = new TableRowSorter(model); trs.setComparator(i, new IntComparator()); tb_data.setRowSorter(trs); } } for (int j = 0; j < tb_data.getColumnCount(); j++) { int width = 0; TableColumn col = tb_data.getColumnModel().getColumn(j); TableCellRenderer renderer = tb_data.getTableHeader().getDefaultRenderer(); Component comp = renderer.getTableCellRendererComponent(tb_data, col.getHeaderValue(), false, false, 0, 0); width = Math.max(comp.getPreferredSize().width, width); for (int i = 0; i < tb_data.getRowCount(); i++) { renderer = tb_data.getCellRenderer(i, j); comp = tb_data.prepareRenderer(renderer, i, j); width = Math.max(comp.getPreferredSize().width, width); } tb_data.getColumnModel().getColumn(j).setPreferredWidth(width + 20); } tb_data.setVisible(true); }
From source file:lcmc.common.ui.EditableInfo.java
/** * Adds field with left and right component to the panel. Use panel * with spring layout for this.//w w w . j a va 2s . c o m */ public final void addField(final JPanel panel, final java.awt.Component left, final java.awt.Component right, final int leftWidth, final int rightWidth, int height) { /* right component with fixed width. */ if (height == 0) { height = application.getDefaultSize("Browser.FieldHeight"); } Tools.setSize(left, leftWidth, height); panel.add(left); Tools.setSize(right, rightWidth, height); panel.add(right); right.setBackground(panel.getBackground()); }
From source file:com.raddle.tools.MergeMain.java
private void setCellRenderer(JList list) { list.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override//ww w. java2s .co m public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { PropertyLine line = (PropertyLine) value; boolean isInSelected = false; for (int selectedIndex : list.getSelectedIndices()) { if (index == selectedIndex) { isInSelected = true; } } if (!isInSelected) { if (CompareResult.extra == line.getCompareResult()) { c.setBackground(new Color(0xFFC48E)); } else if (CompareResult.different == line.getCompareResult()) { c.setBackground(new Color(0xBBBBFF)); } } if (line.getState() != null) { if (LineState.added == line.getState()) { c.setForeground(new Color(0xCC0033)); } else if (LineState.updated == line.getState()) { c.setForeground(new Color(0x0066CC)); } else if (LineState.deleted == line.getState()) { if (line.getOriginalValue() == null) { c.setForeground(new Color(0xAAAAAA)); } else { c.setForeground(new Color(0x666666)); } Map<Attribute, Object> map = new HashMap<Attribute, Object>(); map.put(TextAttribute.FONT, c.getFont()); map.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); c.setFont(Font.getFont(map)); } } } return c; } }); }
From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java
protected final static void setBackground(Component c, NuclosScript ns, final Collectable clct, EntityMetaDataVO meta, boolean isEnabled) { try {//from ww w .j a v a 2 s .c o m String rgb = Integer.toHexString(c.getBackground().getRGB()); rgb = rgb.substring(2, rgb.length()); Object o = ScriptEvaluator.getInstance().eval(ns, new CollectableScriptContext(clct), "#" + rgb); if (o instanceof String) { Color color = Color.decode((String) o); if (isEnabled) { c.setBackground(color); } else { c.setBackground(new Color(Math.max(0, color.getRed() - (color.getRed() * 15 / 100)), Math.max(0, color.getGreen() - (color.getGreen() * 15 / 100)), Math.max(0, color.getBlue() - (color.getBlue() * 15 / 100)))); } } } catch (Exception ex) { LOG.warn(ex); } }
From source file:nl.detoren.ijsco.ui.Mainscreen.java
public JPanel createPanelScenarios() { JPanel panel = new JPanel(); panel.setBackground(Color.RED); panel.setLayout(new GridLayout(1, 0)); schemaModel = new SchemaModel(panel, status.schemas); schemaTabel = new JTable(schemaModel) { @Override/*from w w w . j a v a2 s. c o m*/ public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); // Tooltip if (c instanceof JComponent) { SchemaModel model = (SchemaModel) getModel(); ((JComponent) c).setToolTipText(model.getToolTip(row, column).toString()); } // Alternate row color if (!isRowSelected(row)) { c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY); } return c; } }; schemaTabel.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { panel.getParent().getParent().repaint(); } }); JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(schemaTabel); //panel.add(scrollpane, new ExtendedGridConstraints(0, 2)); panel.add(scrollpane); return panel; }