java - horizontal alignment of two JLabels using BoxLayout -
i want align horizontally 2 jlabels using boxlayout, possible? code:
public class creditspanel extends jpanel { private static final long serialversionuid = 1l; private static final int gap = 75; public creditspanel() { super(); this.setlayout(new boxlayout(this, boxlayout.y_axis)); jlabel title = new jlabel("the developers of game: "); this.add(title); title.setalignmentx(component.center_alignment); this.add(box.createverticalstrut(gap)); jlabel[] names = new jlabel[2]; names[0] = new jlabel("pippo"); names[1] = new jlabel("pluto"); int = 0; (jlabel l : names) { imageicon icon = geticon(i); l.setalignmentx(component.center_alignment); l.sethorizontaltextposition(jlabel.center); l.setverticaltextposition(jlabel.top); l.seticon(icon); this.add(l, borderlayout.east); this.add(box.createverticalstrut(25)); i++; } }
thank in advance. geticon private method different icon set labels.
now have this: http://postimg.org/image/tml9wmr4f/ , want this: http://postimg.org/image/nlg0fvygf/
basic code looks fine me.
the thing out of ordinary is:
this.add(l, borderlayout.east);
don't know if borderlayouteast cause problem.
post sscce if need more help.
Comments
Post a Comment