Solved

AWT control like Detail view in Win95

Posted on 1997-05-05
2
169 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
netstat -ano | find "8000" and taskkill /f /pid 2984 3 83
servlet filter example 37 71
Facing this issue for maven proxy setting 2 20
jmss example java 2 23
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

856 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