pjroy
asked on
AWT control like Detail view in Win95
Is there a set of Java classes that can offer more visual control like a detail view in Win95. I need a control that can hold multiple column of data.
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
class ScrollPanel extends Panel {
Vector values;
Font f;
FontMetrics fm;
int ma, md, lines, topOfList;
ScrollPanel(int lines) {
f = new Font("Helvetica", Font.PLAIN, 14);
fm = getFontMetrics(f);
ma = fm.getMaxAscent();
md = fm.getMaxDescent();
this.lines = lines;
topOfList = 0;
values = new Vector();
}
public Dimension minimumSize() {
return new Dimension(0, (ma + md) * lines);
}
public void paint(Graphics g) {
g.clearRect(0, 0, size().width, size().height);
int y = ma;
int lineHeight = ma + md;
int limit = (size().height / lineHeight);
if (limit > (values.size() - topOfList)) {
limit = (values.size() - topOfList);
}
g.setFont(f);
for (int i = topOfList; i < (topOfList + limit); ++i) {
g.drawString((String)value
y += lineHeight;
}
}
public void clear() {
values.removeAllElements()
}
public void addItem(String s) {
values.addElement(s);
}
public void scrollTo(int pos) {
topOfList = pos;
repaint();
}
public int maxScroll() {
int ms = values.size() - lines;
if (ms < 0) {
return 0;
} else {
return ms;
}
}
}