swing - Java JTable - Transparence with Nimbus/System L&F -
i have jtable:
list<mytuple> l= new arraylist<>(); l.add(new element(1,"one")); l.add(new element(2,"two")); l.add(new element(3,"three")); l.add(new element(4,"four")); l.add(new element(5,"five")); l.add(new element(6,"six")); l.add(new element(7,"seven")); jscrollpane pane = new jscrollpane(); pane.setopaque(false); pane.setborder(new emptyborder(0, 0, 0, 0)); pane.setbackground(new color(0,0,0,0)); pane.setfont(new font("segoe ui semibold", font.plain, 12)); pane.setbounds(3, 101, 707, 297); mytablemodel tm=new mytablemodel(l); table = new mytable(tm); table.setborder(new emptyborder(0, 0, 0, 0)); table.setopaque(false); //table.gettableheader().setbackground(new color(0,0,0,0)); table.gettableheader().setopaque(true); table.gettableheader().setborder(new emptyborder(0,0,0,0)); table.setbackground(new color(0,0,0,0)); table.setfont(new font("segoe ui semibold", font.plain, 12)); table.setfillsviewportheight(false); table.gettableheader().setfont(new font("segoe ui semibold", font.plain, 13)); table.setautoresizemode(jtable.auto_resize_all_columns); pane.setviewportview(table); pane.getviewport().setopaque(false); table.setgridcolor(color.gray); table.setshowgrid(true); getcontentpane().add(pane);
mytuple, mytable , mytablemodel classes don't set custom rendering.
this how table looks under system l&f (which like):
this how table looks under nimbus l&f (note added big rectangle):
i want table 1 system l&f. problem if set 1 l&f want, other gets ugly, want sort of "compatibility", there way so?
maybe using uimanager.put() method?
you forgot set border around viewport
of scrollpane
. possible solutions:
pane.setviewportborder(null);
pane.setviewportborder(borderfactory.createemptyborder());
pane.setviewportborder(new emptyborder(0, 0, 0, 0));
note pane.getviewport().setborder(...)
not work, because jviewport
doesn't have border, setviewportborder
draws border around viewport. (reference)
to make table header transparent:
pane.setcolumnheader(new jviewport()); pane.getcolumnheader().setopaque(false); table.gettableheader().setopaque(false);
Comments
Post a Comment