swing - Doesn't show scroll in JScrollPane with JTable after Upgrade Java 7 to Java 8 -
i've upgrade project java 8. after running application, scroll jscrollpane doesn't show. same piece of code works in java 7 , ok.
public static void main(string[] a){ jpanel contentpane = new jpanel(); contentpane.setbackground(color.white); contentpane.setborder(new emptyborder(0, 0, 0, 0)); contentpane.setlayout(new javax.swing.boxlayout(contentpane, javax.swing.boxlayout.y_axis)); jpanel aggregates = new jpanel("aggregates", new insets(40, 0, 0, 0)); gridbagconstraints gbc_aggregates = new gridbagconstraints(0, 2, 1, 1, 0.0, 0.0, gridbagconstraints.west, 1, new insets(10, 10, 10, 10), 0, 0); gbl_panel.setconstraints(aggregates, gbc_aggregates); gridbaglayout gbl_agregats = new gridbaglayout(); addparameterslayout(gbl_agregats, new int[]{0,0,0}, new int[]{0, 0},new double[]{ 0.0, 0.0, double.min_value}, new double[]{0.0, double.min_value} ); aggregates.setlayout(gbl_agregats); jtable table = new jtable(new mytablemodel(null)); table.setpreferredsize(new dimension(850, const.rowheight)); jscrollpane scrollpane = new jscrollpane(table); table.setpreferredscrollableviewportsize(new dimension(850, 10 *const.rowheight)); gridbagconstraints gbc_scrollpane= new gridbagconstraints(0, 1, 3, 1, 0.0, 0.0, gridbagconstraints.west, 1, new insets(5, 5, 20, 5), 0, 0); gbl_agregats.setconstraints(scrollpane, gbc_scrollpane); aggregates.add(scrollpane); jpanel main_panel = new jpanel(); main_panel.add(aggregates); jscrollpane scrpane = new jscrollpane(main_panel); scrpane.getverticalscrollbar().setunitincrement(16); scrpane.setborder(borderfactory.createemptyborder()); scrpane.getinsets().set(0, 0, 0, 0); contentpane.add(scrpane); setcontentpane(contentpane); } public static void addparameterslayout(gridbaglayout gbl, int[] columnwidths, int[] rowheights, double[] columnweights, double[] rowweights) { gbl.columnwidths = columnwidths; gbl.rowheights = rowheights; gbl.columnweights = columnweights; gbl.rowweights = rowweights; }
question: changed in java 8 ? why same scroll looks ok in older java version ?
edited:
maybe i'm not specific. when compile project see (just bar):
i can scroll table because it's working, it's invisible (i see bar).
import java.awt.color; import java.awt.dimension; import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import java.awt.insets; import java.awt.layoutmanager; import javax.swing.borderfactory; import javax.swing.jpanel; import javax.swing.jscrollpane; import javax.swing.jtab import javax.swing.border.emptyborder; public class source8 { public static void main(string[] a){ jpanel contentpane = new jpanel(); contentpane.setbackground(color.white); contentpane.setborder(new emptyborder(0, 0, 0, 0)); contentpane.setlayout(new javax.swing.boxlayout(contentpane, javax.swing.boxlayout.y_axis)); jpanel aggregates = new jpanel((layoutmanager) new insets(40, 0,0, 0)); gridbagconstraints gbc_aggregates = new gridbagconstraints(0, 2, 1, 1, 0.0, 0.0, gridbagconstraints.west, 1, new insets(10, 10, 10, 10), 0, 0); gridbaglayout gbl_panel = new gridbaglayout(); gbl_panel.setconstraints(aggregates, gbc_aggregates); gridbaglayout gbl_agregats = new gridbaglayout(); addparameterslayout(gbl_agregats, new int[]{0,0,0}, new int[]{0, 0},new double[]{ 0.0, 0.0, double.min_value}, new double[]{0.0, double.min_value} ); aggregates.setlayout(gbl_agregats); jtable table = new jtable(new mytablemodel(null)); table.setpreferredsize(new dimension(850, const.rowheight)); jscrollpane scrollpane = new jscrollpane(table); table.setpreferredscrollableviewportsize(new dimension(850, 10 *const.rowheight)); gridbagconstraints gbc_scrollpane= new gridbagconstraints(0, 1, 3, 1, 0.0, 0.0, gridbagconstraints.west, 1, new insets(5, 5, 20, 5), 0, 0); gbl_agregats.setconstraints(scrollpane, gbc_scrollpane); aggregates.add(scrollpane); jpanel main_panel = new jpanel(); main_panel.add(aggregates); jscrollpane scrpane = new jscrollpane(main_panel); scrpane.getverticalscrollbar().setunitincrement(16); scrpane.setborder(borderfactory.createemptyborder()); scrpane.getinsets().set(0, 0, 0, 0); contentpane.add(scrpane); setcontentpane(contentpane); } public static void addparameterslayout(gridbaglayout gbl, int[] columnwidths, int[] rowheights, double[] columnweights, double[] rowweights) { gbl.columnwidths = columnwidths; gbl.rowheights = rowheights; gbl.columnweights = columnweights; gbl.rowweights = rowweights; } private static void setcontentpane(jpanel contentpane) { throw new unsupportedoperationexception("not supported yet."); //to change body of generated methods, choose tools | templates. } }
some change in code hope works §§thanks
Comments
Post a Comment