java - Auto create JLabels should be under themselves -
i have code automatically create jlabels
.
i want each label
should @ row, not beside!
i use code:
lbl = new jlabel[rows]; (int = 0; < rows; i++) { lbl[i] = new jlabel(arrayresultrow[i].tostring()+ "\n" ); }
but \n
not work!
google , study java swing layout manager tutorial , start reading.
likely you're adding jlabels jpanel uses flowlayout default, , need change layout of container gridlayout or boxlayout.
edit: here's link: laying out components.
i.e.,
// add jlabels jpanel uses gridlayout set have // 1 column , "rows" number of rows. jpanel labelholder = new jpanel(new gridlayout(rows, 1); lbl = new jlabel[rows]; (int = 0; < rows; i++) { lbl[i] = new jlabel(arrayresultrow[i].tostring()); labelholder.add(lbl[i]); }
Comments
Post a Comment