Is it working now?

nope it suppose tp conver 0 and 1 into full and half bar as in loop

What is wrong with what it is doing now?

What does it do?
What do you want it to do differently?

i want to convert the binary code into barcode using fillrect at paint method. which it is not doing

Do you have a formula for converting binary to barcode? How is that supposed to happen?

char nextChar;
                  int length = NewClass.myBinary.length();
        for(int i = 0; i <length; i++)
        {
                nextChar = NewClass.myBinary.charAt(i);
            if(nextChar == '0')
            {
            g.fillRect(x, y, barWidth, halfBar);    
            }
            else   
            {
               g.fillRect(x, y, barWidth, fullBar);
                       x += barGap;
                        }

this suppose to in string myBinary to convert into barcode using fillRect method in above code

What does it do when it executes? What is it supposed to draw? Explain in terms of the rectangles and spaces it draws and say what it is doing wrong.

Add some printlns to it to show you the values it computes and where it is drawing with those values.

it does not open any GUI it just prints that
System.out.println("The is: " + myBinary); at the top. that all it looks like it never goes through rest of the code.

Please post the code that you are executing.
You are trying to do many things that you have not read about how to do. You will continue having problems until you take some time to study how to write a GUI in java.

It suppose to print for every zero i have in myBinary

g.fillRect(x, y, barWidth, halfBar) and for every 1 (x, y, barWidth, fullBar); with gap in between

It suppose to print for every zero i have in myBinary

What does it print out now? Post what it prints and explain what is wrong with it and show what it should be.

It does not print anthing except 1100011000110001100011000110001. it suppose represent evey 0 and 1 with a rectangle some thing like I|||||||||||||||||||||||||||||||||| this in rectange if I have all ones in my binary.

public class Digit
{

    private int zip;

   public Digit(int n)
   {
     zip =n;
   }

   /**
      Converts the zip code number to its binary code equivalent

    */
   public String getCode()
   {
      String bar = "";
      if (zip == 1)
         bar = bar +"00011";
      else if (zip == 2)
         bar = bar + "00101";
      else if (zip == 3)
         bar = bar + "00110";
      else if (zip == 4)
         bar = bar + "01001";
      else if (zip == 5)
         bar = bar + "01010";
      else if (zip == 6)
         bar = bar+ "01100";
      else if (zip == 7)
         bar = "10001";
      else if (zip == 8)
         bar = "10010";
      else if (zip == 9)
         bar = bar+ "10100";
      else
         bar = bar +"11000";

      return bar;
   }
   //----------------------------------
   // separate class
   //------------------------------------

public class BarCode
{
    private int zip;
    private String barCode;
    private String val;
    String binary;
   /**

   */
   public BarCode(String n)
   {
      barCode = n;
   }

   /**
      Make 5 digit objects and concatenate

   */
   public String getCode()
   {

      int sum = 0;
      int temp = 0;

      temp = zip / 10000;
      sum = sum + temp;
      Digit d1 = new Digit(temp);
      barCode =  d1.getCode();
      zip = zip % 10000;

      temp = zip / 1000;
      sum = sum + temp;
      Digit d2 = new Digit(temp);
      barCode =  barCode+d2.getCode();
      zip = zip % 1000;

      temp = zip / 100;
      sum = sum + temp;
      Digit d3 = new Digit(temp);
      barCode =  barCode+d3.getCode();
      zip = zip % 100;

      temp = zip / 10;
      sum = sum + temp;
      Digit d4 = new Digit(temp);
      barCode =  barCode+d4.getCode();
      zip = zip % 10;

      temp = zip;
      sum = sum + temp;
      Digit d5 = new Digit(temp);
      barCode = barCode+d5.getCode();

      temp = 10 - (sum % 10);
      Digit d6 = new Digit(temp);
      barCode =  barCode+ d6.getCode() + 1;

      return barCode;
   }




public String Binary(){
return binary;

here are other 2 class they do what they mean to do. may be you can find a bug one the other

it suppose represent evey 0 and 1 with a rectangle

Can you explain what the code does incorrectly? Can you take a binary number and show what the output is from that number and explain what is wrong with that output?

it does not give any out put it supposed to print a GUI accordingly

Add some println statements that print out messages to show where it is executing. If nothing prints then you will know that it is not executing.

Why do you think that your code will print anything?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.