Solved

AWT control like Detail view in Win95

Posted on 1997-05-05
2
166 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:pjroy
2 Comments
 
LVL 6

Expert Comment

by:jpk041897
ID: 1220127
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;
   }
 }
}


0
 
LVL 1

Accepted Solution

by:
Arkadiy earned 0 total points
ID: 1220128
Almost any class library offers sometnhing like column list. I use the one from Microline Software. Go to http://www.neurondata.com/ and select Products.
However, if you have time, you may want to wait for JFC from JavaSoft. That toolkit will eventualy become a part of AWT.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now