Solved

A simple progress bar with JDK 1.0.2?

Posted on 1998-06-18
1
213 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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:

762 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