Solved

A simple progress bar with JDK 1.0.2?

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

688 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