Change a JTable's Look and Feel?

I'm not sure the codes below will work because I grabbed and modified it from some chunks of one of my old project's codes, but you could try.

I'm not sure the codes below will work because I grabbed and modified it from some chunks of one of my old project's codes, but you could try. Public class MyTable extends JTable implements MouseMotionListener { int mouseHoverRow = -1; public MyTable() { addMouseMotionListener(this); } //codes public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) { Component c = super. PrepareRenderer(renderer, rowIndex, vColIndex); Color back = getSelectionBackground(); int red = back.getRed(); int green = back.getGreen(); int blue = back.getBlue(); if (rowIndex == mouseHoverRow) { c.

SetBackground(Color. LIGHT_GRAY); } else { c. SetBackground(getBackground()); } return c; } public void mouseMoved(MouseEvent e) { Point p = new Point(e.getX(), e.getY()); mouseHoverRow = rowAtPoint(p); }.

Added table.repaint(); at the end of mouseMoved() and made some more modifications to this code and it worked beautifully. Thank you. – David Aug 12 at 10:46 you are welcome – Mi Mee Aug 12 at 15:47.

You can probably reach your goal by setting one or several properties you cite in the UIManager (or the UIDefaults) using the method #put(String, String) before rendering your JTable. This link may also help you a bit: java2s.com/Code/Java/Swing-JFC/ListUIPro... Hope it will help!

Thanks for the answer! I tried UIManager. Put("highlight", Color.

Red); but it didn't seem to work though. I'll try some other colour values next. – David Aug 12 at 9:14.

There are four ways 1) override UI 2) use Renderers prepareRenderer lots of various examples for TableCellRenderer 3) for better and nice output to the GUI I recomending to change Look and Feel or use Nimbus Look and Feel or Synth Look and Feel 4) put all a.m. Options together and with Custom painting for JViewPort, ScrollBar.

David confortable would be look for prepareRenderer (works for whole TableView) as for TableCellRenderer (valid for particular TableColumn), please carrefully with Opacities for JTable, TableCellRenderer and TableCellEditor (for getTableCellRendererComponent(...) from link that you posted), I'm not sure that Opacity works as I expected, and that's please follows examples from this forum, there are lots of better code and excellent described – mKorbel Aug 12 at 10:07 +1 especially for 3) and the good links. It was hard to choose an answer, but I was looking for an SSCCE. I have learnt alot from this though.

– David Aug 12 at 10:50 @David for nice thread +1 – mKorbel Aug 12 at 12:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions