Solved

A simple progress bar with JDK 1.0.2?

Posted on 1998-06-18
1
218 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

730 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