Solved

A simple progress bar with JDK 1.0.2?

Posted on 1998-06-18
1
216 Views
Last Modified: 2013-11-23
Hello, How can I make a simple Progress Bar (in JDK 1.0.2) ?.

   Thanks.
0
Comment
Question by:Deladier
1 Comment
 
LVL 4

Accepted Solution

by:
evijay earned 0 total points
ID: 1223384
here is a solution from graphic java toolkit (gjt)

public class Bargauge extends Component {
    private double          percentFill = 0;
    private ThreeDRectangle border = new ThreeDRectangle(this);
    private Color           fillColor;

    public Bargauge(Color fillColor) {
        setFillColor(fillColor);
    }
    public void setFillColor(Color fillColor) {
        this.fillColor = fillColor;
    }
    public void setFillPercent(double percentage) {
        Assert.notFalse(percentage >= 0 && percentage <= 100);
        percentFill = percentage;
    }
      /**
       * @deprecated for JDK1.1
       */
      public void resize(int w, int h) {
            setSize(w,h);
      }
    public void setSize(int w, int h) {
        setBounds(getLocation().x, getLocation().y, w, h);
    }
      /**
       * @deprecated for JDK1.1
       */
      public void reshape(int x, int y, int w, int h) {
            // compiler will issue deprecation warning, but we can't call
            // super.setBounds(), because it calls reshape()!
        super.reshape(x,y,w,h);
        border.setSize(w,h);
    }
    public void setBounds(int x, int y, int w, int h) {
            reshape(x,y,w,h);
      }
      /**
       * @deprecated for JDK1.1
       */
      public Dimension minimumSize() {
            return getPreferredSize();
      }
    public Dimension getMinimumSize() {
            return minimumSize();
      }
      /**
       * @deprecated for JDK1.1
       */
      public Dimension preferredSize() {
        int w = border.getThickness() * 3;
        return new Dimension(w, w*4);
      }
    public Dimension getPreferredSize() {
            return preferredSize();
    }
    public void paint(Graphics g) {
        border.raise();
        border.paint();
        fill();
    }
    public void fill() {
        Graphics g = getGraphics();

        if((g != null) && (percentFill > 0)) {
            Rectangle b       = border.getInnerBounds();
            int       fillw   = b.width;
            int       fillh   = b.height;

            if(b.width > b.height) fillw *= percentFill/100;
            else                   fillh *= percentFill/100;

            g.setColor(fillColor);
            border.clearInterior();

            if(b.width > b.height)
                g.fill3DRect(b.x, b.y, fillw, b.height, true);
            else                  
                g.fill3DRect(b.x, b.y + b.height - fillh,
                             b.width, fillh, true);
                  g.dispose();
        }
    }
    protected String paramString() {
        Dimension size = getSize();
        Orientation orient = size.width > size.height ?
                             Orientation.HORIZONTAL :
                             Orientation.VERTICAL;
        String    str  = "fill percent=" + percentFill + "," +
                         "orientation="  + orient      + "," +
                         "color"         + fillColor;
        return str;
    }
}


If it didnt run in java 1.0.2, you can always get the gjt for 1.0.2 from java.sun.com/books site
The book you have to search for is Graphic Java 1.1
There you will find link for gjt 1.0 toolkit which is designed for java 1.0 and has a lot more than you want. Also, there is a test program for testing this progress bar


0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java JRE greater than 1.6 5 62
check java version using powershell 13 92
pagenation logic how it is working in my code 1 30
Java: The Public Class Main 4 16
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

773 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