Link to home
Start Free TrialLog in
Avatar of pjroy
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
Avatar of jpk041897
jpk041897

Not sure if this will help, but the following code is for a multiple coliumn list box:

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)values.elementAt(i), 5, y);
    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;
   }
 }
}


ASKER CERTIFIED SOLUTION
Avatar of Arkadiy
Arkadiy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial