swing - creating a table interface in java -
how can create interface similar following in java (tweetie)?
i thinking of using jtable 1 columns , customized cell has image in it...not sure how though.
the simplest way (i it) use vertical boxlayout
on jpanel
. each tweet own jpanel
(tweetpanel extends jpanel
) borderlayout
image on west, , tweet text in center.
the following how go laying out 1 of restaurant panels.
public resturantpanel extends jpanel { public resturantpanel(string name, string address, list<string> reviews, icon icon){ setlayout(new borderlayout()); jlabel iconlabel = new jlabel(theicon); jlabel namelabel = new jlabel(name); jlabel addresslabel = new jlabel(address); jpanel southreviewpanel = new jpanel(); southreviewpanel.setlayout(new boxlayout(southreviewpanel, boxlayout.y_axis); (string review: reviews) { southreviewpanel.add(new jtextarea(review)); } add(southreviewpanel); add(iconlabel, borderlayout.west); jpanel northpane = new jpanel(); northpane.setlayout(new boxlayout(northpane, boxlayout.y_axis)); northpane.add(namelabel); northpane.add(addresslabel); add(northpane, borderlayout.north); } }
note, written entirely in editor window. have typos. also, have play sizing of icon, text areas added southreviewpanel
, , southreviewpanel
how want look.
you place bunch of these on jpanel
in jscrollpane
, , go.
Comments
Post a Comment