mport java.awt.Color;
import java.awt.Graphics;
import javax.swing.JOptionPane;
why this is not working need help
public class NewClass
{ static String myBinary;
public static void main(String[] args)
{
String code = JOptionPane.showInputDialog("Please enter zipCode: ");
BarCode myBar = new BarCode(code);
myBinary = myBar.getCode();
int length= code.length();
if (length != 5 && length!=9)
System.out.println("please enter a valid zipcode code");
else
System.out.println("The is: " + myBinary);
}
public void DrawBarCode(Graphics page){
int x = 200;
int y = 300;
int barWidth = 6; // Calculate a width of the bar
int fullBar = 32; // Calculate the full length bar
int halfBar = 16; // Calculate the half length bar
int barGap = 6; // Calculate space between bars
Graphics graphicsBarCode = page.create();
graphicsBarCode.setColor(Color.yellow);
graphicsBarCode.fillRect(x,y,320,30);
graphicsBarCode.setColor(Color.black);
char nextChar;
for(int i = 0; i < myBinary.length(); i++)
{
nextChar = myBinary.charAt(i);
if(nextChar == '0')
{
page.fillRect(x, y, barWidth, halfBar);
}
else //
{
page.fillRect(x, y, barWidth, fullBar);
x += barGap;
}
}
}
}
Quoted Text Here