?
Solved

A simple progress bar with JDK 1.0.2?

Posted on 1998-06-18
1
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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:
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

800 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